MediaInfoLib/0000775000000000000000000000000012652076434012051 5ustar rootrootMediaInfoLib/debian/0000775000000000000000000000000012652076434013273 5ustar rootrootMediaInfoLib/debian/libmediainfo0.install0000664000000000000000000000002512652076434017362 0ustar rootroot/usr/lib/*/lib*.so.* MediaInfoLib/debian/python-mediainfodll.install0000664000000000000000000000002212652076434020623 0ustar rootroot/usr/lib/python2* MediaInfoLib/debian/compat0000664000000000000000000000000212652076434014471 0ustar rootroot9 MediaInfoLib/debian/libmediainfo-doc.examples0000664000000000000000000000003412652076434020215 0ustar rootrootSource/Example/HowToUse.cpp MediaInfoLib/debian/libmediainfo0.symbols0000664000000000000000000002111312652076434017405 0ustar rootrootlibmediainfo.so.0 libmediainfo0 #MINVER# MediaInfoA_Close@Base 0.7.52 MediaInfoA_Count_Get@Base 0.7.52 MediaInfoA_Delete@Base 0.7.52 MediaInfoA_Get@Base 0.7.52 MediaInfoA_GetI@Base 0.7.52 MediaInfoA_Inform@Base 0.7.52 MediaInfoA_New@Base 0.7.52 MediaInfoA_New_Quick@Base 0.7.52 MediaInfoA_Open@Base 0.7.52 MediaInfoA_Open_Buffer@Base 0.7.52 MediaInfoA_Open_Buffer_Continue@Base 0.7.52 MediaInfoA_Open_Buffer_Continue_GoTo_Get@Base 0.7.52 MediaInfoA_Open_Buffer_Finalize@Base 0.7.52 MediaInfoA_Open_Buffer_Init@Base 0.7.52 MediaInfoA_Open_NextPacket@Base 0.7.52 MediaInfoA_Option@Base 0.7.52 MediaInfoA_Output_Buffer_Get@Base 0.7.52 MediaInfoA_Output_Buffer_GetI@Base 0.7.52 MediaInfoA_Save@Base 0.7.52 MediaInfoA_Set@Base 0.7.52 MediaInfoA_SetI@Base 0.7.52 MediaInfoA_State_Get@Base 0.7.52 MediaInfoListA_Close@Base 0.7.52 MediaInfoListA_Count_Get@Base 0.7.52 MediaInfoListA_Count_Get_Files@Base 0.7.52 MediaInfoListA_Delete@Base 0.7.52 MediaInfoListA_Get@Base 0.7.52 MediaInfoListA_GetI@Base 0.7.52 MediaInfoListA_Inform@Base 0.7.52 MediaInfoListA_New@Base 0.7.52 MediaInfoListA_New_Quick@Base 0.7.52 MediaInfoListA_Open@Base 0.7.52 MediaInfoListA_Open_Buffer@Base 0.7.52 MediaInfoListA_Option@Base 0.7.52 MediaInfoListA_Save@Base 0.7.52 MediaInfoListA_Set@Base 0.7.52 MediaInfoListA_SetI@Base 0.7.52 MediaInfoListA_State_Get@Base 0.7.52 MediaInfoList_Close@Base 0.7.52 MediaInfoList_Count_Get@Base 0.7.52 MediaInfoList_Count_Get_Files@Base 0.7.52 MediaInfoList_Delete@Base 0.7.52 MediaInfoList_Get@Base 0.7.52 MediaInfoList_GetI@Base 0.7.52 MediaInfoList_Inform@Base 0.7.52 MediaInfoList_New@Base 0.7.52 MediaInfoList_New_Quick@Base 0.7.52 MediaInfoList_Open@Base 0.7.52 MediaInfoList_Open_Buffer@Base 0.7.52 MediaInfoList_Option@Base 0.7.52 MediaInfoList_Save@Base 0.7.52 MediaInfoList_Set@Base 0.7.52 MediaInfoList_SetI@Base 0.7.52 MediaInfoList_State_Get@Base 0.7.52 MediaInfo_Close@Base 0.7.52 MediaInfo_Count_Get@Base 0.7.52 MediaInfo_Delete@Base 0.7.52 MediaInfo_Get@Base 0.7.52 MediaInfo_GetI@Base 0.7.52 MediaInfo_Info_Version@Base 0.7.52 MediaInfo_Inform@Base 0.7.52 MediaInfo_New@Base 0.7.52 MediaInfo_New_Quick@Base 0.7.52 MediaInfo_Open@Base 0.7.52 MediaInfo_Open_Buffer@Base 0.7.52 MediaInfo_Open_Buffer_Continue@Base 0.7.52 MediaInfo_Open_Buffer_Continue_GoTo_Get@Base 0.7.52 MediaInfo_Open_Buffer_Finalize@Base 0.7.52 MediaInfo_Open_Buffer_Init@Base 0.7.52 MediaInfo_Open_NextPacket@Base 0.7.52 MediaInfo_Option@Base 0.7.52 MediaInfo_Output_Buffer_Get@Base 0.7.52 MediaInfo_Output_Buffer_GetI@Base 0.7.52 MediaInfo_Save@Base 0.7.52 MediaInfo_Set@Base 0.7.52 MediaInfo_SetI@Base 0.7.52 MediaInfo_State_Get@Base 0.7.52 (c++)"MediaInfoLib::MediaInfoList::Option_Static(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfoList::Open_Buffer_Init(unsigned long long, unsigned long long)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Open_Buffer_Continue\(unsigned (int|long), unsigned char const\*, unsigned (int|long)\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Open_Buffer_Finalize\(unsigned (int|long)\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Open_Buffer_Continue_GoTo_Get\(unsigned (int|long)\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Get\(unsigned (int|long), MediaInfoLib::stream_t, unsigned (int|long), std::basic_string, std::allocator > const&, MediaInfoLib::info_t, MediaInfoLib::info_t\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Get\(unsigned (int|long), MediaInfoLib::stream_t, unsigned (int|long), unsigned (int|long), MediaInfoLib::info_t\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Set\(std::basic_string, std::allocator > const&, unsigned (int|long), MediaInfoLib::stream_t, unsigned (int|long), std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Set\(std::basic_string, std::allocator > const&, unsigned (int|long), MediaInfoLib::stream_t, unsigned (int|long), unsigned (int|long), std::basic_string, std::allocator > const&\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfoList::Open(std::basic_string, std::allocator > const&, MediaInfoLib::fileoptions_t)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Save\(unsigned (int|long)\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Close\(unsigned (int|long)\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Inform\(unsigned (int|long), unsigned (int|long)\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfoList::Option(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::Count_Get\(unsigned (int|long), MediaInfoLib::stream_t, unsigned (int|long)\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfoList::Count_Get()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfoList::State_Get()@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfoList::MediaInfoList\(unsigned (int|long)\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfoList::~MediaInfoList()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Option_Static(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Open_NextPacket()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Open_Buffer_Init(unsigned long long, unsigned long long)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Output_Buffer_Get(std::basic_string, std::allocator > const&)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Output_Buffer_Get\(unsigned (int|long)\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Open_Buffer_Continue\(unsigned char const\*, unsigned (int|long)\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Open_Buffer_Finalize()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Open_Buffer_Continue_GoTo_Get()@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Get\(MediaInfoLib::stream_t, unsigned (int|long), std::basic_string, std::allocator > const&, MediaInfoLib::info_t, MediaInfoLib::info_t\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Get\(MediaInfoLib::stream_t, unsigned (int|long), unsigned (int|long), MediaInfoLib::info_t\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Set\(std::basic_string, std::allocator > const&, MediaInfoLib::stream_t, unsigned (int|long), std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Set\(std::basic_string, std::allocator > const&, MediaInfoLib::stream_t, unsigned (int|long), unsigned (int|long), std::basic_string, std::allocator > const&\)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Open\(unsigned char const\*, unsigned (int|long), unsigned char const\*, unsigned (int|long), unsigned (int|long) long\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Open(std::basic_string, std::allocator > const&)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Save()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Close()@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Inform\(unsigned (int|long)\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::Option(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)@Base" 0.7.52 (c++|regex)"MediaInfoLib::MediaInfo::Count_Get\(MediaInfoLib::stream_t, unsigned (int|long)\)@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::State_Get()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::MediaInfo()@Base" 0.7.52 (c++)"MediaInfoLib::MediaInfo::~MediaInfo()@Base" 0.7.52 (optional|c++|regex)"^(std|__gnu_cxx)::" 0.7.52 (optional|c++|regex)"^(bool|void|MediaInfoLib::File_Mxf::indextable\*|(unsigned )?(int|short|(long )?long)\*) (std|__gnu_cxx)::" 0.7.52 MediaInfoLib/debian/libmediainfo-dev.install0000664000000000000000000000052412652076434020062 0ustar rootroot/usr/lib/*/lib*.so /usr/lib/*/pkgconfig Source/MediaInfo/MediaInfo.h /usr/include/MediaInfo Source/MediaInfo/MediaInfoList.h /usr/include/MediaInfo Source/MediaInfo/MediaInfo_Const.h /usr/include/MediaInfo Source/MediaInfo/MediaInfo_Events.h /usr/include/MediaInfo Source/MediaInfoDLL/MediaInfoDLL.h /usr/include/MediaInfoDLL MediaInfoLib/debian/watch0000664000000000000000000000010312652076434014316 0ustar rootrootversion=3 http://sf.net/mediainfo/libmediainfo_([0-9.]+)\.tar\.xz MediaInfoLib/debian/gbp.conf0000664000000000000000000000000012652076434014700 0ustar rootrootMediaInfoLib/debian/autoreconf0000664000000000000000000000002412652076434015357 0ustar rootrootProject/GNU/Library MediaInfoLib/debian/libmediainfo-doc.docs0000664000000000000000000000003012652076434017323 0ustar rootrootDocumentation.html Doc/ MediaInfoLib/debian/copyright0000664000000000000000000000673512652076434015241 0ustar rootrootFormat: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: libmediainfo Upstream-Contact: MediaArea.net SARL Source: http://mediainfo.sf.net Files: * Copyright: 2002-2013, MediaArea.net SARL License: BSD-2-clause Files: Project/MSCS2008/Example/HowToUse_Dll.cs Project/MSCS2010/Example/HowToUse_Dll.cs Copyright: MediaArea.net SARL License: Zlib Files: Source/ThirdParty/tinyxml2/tinyxml2.cpp Source/ThirdParty/tinyxml2/tinyxml2.h Copyright: Copyright: 2011-2012 Lee Thomason License: Zlib Files: Source/ThirdParty/aes-gladman/* Copyright: 1998-2013, Brian Gladman License: aes-gladman Files: debian/* Copyright: 2008-2015, MediaArea.net SARL 2012-2015, Chow Loong Jin License: BSD-2-clause License: Zlib 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. License: BSD-2-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: aes-gladman The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: . source code distributions include the above copyright notice, this list of conditions and the following disclaimer; . binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. . This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. MediaInfoLib/debian/control0000664000000000000000000001424512652076434014704 0ustar rootrootSource: libmediainfo Priority: optional Maintainer: MediaArea.net SARL Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1), python-all (>= 2.6.6-3~), python3-all, dh-autoreconf, doxygen, tofrodos, libzen-dev (>= 0.4.32), libtinyxml2-dev, libcurl4-gnutls-dev, libmms-dev, libglib2.0-dev, zlib1g-dev, pkg-config Standards-Version: 3.9.6 Section: libs Homepage: http://MediaArea.net/MediaInfo Vcs-Git: https://github.com/MediaArea/MediaInfoLib.git Vcs-Browser: https://github.com/MediaArea/MediaInfoLib Package: libmediainfo-dev Section: libdevel Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: libzen-dev, libmediainfo0 (= ${binary:Version}), ${misc:Depends} Description: library reading metadata from media files -- headers MediaInfo is a library used for retrieving technical information and other metadata about audio or video files. . A non-exhaustive list of the information MediaInfo can retrieve from media files include: - General: title, author, director, album, track number, date, duration... - Video: codec, aspect, fps, bitrate... - Audio: codec, sample rate, channels, language, bitrate... - Text: language of subtitle - Chapters: number of chapters, list of chapters . MediaInfo supports the following formats: - Video: MKV, OGM, AVI, DivX, WMV, QuickTime, Real, MPEG-1, MPEG-2, MPEG-4, DVD (VOB)... - Video Codecs: DivX, XviD, MSMPEG4, ASP, H.264, AVC...) - Audio: OGG, MP3, WAV, RA, AC3, DTS, AAC, M4A, AU, AIFF... - Subtitles: SRT, SSA, ASS, SAMI... . This package contains the headers and other development support files needed for compiling and linking applications and libraries which use this library. Package: libmediainfo0 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Description: library for reading metadata from media files -- shared library MediaInfo is a library used for retrieving technical information and other metadata about audio or video files. . A non-exhaustive list of the information MediaInfo can retrieve from media files include: - General: title, author, director, album, track number, date, duration... - Video: codec, aspect, fps, bitrate... - Audio: codec, sample rate, channels, language, bitrate... - Text: language of subtitle - Chapters: number of chapters, list of chapters . MediaInfo supports the following formats: - Video: MKV, OGM, AVI, DivX, WMV, QuickTime, Real, MPEG-1, MPEG-2, MPEG-4, DVD (VOB)... - Video Codecs: DivX, XviD, MSMPEG4, ASP, H.264, AVC...) - Audio: OGG, MP3, WAV, RA, AC3, DTS, AAC, M4A, AU, AIFF... - Subtitles: SRT, SSA, ASS, SAMI... . This package contains the shared library needed for running applications which use this library. Package: python-mediainfodll Section: python Architecture: all Depends: ${python:Depends}, libmediainfo0 (>= ${source:Version}), ${misc:Depends} Description: library for reading metadata from media files -- shared library MediaInfo is a library used for retrieving technical information and other metadata about audio or video files. . A non-exhaustive list of the information MediaInfo can retrieve from media files include: - General: title, author, director, album, track number, date, duration... - Video: codec, aspect, fps, bitrate... - Audio: codec, sample rate, channels, language, bitrate... - Text: language of subtitle - Chapters: number of chapters, list of chapters . MediaInfo supports the following formats: - Video: MKV, OGM, AVI, DivX, WMV, QuickTime, Real, MPEG-1, MPEG-2, MPEG-4, DVD (VOB)... - Video Codecs: DivX, XviD, MSMPEG4, ASP, H.264, AVC...) - Audio: OGG, MP3, WAV, RA, AC3, DTS, AAC, M4A, AU, AIFF... - Subtitles: SRT, SSA, ASS, SAMI... . This package contains the Python 2.x module required for using this library from Python 2.x applications. Package: python3-mediainfodll Section: python Architecture: all Depends: ${python3:Depends}, libmediainfo0 (>= ${source:Version}), ${misc:Depends} Description: library for reading metadata from media files -- shared library MediaInfo is a library used for retrieving technical information and other metadata about audio or video files. . A non-exhaustive list of the information MediaInfo can retrieve from media files include: - General: title, author, director, album, track number, date, duration... - Video: codec, aspect, fps, bitrate... - Audio: codec, sample rate, channels, language, bitrate... - Text: language of subtitle - Chapters: number of chapters, list of chapters . MediaInfo supports the following formats: - Video: MKV, OGM, AVI, DivX, WMV, QuickTime, Real, MPEG-1, MPEG-2, MPEG-4, DVD (VOB)... - Video Codecs: DivX, XviD, MSMPEG4, ASP, H.264, AVC...) - Audio: OGG, MP3, WAV, RA, AC3, DTS, AAC, M4A, AU, AIFF... - Subtitles: SRT, SSA, ASS, SAMI... . This package contains the Python 3.x module required for using this library from Python 3.x applications. Package: libmediainfo-doc Section: doc Architecture: all Depends: ${misc:Depends} Description: library for reading metadata from media files -- documentation MediaInfo is a library used for retrieving technical information and other metadata about audio or video files. . A non-exhaustive list of the information MediaInfo can retrieve from media files include: - General: title, author, director, album, track number, date, duration... - Video: codec, aspect, fps, bitrate... - Audio: codec, sample rate, channels, language, bitrate... - Text: language of subtitle - Chapters: number of chapters, list of chapters . MediaInfo supports the following formats: - Video: MKV, OGM, AVI, DivX, WMV, QuickTime, Real, MPEG-1, MPEG-2, MPEG-4, DVD (VOB)... - Video Codecs: DivX, XviD, MSMPEG4, ASP, H.264, AVC...) - Audio: OGG, MP3, WAV, RA, AC3, DTS, AAC, M4A, AU, AIFF... - Subtitles: SRT, SSA, ASS, SAMI... . This package contains the Doxygen generated API reference for developing applications/libraries using this library. MediaInfoLib/debian/python3-mediainfodll.install0000664000000000000000000000002212652076434020706 0ustar rootroot/usr/lib/python3* MediaInfoLib/debian/changelog0000664000000000000000000002502212652076434015146 0ustar rootrootlibmediainfo (0.7.82-1) experimental; urgency=medium * Upstream version 0.7.82 For details, see https://github.com/MediaArea/MediaInfoLib/blob/master/History_DLL.txt -- MediaArea Mon, 02 Nov 2015 10:30:00 +0100 libmediainfo (0.7.70-1) unstable; urgency=medium * [eff1e51] Imported Upstream version 0.7.70 * [3253f5d] Update copyright file to include aes-gladman bits * [0fb5774] Refresh patches -- Chow Loong Jin Thu, 18 Sep 2014 19:01:31 +0800 libmediainfo (0.7.69-1) unstable; urgency=medium * [6b3a5a1] Imported Upstream version 0.7.69 -- Chow Loong Jin Mon, 05 May 2014 03:26:31 +0800 libmediainfo (0.7.68-1) unstable; urgency=medium * [eb215b4] Imported Upstream version 0.7.68 -- Chow Loong Jin Wed, 09 Apr 2014 02:13:18 +0800 libmediainfo (0.7.67-2) unstable; urgency=low * [6756a05] Re-add pkgconfig path to libmediainfo-dev.install -- Chow Loong Jin Wed, 15 Jan 2014 20:39:24 +0800 libmediainfo (0.7.67-1) unstable; urgency=low * [40db143] Imported Upstream version 0.7.67 * [e6819b5] No-change bump of Standards-Version to 3.9.5 * [eda1a64] Fix pc file location not respecting multiarch paths -- Chow Loong Jin Mon, 13 Jan 2014 03:02:39 +0800 libmediainfo (0.7.65-1) unstable; urgency=low * [a5f5c7f] Imported Upstream version 0.7.65 * [e715bca] Drop fromdos command after dh_installdocs. The .txt files we used to install seem to have vanished. -- Chow Loong Jin Tue, 26 Nov 2013 01:34:04 +0800 libmediainfo (0.7.64-3) unstable; urgency=low * [3ff3203] Install MediaInfoDLL.h for C bindings (Closes: #702993) * [551fb07] Add packages for python bindings * [29bf174] Use dh_python{2,3} * [7eda431] Install python modules -- Chow Loong Jin Sun, 18 Aug 2013 03:49:45 +0800 libmediainfo (0.7.64-2) unstable; urgency=low * [40791b4] Update Homepage * [f9eb35b] Relicense debian/* under BSD-2-clause * [b9c78ab] Make libmediainfo-dev depend on libzen-dev. Its headers have some ZenLib includes, so libzen-dev is necessary. (LP: #1212569) * [62135a3] Add use of Requires: libzen into .pc -- Chow Loong Jin Sat, 17 Aug 2013 03:13:53 +0800 libmediainfo (0.7.64-1) unstable; urgency=low * [3d2c4db] Imported Upstream version 0.7.64 * [b7f14a1] Update copyright file -- Chow Loong Jin Tue, 09 Jul 2013 23:05:18 +0800 libmediainfo (0.7.63-1) unstable; urgency=low * [cd628ff] Imported Upstream version 0.7.63 * [4d8e014] Enable some additional dependencies * [c1efa4c] Refresh patch * [702fe1a] Add patch to fix pkg-config missing error * [1f67600] Build-depend on libglib2.0-dev mms.pc depends on glib-2.0.pc, but libmms-dev doesn't depend on libglib2.0-dev. This can be dropped once libmms-dev is fixed. -- Chow Loong Jin Thu, 16 May 2013 23:30:01 +0800 libmediainfo (0.7.62-1) experimental; urgency=low * [d63ebce] Imported Upstream version 0.7.62 * [bf20076] No-change bump of Standards-Version to 3.9.4 -- Chow Loong Jin Mon, 11 Mar 2013 22:11:12 +0800 libmediainfo (0.7.61-1) experimental; urgency=low * [94f6dbd] Imported Upstream version 0.7.61 * [360e5da] Refresh Drop-direct-linkage-of-libzen-in-.pc.patch -- Chow Loong Jin Sun, 28 Oct 2012 04:58:26 +0800 libmediainfo (0.7.60-1) experimental; urgency=low * [4068ade] Imported Upstream version 0.7.60 -- Chow Loong Jin Tue, 04 Sep 2012 01:25:51 +0800 libmediainfo (0.7.59-1) experimental; urgency=low * [5c6d445] Bump libzen-dev build-dep version * [f80f420] Imported Upstream version 0.7.59 -- Chow Loong Jin Sun, 19 Aug 2012 20:12:33 +0800 libmediainfo (0.7.58-1) unstable; urgency=low * [7821ed5] Imported Upstream version 0.7.58 -- Chow Loong Jin Sun, 03 Jun 2012 14:44:10 +0800 libmediainfo (0.7.57-1) unstable; urgency=low * [253bc4c] Imported Upstream version 0.7.57: - New features: + #3513490, Vorbis comment (Flac, Ogg): more tags are supported + XML-based formats (P2, XDCAM, DCP, ISM, HLS...): support of UTF-16 encoding + MPEG-4: for buggy PCM, prioritizing the codec ID "in24" = 24-bit against the bit depth field - Upstream Bug fixes: + #3516900, Vorbis comment (Flac, Ogg): trying to do better mapping of PERFORMER and ARTIST tags + MXF: wrong video frame count in some cases + #3517374, GCC 4.7: compilation issues removal, thanks to SpepS + MPEG-PS: some files were not well demuxed so analysis was sometimes wrong (especially macroblock parsing) * [77978a5] Build-depend on libtinyxml2-dev * [41b551c] Update configure flag to --with-libtinyxml2 * [22ad4d4] Update regex for ignored symbols * [1636c13] Call dpkg-gensymbols with -c4. We want to be as strict as possible to ensure that the symbols file is always up to date. -- Chow Loong Jin Thu, 24 May 2012 21:16:58 +0800 libmediainfo (0.7.56-1) unstable; urgency=low * [49afb28] Imported Upstream version 0.7.56: - New features: + Better support of machines lacking of std::stringstream + Better support of machines requesting explicit stdc++ library link option (e.g. some ARM embedded devices) + AC-3: support of little endian streams + LXF: support of format version 0 + HLS: support of .m3u8 index and sequence referencing a bunch of MPEG-TS files + MPEG-4: Added support of glbl atom and corresponding 4CC (ai12, ai15, ai1q, ai5q) + MPEG-4: Added detection of files with mx5p files wrongly filled with raw MPEG Video instead of MXF + MPEG-TS: Detection of 20-bit Dolby E even if the SMPTE 302 M header is set to 24-bit - Upstream bug fixes: + Correction + sf#3515515, MPEG-4: crash with MPEG-4 container + H264/AVC video stream + sf#3515393, MPEG Audio: infinite loop (freeze) with some files + sf#3514677, Video: Well known 1.85:1 display aspect ratio was incorrectly displayed as 16:9 + sf#3513908, File interface: No output if filename contain a colon + AVI: infinite loop (freeze) with some files (having index containing 0-sized chunk) + AVC: memory leaks + libcurl support: libcurl config from MediaInfo is compatible with libcurl+gnutls + sf#3513490, Id3v2: mapping of "Encoded by" and "Encoding library" is conform to the specs now + MXF: hang up with some clip-wrapped files + MPEG-4: AVC-100 bit rate was not coherent depending of the container (MPEG-4 or MXF) + reVTMD output is disabled due to its non-free (point of view of FSF and DFSG) licensing. * [2527bf2] Drop 0001-Don-t-expose-tinyxml-dependency.patch (applied upstream) * [7a2e4d4] Refresh Drop-direct-linkage-of-libzen-in-.pc.patch * [6435829] Bump Standards-Version to 3.9.3 - Update debian/copyright Format URL * [4b620bd] Bump debhelper build-dep version to 9 -- Chow Loong Jin Sun, 22 Apr 2012 18:56:27 +0800 libmediainfo (0.7.54-1) UNRELEASED; urgency=low * [3e0843e] Update watch url * [6aab287] Imported Upstream version 0.7.54: - New features: + #3480111, Matroska: parsing of WebM-style frame rate info + #3499859, ALAC: parsing of the alac atom, for real bit depth / sample rate + #3487601, DV: fields order (TFF/BFF) + MPEG-4: more video 4CCs binded to MPEG Video + H.263: raw stream parsing (width, height, aspect ratio), comparison with container data + Speed improvements + MPEG-PS: supporting parsing of some non-conform files + Full support of CEA-608 (separation of CC1-CC4, T1-T4) + #3494722, MPEG-4: trying to detect wrong duration in track header + MPEG-4 with embedded MXF track (XDCAM...): separation of video bitrate and padding bitrate + Compound streams (e.g. DV): separation of video bitrate and audio bitrate + Blu-ray: LPCM mono real bit rate is separated from the encoded (stereo) bit rate + Support of https, sftp scp protocols (custom builds only) + AVI: vprp (OpenDML) display aspect ratio support - Upstream bug fixes: + sf#3480111, Matroska: some frame rates are incorrect in the file, trying to detect this kind of malformed file + sf#3479494, AVC: segmentation fault + sf#3440638, AAC: wrong detection for some malformed AAC streams + sf#3440638, MPEG-4: wrong analysis of some files having track header after media information + sf#3480111, MXF: Height was wrong for MXF with FrameLayout = Mixed fields + sf#3468235, Blu-ray: displaying PGS in all cases (even if PES is not detected, they are too much rare) + sf#3498846, MPEG-4: delay between audio and video was no more detected + sf#3495573, MPEG-4: crash with some files having fragments + MPEG-4: channel position in case of channel atom is configured with ChannelBitmap + MPEG-TS: crash with some buggy files (a PID indicated as PSI and PES at the same time) + AES3: not detecting Dolby E stream if there is guard band before the Dolby E frame, in MPEG-TS + DPX: some files with some invalid fields were not detected + DTVCC Captions: crash with some buggy streams -- Chow Loong Jin Sat, 31 Mar 2012 06:01:01 +0800 libmediainfo (0.7.53-2) unstable; urgency=low * [c68e5bb] Clean up doxygen generated files. This fixes issues with double-building. (Closes: #656918) * [3e7e828] Drop public dependency of libzen in .pc file * [e8b4cce] Drop libzen-dev dependency in libmediainfo-dev -- Chow Loong Jin Sun, 29 Jan 2012 06:15:32 +0800 libmediainfo (0.7.53-1) unstable; urgency=low * [c09c8a3] Add watchfile * [d01eaa2] Imported Upstream version 0.7.53 - Fixes issue with missing -DUNICODE flag (Closes: #656929) * [1f9257f] Drop gbp.conf. We use gz tarballs which are pristine-tar-able now * [4fa4d5a] Add --with-tinyxml (use system tinyxml) * [2515c8e] Enable parallel builds * [739b1ec] Don't expose tinyxml dependency * [1a43861] Add libzen to Requires of .pc file -- Chow Loong Jin Thu, 26 Jan 2012 10:26:36 +0800 libmediainfo (0.7.52-1) unstable; urgency=low * Initial release (Closes: #654235) -- Chow Loong Jin Mon, 02 Jan 2012 19:29:00 +0800 MediaInfoLib/debian/source/0000775000000000000000000000000012652076434014573 5ustar rootrootMediaInfoLib/debian/source/format0000664000000000000000000000001412652076434016001 0ustar rootroot3.0 (quilt) MediaInfoLib/debian/rules0000775000000000000000000000317712652076434014363 0ustar rootroot#!/usr/bin/make -f # -*- makefile -*- include /usr/share/dpkg/default.mk # shared library versions version = $(DEB_VERSION_UPSTREAM) override_dh_auto_configure: dh_auto_configure -DProject/GNU/Library -- \ --enable-shared \ --enable-visibility \ --with-libcurl \ --with-libmms \ --with-libtinyxml2 \ --without-libmd5 override_dh_auto_build: cd Source/Doc && doxygen Doxyfile cp Source/Doc/*.html ./ dh_auto_build -DProject/GNU/Library override_dh_auto_install: dh_auto_install -DProject/GNU/Library for py in $(shell pyversions -vr); do \ install -D -m644 Source/MediaInfoDLL/MediaInfoDLL.py debian/tmp/usr/lib/python$$py/dist-packages/MediaInfoDLL.py; \ done for py3 in $(shell py3versions -vr); do \ install -D -m644 Source/MediaInfoDLL/MediaInfoDLL3.py debian/tmp/usr/lib/python$$py3/dist-packages/MediaInfoDLL3.py; \ done mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/ sed -e 's|Version: |Version: $(version)|g' Project/GNU/Library/libmediainfo.pc > debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/libmediainfo.pc override_dh_auto_clean: dh_auto_clean -DProject/GNU/Library rm -rf Doc/ (cd Source/Doc && find -maxdepth 1 -name '*.html' -print0) | xargs -0 rm -f override_dh_installchangelogs: dh_installchangelogs Changes.txt fromdos debian/*/usr/share/doc/*/changelog override_dh_installexamples: dh_installexamples if dh_listpackages | grep -q libmediainfo-doc; then \ chmod 0644 debian/libmediainfo-doc/usr/share/doc/libmediainfo-doc/examples/*; \ fi override_dh_makeshlibs: dh_makeshlibs -- -c4 %: dh $@ --with=autoreconf,python2,python3 --parallel MediaInfoLib/ReadMe.txt0000664000000000000000000000437012652076434013753 0ustar rootrootMediaInfo.lib : static library MediaInfo.Dll : dynamic library HowToUse.exe : static-linked example HowToUse_Dll : dynamic-linked example For DLL, there are two versions of functions : - MediaInfoLib_XXX : Unicode version (international, UTF16, 2-byte characters), this is the main version, there is not only English language in the world ;-). So, now, Chinese / French / German languages can be showed at the same time. - MediaInfoLibA_XXX : Deprecated, Ansi version (localized, UTF8, 1-byte characters), as the old DLL : you should link your old code to these functions. MediaInfo library (static and/or shared) can be compiled within these different tools : - Project/BCB : Borland C++ Builder 6 - Project/CMake : cmake, C++ - Project/CodeBlocks : C++ - Project/GNU : g++, C++ - Project/MSVC2005 : Visual Studio 9 (aka 2005), C++ - Project/MSVC2008 : Visual Studio 10 (aka 2008), C++ - Project/MSVC2010 : Visual Studio 11 (aka 2010), C++ - Project/MSVC2012 : Visual Studio 12 (aka 2012), C++ - Project/Solaris : g++, C++ Examples for using the MediaInfo library are given under those folders : - Project/Delphi : Borland Delphi 7 - Project/Java : Java - Project/MSCS2008 : Visual Studio 10 (aka 2008), C# - Project/MSCS2010 : Visual Studio 11 (aka 2010), C# - Project/MSJS : Visual Studio 7.1 (aka 2003), J# - Project/MSVB : Visual Studio 7.1 (aka 2003), Basic (and no more VB6 code) - Project/MSVB2010 : Visual Studio 11 (aka 2010), Basic - Project/NetBeans : Java binding - Project/PureBasic : Basic MediaInfo library needs only 2 extra libraries to compile properly : - zenlib.lib - zlib.lib You can enable or disable format support with Compilation macro defines : MEDIAINFO_XXX_NO or MEDIAINFO_XXX_YES (if both are defined, NO is choosen) XXX may be : - VIDEO (all videos) - AUDIO (all audios) - RIFF : Microsoft Avi, Wav... - OGG : Ogg, Ogm... - MPEG : Mpg, Mpeg, Vob... - MPEG4 : Mp4, M4a, M4v... - MPEGA : mpa, mp2, mp3... - MPEGV : mpv, m2v... - WM : Wma, Wmv... - QT : Qt, Mov... - RM : Rm, Rmvb... - DVDV : Ifo of DVD - AAC : Aac - DTS : Dts - AC3 : Ac3 - MK : Matroska - APE : Monkey Audio, Ape, Mac... - FLAC : Flac - SNDFILE : SndFile related - etc... MediaInfoLib/Source/0000775000000000000000000000000012652076434013311 5ustar rootrootMediaInfoLib/Source/MediaInfo/0000775000000000000000000000000012652076434015144 5ustar rootrootMediaInfoLib/Source/MediaInfo/HashWrapper.h0000664000000000000000000000406612652076434017547 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef HashWrapperH #define HashWrapperH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" #if MEDIAINFO_MD5 || MEDIAINFO_SHA1 || MEDIAINFO_SHA2 #define MEDIAINFO_HASH 1 #else //MEDIAINFO_MD5 || MEDIAINFO_SHA1 || MEDIAINFO_SHA2 #define MEDIAINFO_HASH 0 #endif //MEDIAINFO_MD5 || MEDIAINFO_SHA1 || MEDIAINFO_SHA2 //--------------------------------------------------------------------------- #if MEDIAINFO_HASH //--------------------------------------------------------------------------- #include #include #include "ZenLib/Conf.h" using namespace std; using namespace ZenLib; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- class HashWrapper { public: enum HashFunction { MD5, SHA1, SHA224, SHA256, SHA384, SHA512, HashFunction_Max, }; typedef bitset HashFunctions; HashWrapper (const HashFunctions &Functions); ~HashWrapper (); void Update (const int8u* Buffer, const size_t Buffer_Size); string Generate (const HashFunction Function); static string Name (const HashFunction Function); private: void* m; }; } //NameSpace #endif //MEDIAINFO_HASH #endif //HashWrapperH MediaInfoLib/Source/MediaInfo/HashWrapper.cpp0000664000000000000000000002173312652076434020102 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/HashWrapper.h" //For getting MEDIAINFO_HASH, not in setup //--------------------------------------------------------------------------- #if MEDIAINFO_HASH //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" using namespace ZenLib; #if MEDIAINFO_MD5 extern "C" { #include } #endif //MEDIAINFO_MD5 #if MEDIAINFO_SHA1 extern "C" { #include } #endif //MEDIAINFO_SHA1 #if MEDIAINFO_SHA2 extern "C" { #include } #endif //MEDIAINFO_SHA2 //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // info //*************************************************************************** const char* HashWrapper_Hex = "0123456789abcdef"; //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- HashWrapper::HashWrapper (const HashFunctions &Functions) { m = new void*[HashFunction_Max]; #if MEDIAINFO_MD5 if (Functions[MD5]) { ((void**)m)[MD5]=new struct MD5Context; MD5Init((struct MD5Context*)((void**)m)[MD5]); } else ((void**)m)[MD5]=NULL; #endif //MEDIAINFO_MD5 #if MEDIAINFO_SHA1 if (Functions[SHA1]) { ((void**)m)[SHA1]=new sha1_ctx; sha1_begin((sha1_ctx*)((void**)m)[SHA1]); } else ((void**)m)[SHA1]=NULL; #endif //MEDIAINFO_SHA1 #if MEDIAINFO_SHA2 if (Functions[SHA224]) { ((void**)m)[SHA224]=new sha224_ctx; sha224_begin((sha224_ctx*)((void**)m)[SHA224]); } else ((void**)m)[SHA224]=NULL; if (Functions[SHA256]) { ((void**)m)[SHA256]=new sha256_ctx; sha256_begin((sha256_ctx*)((void**)m)[SHA256]); } else ((void**)m)[SHA256]=NULL; if (Functions[SHA384]) { ((void**)m)[SHA384]=new sha384_ctx; sha384_begin((sha384_ctx*)((void**)m)[SHA384]); } else ((void**)m)[SHA384]=NULL; if (Functions[SHA512]) { ((void**)m)[SHA512]=new sha512_ctx; sha512_begin((sha512_ctx*)((void**)m)[SHA512]); } else ((void**)m)[SHA512]=NULL; #endif //MEDIAINFO_SHA2 } HashWrapper::~HashWrapper () { #if MEDIAINFO_MD5 delete (struct MD5Context*)((void**)m)[MD5]; #endif //MEDIAINFO_MD5 #if MEDIAINFO_SHA1 delete (sha1_ctx*)((void**)m)[SHA1]; #endif //MEDIAINFO_SHA1 #if MEDIAINFO_SHA2 delete (sha224_ctx*)((void**)m)[SHA224]; delete (sha256_ctx*)((void**)m)[SHA256]; delete (sha384_ctx*)((void**)m)[SHA384]; delete (sha512_ctx*)((void**)m)[SHA512]; #endif //MEDIAINFO_SHA2 delete[] m; } void HashWrapper::Update (const int8u* Buffer, const size_t Buffer_Size) { #if MEDIAINFO_MD5 if (((void**)m)[MD5]) MD5Update((struct MD5Context*)((void**)m)[MD5], Buffer, (unsigned int)Buffer_Size); #endif //MEDIAINFO_MD5 #if MEDIAINFO_SHA1 if (((void**)m)[SHA1]) sha1_hash(Buffer, (unsigned long)Buffer_Size, (sha1_ctx*)((void**)m)[SHA1]); #endif //MEDIAINFO_SHA1 #if MEDIAINFO_SHA2 if (((void**)m)[SHA224]) sha224_hash(Buffer, (unsigned long)Buffer_Size, (sha224_ctx*)((void**)m)[SHA224]); if (((void**)m)[SHA256]) sha256_hash(Buffer, (unsigned long)Buffer_Size, (sha256_ctx*)((void**)m)[SHA256]); if (((void**)m)[SHA384]) sha384_hash(Buffer, (unsigned long)Buffer_Size, (sha384_ctx*)((void**)m)[SHA384]); if (((void**)m)[SHA512]) sha512_hash(Buffer, (unsigned long)Buffer_Size, (sha512_ctx*)((void**)m)[SHA512]); #endif //MEDIAINFO_SHA2 } string HashWrapper::Generate (const HashFunction Function) { #if MEDIAINFO_MD5 if (Function==MD5 && ((void**)m)[MD5]) { unsigned char Digest[16]; MD5Final(Digest, (struct MD5Context*)((void**)m)[MD5]); Ztring Temp; Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+ 0)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+ 2)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+ 4)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+ 6)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+ 8)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+10)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+12)); Temp+=Ztring().From_CC2(BigEndian2int16u(Digest+14)); Temp.MakeLowerCase(); return Temp.To_UTF8(); } #endif //MEDIAINFO_MD5 #if MEDIAINFO_SHA1 if (Function==SHA1 && ((void**)m)[SHA1]) { unsigned char Digest[20]; sha1_end(Digest, (sha1_ctx*)((void**)m)[SHA1]); string DigestS; DigestS.reserve(40); for (size_t i=0; i<20; ++i) { DigestS.append(1, HashWrapper_Hex[Digest[i] >> 4]); DigestS.append(1, HashWrapper_Hex[Digest[i] & 0xF]); } return DigestS; } #endif //MEDIAINFO_SHA1 #if MEDIAINFO_SHA2 if (Function==SHA224 && ((void**)m)[SHA224]) { unsigned char Digest[28]; sha224_end(Digest, (sha224_ctx*)((void**)m)[SHA224]); string DigestS; DigestS.reserve(28*2); for (size_t i=0; i<28; ++i) { DigestS.append(1, HashWrapper_Hex[Digest[i] >> 4]); DigestS.append(1, HashWrapper_Hex[Digest[i] & 0xF]); } return DigestS; } if (Function==SHA256 && ((void**)m)[SHA256]) { unsigned char Digest[32]; sha256_end(Digest, (sha256_ctx*)((void**)m)[SHA256]); string DigestS; DigestS.reserve(32*2); for (size_t i=0; i<32; ++i) { DigestS.append(1, HashWrapper_Hex[Digest[i] >> 4]); DigestS.append(1, HashWrapper_Hex[Digest[i] & 0xF]); } return DigestS; } if (Function==SHA384 && ((void**)m)[SHA384]) { unsigned char Digest[48]; sha384_end(Digest, (sha384_ctx*)((void**)m)[SHA384]); string DigestS; DigestS.reserve(48*2); for (size_t i=0; i<48; ++i) { DigestS.append(1, HashWrapper_Hex[Digest[i] >> 4]); DigestS.append(1, HashWrapper_Hex[Digest[i] & 0xF]); } return DigestS; } if (Function==SHA512 && ((void**)m)[SHA512]) { unsigned char Digest[64]; sha512_end(Digest, (sha512_ctx*)((void**)m)[SHA512]); string DigestS; DigestS.reserve(64*2); for (size_t i=0; i<64; ++i) { DigestS.append(1, HashWrapper_Hex[Digest[i] >> 4]); DigestS.append(1, HashWrapper_Hex[Digest[i] & 0xF]); } return DigestS; } #endif //MEDIAINFO_SHA2 return string(); } string HashWrapper::Name (const HashFunction Function) { #if MEDIAINFO_MD5 if (Function==MD5) return "MD5"; #endif //MEDIAINFO_MD5 #if MEDIAINFO_SHA1 if (Function==SHA1) return "SHA-1"; #endif //MEDIAINFO_SHA1 #if MEDIAINFO_SHA2 if (Function==SHA224) return "SHA-224"; if (Function==SHA256) return "SHA-256"; if (Function==SHA384) return "SHA-384"; if (Function==SHA512) return "SHA-512"; #endif //MEDIAINFO_SHA2 return string(); } } //NameSpace #endif //MEDIAINFO_HASH MediaInfoLib/Source/MediaInfo/MediaInfoList.h0000664000000000000000000003444212652076434020013 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 { class MediaInfoList_Internal; //*************************************************************************** /// @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 /// @return 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) /// @retval 0 failed /// @retval 1 succeed 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 /// @retval 0 failed /// @retval 1 succeed 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 /// @retval 0 failed /// @retval 1 succeed 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 succeed 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() /// @return Text with information about the file 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...) /// @return The count of fields for this stream kind / stream number if stream number is provided, else the count of streams for this stream kind 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 : MediaInfoList_Internal* Internal; //Constructor MediaInfoList (const MediaInfoList&); // Prevent copy-construction MediaInfoList& operator=(const MediaInfoList&); // Prevent assignment }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/0000775000000000000000000000000012652076434016166 5ustar rootrootMediaInfoLib/Source/MediaInfo/Image/File_Bmp.cpp0000664000000000000000000002562212652076434020356 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 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!=(int32u)-1 && 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 : BitmapCoreHeader(1); break; case 40 : BitmapInfoHeader(1); break; case 52 : BitmapInfoHeader(2); break; case 56 : BitmapInfoHeader(3); break; case 64 : BitmapCoreHeader(2); break; case 108 : BitmapInfoHeader(4); break; case 124 : BitmapInfoHeader(5); break; default : if (DIB_Size>124) { BitmapInfoHeader((int8u)-1); //Future versions of BitmapInfoHeader (OS/2 is abandonned) Skip_XX(14+124-Element_Offset, "Unknown"); } } Element_End0(); if (Element_Offset1) //V2 additional fields for information only { Skip_L4( "Compression"); Skip_L4( "ImageDataSize"); Skip_L4( "XResolution"); Skip_L4( "YResolution"); Skip_L4( "ColorsUsed"); Skip_L4( "ColorsImportant"); Skip_L2( "Units"); Skip_L2( "Reserved"); Skip_L2( "Recording"); Skip_L2( "Rendering"); Skip_L4( "Size1"); Skip_L4( "Size2"); Skip_L4( "ColorEncoding"); Skip_L4( "Identifier"); } } void File_Bmp::BitmapInfoHeader(int8u Version) { #if MEDIAINFO_TRACE switch (Version) { case 1 : Element_Info1("BITMAPINFOHEADER"); break; case 2 : Element_Info1("BITMAPV2INFOHEADER"); break; case 3 : Element_Info1("BITMAPV3INFOHEADER"); break; case 4 : Element_Info1("BITMAPV4HEADER"); break; case 5 : Element_Info1("BITMAPV5HEADER"); break; default: Element_Info1("BITMAPV?HEADER"); } #endif //MEDIAINFO_TRACE //Parsing 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"); FILLING_BEGIN(); if (BitsPerPixel<8) BitsPerPixel=8; //It is a palette 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)); Fill(Stream_Image, 0, Image_ColorSpace, "RGB"); FILLING_END(); if (Version>1) { Skip_L4( "Red Channel bit mask"); Skip_L4( "Green Channel bit mask"); Skip_L4( "Blue Channel bit mask"); if (Version>2) { Skip_L4( "Alpha Channel bit mask"); if (Version>3) { 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"); if (Version>4) { Skip_L4( "Intent"); Skip_L4( "ProfileData"); Skip_L4( "ProfileSize"); Skip_L4( "Reserved"); } } } } } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Tiff.cpp0000664000000000000000000005170512652076434020531 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 ""; } } //--------------------------------------------------------------------------- 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+8+4second); //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 GoToFromEnd(0); } } } //--------------------------------------------------------------------------- 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()) { if (Info->second.size()>1) { bool IsOk=true; for (size_t Pos=1; Possecond.size(); ++Pos) if (Info->second[Pos]!=Info->second[0]) IsOk=false; if (IsOk) Info->second.resize(1); //They are all same, we display 1 piece of information } 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)==0) { if (Element_Offset+4=10) { //Too many data, we don't currently need it and we skip it Skip_XX(Element_Size-(Element_Offset+4), Name); Info.clear(); return; } switch (IfdItem.Type) { case 1: /* 8-bit unsigned integer. */ for (int16u Pos=0; PosElement_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; PosElement_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; PosElement_Size) { Trusted_IsNot(); break; } if (LittleEndian) Ret32=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); else Ret32=BigEndian2int32u(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 MediaInfoLib/Source/MediaInfo/Image/File_Pcx.h0000664000000000000000000000241612652076434020033 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PCX files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_PcxH #define MediaInfo_File_PcxH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Pcx //*************************************************************************** class File_Pcx : public File__Analyze { protected : //Buffer - File header bool FileHeader_Begin(); //Elements void Read_Buffer_Continue(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Png.cpp0000664000000000000000000002420212652076434020355 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PNG files // // 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) { TestContinuousFileNames(); Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image); if (File_Size!=(int64u)-1) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), File_Size); if (StreamKind_Last==Stream_Video) Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Config->File_Names.size()); } else Stream_Prepare(StreamKind_Last); } //*************************************************************************** // 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(); if (!Status[IsFilled]) { 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: ; } Fill(); } if (Config->ParseSpeed<1.0) Finish("PNG"); //No need of more FILLING_END(); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Tga.cpp0000664000000000000000000002561612652076434020356 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p) } //*************************************************************************** // 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() { //Synchro if (18>Buffer_Size) return false; if (Buffer[2]==0x00 || Buffer[16]>32) //bit depth { Reject(); return false; } if (Buffer_Size 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 POC =0xFF5F; //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 Ci; int8u Hi; int8u Vi; }; //--------------------------------------------------------------------------- string Jpeg2000_Rsiz(int16u Rsiz) { switch (Rsiz) { case 0x0000: return "No restrictions"; case 0x0001: return "Profile-0"; case 0x0002: return "Profile-1"; case 0x0003: return "D-Cinema 2k"; case 0x0004: return "D-Cinema 4k"; case 0x0005: return "D-Cinema 2k Scalable"; case 0x0006: return "D-Cinema 4k Scalable"; case 0x0007: return "Long-term storage"; case 0x0101: return "BCS@L1"; //Broadcast Contribution Single Tile case 0x0102: return "BCS@L2"; //Broadcast Contribution Single Tile case 0x0103: return "BCS@L3"; //Broadcast Contribution Single Tile case 0x0104: return "BCS@L4"; //Broadcast Contribution Single Tile case 0x0105: return "BCS@L5"; //Broadcast Contribution Single Tile case 0x0205: return "BCM@L5"; //Broadcast Contribution Multi-tile case 0x0306: return "BCMR@L6"; //Broadcast Contribution Multi-tile Reversible case 0x0307: return "BCMR@L7"; //Broadcast Contribution Multi-tile Reversible default: return Ztring::ToZtring(Rsiz, 16).To_UTF8(); } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Jpeg::File_Jpeg() { //Config #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Jpeg; StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_TRACE Trace_Layers_Update(8); //Stream #endif //MEDIAINFO_TRACE MustSynchronize=true; IsRawStream=true; //In StreamKind=Stream_Image; Interlaced=false; #if MEDIAINFO_DEMUX FrameRate=0; #endif //MEDIAINFO_DEMUX } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Jpeg::Streams_Accept() { if (!IsSub) { TestContinuousFileNames(); Stream_Prepare(Config->File_Names.size()>1?Stream_Video:StreamKind); if (File_Size!=(int64u)-1) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_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; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p) } //--------------------------------------------------------------------------- void File_Jpeg::Streams_Finish() { if (StreamKind_Last==Stream_Video && Config->ParseSpeed>=1.0) Fill (Stream_Video, 0, Video_StreamSize, Buffer_TotalBytes, 10, true); } //*************************************************************************** // 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; } //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() { APP0_JFIF_Parsed=false; SOS_SOD_Parsed=false; APPE_Adobe0_transform=(int8u)-1; } //*************************************************************************** // Buffer - Demux //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX bool File_Jpeg::Demux_UnpacketizeContainer_Test() { if (!IsSub) { if (!Status[IsAccepted]) Accept(); if (Config->File_Names.size()>1) return Demux_UnpacketizeContainer_Test_OneFramePerFile(); } if (Interlaced && Buffer_Offset==0) { bool StartIsFound=false; while (Demux_Offset+2<=Buffer_Size) { int16u code=BigEndian2int16u(Buffer+Demux_Offset); Demux_Offset+=2; switch (code) { case Elements::SOD : //JPEG-2000 start StartIsFound=true; 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::SOI : case Elements::EOI : break; default : if (Demux_Offset+2>Buffer_Size) break; { int16u size=BigEndian2int16u(Buffer+Demux_Offset); if (Demux_Offset+2+size>Buffer_Size) break; Demux_Offset+=size; if (code==Elements::SOS) //JPEG start StartIsFound=true; } } if (StartIsFound) break; } while (Demux_Offset+2<=Buffer_Size) { while (Demux_OffsetParseSpeed>=1.0 && IsSub && Status[IsFilled]) { #if MEDIAINFO_DEMUX if (Buffer_TotalBytesBuffer_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(POC , "Progression order change"); //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 SamplingFactors; vector BitDepths; int8u SamplingFactors_Max=0; int32u Xsiz, Ysiz; int16u Rsiz, Count; Get_B2 (Rsiz, "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; PosSamplingFactors_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"); Fill("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"); Fill(StreamKind_Last, 0, "Format_Profile", Jpeg2000_Rsiz(Rsiz)); 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; PosParseSpeed<1.0) Finish("JPEG 2000"); //No need of more } } //--------------------------------------------------------------------------- void File_Jpeg::SOF_() { //Parsing vector 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; PosCount) Element_Info1(Ztring().append(1, (Char)SamplingFactor.Ci)); else Element_Info1(SamplingFactor.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"); Fill("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, Fill_Parameter(StreamKind_Last, Generic_BitDepth), Resolution); Fill(StreamKind_Last, 0, "Height", Height*(Interlaced?2:1)); Fill(StreamKind_Last, 0, "Width", Width); //ColorSpace from http://docs.oracle.com/javase/1.4.2/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html switch (APPE_Adobe0_transform) { case 0x01 : if (Count==3) Fill(StreamKind_Last, 0, "ColorSpace", "YUV"); break; case 0x02 : if (Count==4) Fill(StreamKind_Last, 0, "ColorSpace", "YCCB"); break; default : { int8u Ci[256]; memset(Ci, 0, 256); for (int8u Pos=0; PosParseSpeed<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-Element_Offset, "Unknown"); } } //--------------------------------------------------------------------------- // From OpenDML AVI File Format Extensions void File_Jpeg::APP0_AVI1() { Element_Info1("AVI1"); //Parsing bool UnknownInterlacement_IsDetected=false; int8u FieldOrder=(int8u)-1; Get_B1 (FieldOrder, "Polarity"); if (Element_Size>=14) { int32u FieldSize, FieldSizeLessPadding; Skip_B1( "Reserved"); Get_B4 (FieldSize, "FieldSize"); Get_B4 (FieldSizeLessPadding, "FieldSizeLessPadding"); //Coherency if (FieldOrder==0 && IsSub && FieldSize && FieldSize!=Buffer_Size) { if (FieldSizeLessPadding>1 && FieldSizeLessPadding<=Buffer_Size && Buffer[FieldSizeLessPadding-2]==0xFF && Buffer[FieldSizeLessPadding-1]==0xD9 //EOI && FieldSize+1 < Buffer_Size && Buffer[FieldSize] ==0xFF && Buffer[FieldSize+1] ==0xD8) //SOI UnknownInterlacement_IsDetected=true; } } Skip_XX(Element_Size-Element_Offset, "Unknown"); FILLING_BEGIN(); if (Frame_Count==0 && Field_Count==0) { Accept(); if (UnknownInterlacement_IsDetected) { Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); Interlaced=true; } else { 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"); Interlaced=true; break; case 0x02 : Fill(Stream_Video, 0, Video_Interlacement, "BFF"); Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); Fill(Stream_Video, 0, Video_ScanOrder, "BFF"); Interlaced=true; break; default : ; } } } FILLING_END(); } //--------------------------------------------------------------------------- void File_Jpeg::APP0_JFIF() { Element_Info1("JFIF"); //Parsing Skip_B1( "Zero"); 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"); APP0_JFIF_Parsed=true; } //--------------------------------------------------------------------------- void File_Jpeg::APP0_JFFF() { Element_Info1("JFFF"); Skip_B1( "Zero"); 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"); } //--------------------------------------------------------------------------- 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() { Element_Info1("Exif"); //Parsing int32u Alignment; Get_C4(Alignment, "Alignment"); if (Alignment==0x49492A00) Skip_B4( "First_IFD"); if (Alignment==0x4D4D2A00) Skip_L4( "First_IFD"); } //--------------------------------------------------------------------------- void File_Jpeg::APPE() { //Parsing int64u Name; Get_C6(Name, "Name"); switch (Name) { case 0x41646F626500LL : APPE_Adobe0(); break; //"AVI1" default : Skip_XX(Element_Size-Element_Offset, "Unknown"); } } //--------------------------------------------------------------------------- void File_Jpeg::APPE_Adobe0() { Element_Info1("Adobe"); //Parsing int8u Version; Get_B1(Version, "Version"); if (Version==100) { int8u transform; Skip_B2( "flags0"); Skip_B2( "flags1"); Get_B1 (transform, "transform"); FILLING_BEGIN(); APPE_Adobe0_transform=transform; FILLING_END(); } else Skip_XX(Element_Size-Element_Offset, "unknown"); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Dds.cpp0000664000000000000000000001554112652076434020351 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DDS (DirectDraw Surface) files // // From http://msdn.microsoft.com/en-us/library/windows/desktop/bb943982%28v=vs.85%29.aspx // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DDS_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Image/File_Dds.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Dds::File_Dds() { //Config #if MEDIAINFO_TRACE Trace_Layers_Update(8); //Stream #endif //MEDIAINFO_TRACE IsRawStream=true; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Dds::Streams_Accept() { Fill(Stream_General, 0, General_Format, "DDS"); if (!IsSub) { 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()); if (pfFlags&0x4) //DDPF_FOURCC CodecID_Fill(Ztring().From_CC4(FourCC), StreamKind_Last, StreamPos_Last, InfoCodecID_Format_Riff, Stream_Video); if (Flags&0x2) //DDSD_HEIGHT Fill(StreamKind_Last, 0, "Height", Height); if (Flags&0x4) //DDSD_WIDTH Fill(StreamKind_Last, 0, "Width", Width); if (Flags&0x800000) //DDSD_DEPTH Fill(StreamKind_Last, 0, "BitDepth", Depth); } else Stream_Prepare(StreamKind_Last); } //*************************************************************************** // Header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Dds::FileHeader_Begin() { // Minimum buffer size if (Buffer_Size<8) return false; // Must wait for more data // Testing if (Buffer[0]!=0x44 // "DDS " || Buffer[1]!=0x44 || Buffer[2]!=0x53 || Buffer[3]!=0x20 || LittleEndian2int32u(Buffer+4)<124) { Reject(); return false; } //All should be OK... return true; } //--------------------------------------------------------------------------- void File_Dds::FileHeader_Parse() { //Parsing int32u Size; Skip_C4( "Magic"); Get_L4 (Size, "Size"); Get_L4 (Flags, "Flags"); Get_L4 (Height, "Height"); Get_L4 (Width, "Width"); Skip_L4( "PitchOrLinearSize"); Skip_L4( "Depth"); Skip_L4( "MipMapCount"); Skip_XX(4*11, "Reserved1"); Element_Begin1("Pixel format"); int32u pf_Size; Get_L4 (pf_Size, "Size"); if (pf_Size>=32) { Get_L4 (pfFlags, "Flags"); Get_C4 (FourCC, "FourCC"); Skip_L4( "RGBBitCount"); Skip_L4( "RBitMask"); Skip_L4( "GBitMask"); Skip_L4( "BBitMask"); Skip_L4( "ABitMask"); if (pf_Size>32) Skip_XX(Size-32, "(Data)"); } else if (pf_Size>4) Skip_XX(pf_Size-4, ""); Element_End0(); Skip_L4( "Caps"); Skip_L4( "Caps2"); Skip_L4( "Caps3"); Skip_L4( "Caps4"); Skip_L4( "Reserved2"); if (Size>124) Skip_XX(Size-124, "(Data)"); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Dds::Read_Buffer_Unsynched() { Read_Buffer_Unsynched_OneFramePerFile(); } //--------------------------------------------------------------------------- void File_Dds::Read_Buffer_Continue() { Skip_XX(File_Size-(File_Offset+Buffer_Offset), "Data"); FILLING_BEGIN(); Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (!Status[IsAccepted]) { Accept(); Fill(); if (Config->ParseSpeed<1.0) Finish(); } FILLING_END(); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Dpx.h0000664000000000000000000000477212652076434020043 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DPX files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DpxH #define MediaInfo_File_DpxH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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_Cineon(); void GenericSectionHeader_Dpx(); void GenericSectionHeader_Cineon_ImageElement(); void GenericSectionHeader_Dpx_ImageElement(); void IndustrySpecificHeader_Cineon(); void IndustrySpecificHeader_Dpx(); void UserDefinedHeader_Cineon(); void UserDefinedHeader_Dpx(); void Padding(); void ImageData(); //Temp std::vector Sizes; size_t Sizes_Pos; int8u Version; bool IsDpx; bool LittleEndian; //Helpers void Get_X2 (int16u &Info, const char* Name); void Get_X4 (int32u &Info, const char* Name); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Gif.h0000664000000000000000000000233312652076434020004 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Image/File_Rle.h0000664000000000000000000000236012652076434020021 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Image/File_Dpx.cpp0000664000000000000000000012177012652076434020374 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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)", "", //No info "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_Descriptors_ColorSpace(int8u i) { switch (i) { case 1: return "R"; case 2: return "G"; case 3: return "B"; case 4: return "A"; case 6: return "Y"; case 7: return "UV"; case 8: return "Z"; case 50: return "RGB"; case 51: case 52: return "RGBA"; case 100: case 102: case 103: return "YUV"; case 101: return "YUVA"; default : return ""; } } //--------------------------------------------------------------------------- const char* DPX_Descriptors_ChromaSubsampling(int8u i) { switch (i) { case 100: case 101: return "4:2:2"; default : return ""; } } //--------------------------------------------------------------------------- const char* Mpegv_transfer_characteristics(int8u transfer_characteristics); const char* DPX_TransferCharacteristic(int8u TransferCharacteristic) { switch (TransferCharacteristic) { case 1 : return "Printing density"; case 2 : return Mpegv_transfer_characteristics(8); //Linear case 3 : return "Logarithmic"; //Value not specified in specs case 5 : //SMPTE 274M, for HDTV, mapped to BT.709 case 6 : return Mpegv_transfer_characteristics(1); //BT.709 case 7 : return Mpegv_transfer_characteristics(5); //BT.470 System B, BT.470 System G (typo in specs?) case 8 : return Mpegv_transfer_characteristics(4); //BT.470 System M (typo in specs?) case 9 : //BT.601 (NTSC) case 10 : return Mpegv_transfer_characteristics(6); //BT.601 (PAL) case 11 : return "Z (depth) - linear"; case 12 : return "Z (depth) - homogeneous"; default : return ""; } }; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- const char* Mpegv_colour_primaries(int8u colour_primaries); const char* DPX_ColorimetricSpecification(int8u ColorimetricSpecification) { switch (ColorimetricSpecification) { case 1 : return "Printing density"; case 5 : //SMPTE 274M, for HDTV, mapped to BT.709 case 6 : return Mpegv_colour_primaries(1); //BT.709 case 7 : return Mpegv_colour_primaries(5); //BT.470 System B, BT.470 System G (typo in specs?), mapped to BT.601 PAL case 8 : return Mpegv_colour_primaries(6); //BT.470 System M (typo in specs?), mapped to BT.601 NTSC case 9 : return Mpegv_colour_primaries(6); //BT.601 NTSC case 10 : return Mpegv_colour_primaries(5); //BT.601 PAL default : return ""; } } //--------------------------------------------------------------------------- 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, }; //*************************************************************************** // Helpers //*************************************************************************** // string DPX_DateTime2Iso(const string &FromDpx) { if (FromDpx.size()<20 || FromDpx[ 0]<'0' || FromDpx[ 0]>'9' || FromDpx[ 1]<'0' || FromDpx[ 1]>'9' || FromDpx[ 2]<'0' || FromDpx[ 2]>'9' || FromDpx[ 3]<'0' || FromDpx[ 3]>'9' || FromDpx[ 4] != ':' || FromDpx[ 5]<'0' || FromDpx[ 5]>'9' || FromDpx[ 6]<'0' || FromDpx[ 6]>'9' || FromDpx[ 7] != ':' || FromDpx[ 8]<'0' || FromDpx[ 8]>'9' || FromDpx[ 9]<'0' || FromDpx[ 9]>'9' || FromDpx[10] != ':' || FromDpx[11]<'0' || FromDpx[11]>'9' || FromDpx[12]<'0' || FromDpx[12]>'9' || FromDpx[13] != ':' || FromDpx[14]<'0' || FromDpx[14]>'9' || FromDpx[15]<'0' || FromDpx[15]>'9' || FromDpx[16] != ':' || FromDpx[17]<'0' || FromDpx[17]>'9' || FromDpx[18]<'0' || FromDpx[18]>'9' ) return FromDpx; //Invalid, returning the value in the file // Date/Time string ToReturn(FromDpx.substr(0, 19)); ToReturn[ 4]='-'; ToReturn[ 7]='-'; ToReturn[10]='T'; // Note: should be 'T' (ISO 8601), TODO: change to 'T' during next API change // Time zone if (FromDpx.size()>20) { size_t Offset; if (FromDpx[19]==':') // Note: Cineon and DPX v1 header date/time format is with ":LTZ", DPX v2 date/time format is "LTZ", but both are atually seen in any version. Always testing both. Offset=20; else Offset=19; size_t Max=FromDpx.find('\0'); if (Max==(size_t)-1) Max=FromDpx.size(); ToReturn+=FromDpx.substr(Offset, Max-Offset); if (ToReturn.size()>22) ToReturn.insert(ToReturn.begin(), ':'); //Hours/Minutes offset sepearator added else if (ToReturn.size()==22 && (ToReturn[19]=='+' || ToReturn[19]=='-')) ToReturn+=":00"; // Minutes offset, default } return ToReturn; } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Dpx::File_Dpx() :File__Analyze() { //Configuration ParserName=__T("DPX"); } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Dpx::Streams_Accept() { if (!IsSub) { TestContinuousFileNames(); Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image); if (File_Size!=(int64u)-1) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_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; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p) } //*************************************************************************** // 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 : // (Cineon Big) case 0xD75F2A80 : // (Cineon Little) case 0x53445058 : //"SPDX" (Dpx Big) case 0x58504453 : //"XDPS" (Dpx 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 : // (Cineon Big) case 0xD75F2A80 : // (Cineon Little) IsDpx=false; break; case 0x58504453 : //"XDPS" (Dpx Little) case 0x53445058 : //"SPDX" (Dpx Big) IsDpx=true; break; default : ; } switch (Magic) { case 0xD75F2A80 : // (Cineon Little) case 0x58504453 : //"XDPS" (Dpx Little) LittleEndian=true; break; case 0x802A5FD7 : // (Cineon Big) case 0x53445058 : //"SPDX" (Dpx 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 (!IsDpx) // Is Cineon { switch (Element_Code) { case Pos_GenericSection : GenericSectionHeader_Cineon(); break; case Pos_IndustrySpecific : IndustrySpecificHeader_Cineon(); break; case Pos_UserDefined : UserDefinedHeader_Cineon(); break; case Pos_Padding : Padding(); break; case Pos_ImageData : ImageData(); break; default : ; } } else { switch (Element_Code) { case Pos_GenericSection : GenericSectionHeader_Dpx(); break; case Pos_IndustrySpecific : IndustrySpecificHeader_Dpx(); break; case Pos_UserDefined : UserDefinedHeader_Dpx(); 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.clear(); Sizes_Pos=0; if (!Status[IsFilled]) Fill(); if (File_Offset+Buffer_Offset+Element_SizeFile_Current_Size) GoTo(Config->File_Current_Size); } } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Cineon() { Element_Name("Generic section header"); //Parsing Element_Begin1("File information"); string CreationDate, CreationTime; string Version; 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"); Get_String(8, Version, "Version number of header format"); Skip_UTF8 (100, "FileName"); Get_String (12, CreationDate, "Creation Date"); Get_String (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=Config->File_Current_Size) Size_Total=(int32u)(Config->File_Current_Size-(File_Offset+Buffer_Offset)); //The total size is bigger than the real size 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, DPX_DateTime2Iso(CreationDate+':'+CreationTime)); Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", DPX_DateTime2Iso(CreationDate+':'+CreationTime)); Fill(StreamKind_Last, StreamPos_Last, "Format", "Cineom"); if (Version.size()>2 && Version[0]=='V' && Version[1]>='0' && Version[2]<='9') Version.insert(1, "ersion "); Fill(StreamKind_Last, StreamPos_Last, "Format_Version", Version); Fill(Stream_General, 0, General_Format_Version, Version); } FILLING_END(); } //--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Cineon_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_BF4( "Minimum data value"); Skip_BF4( "Minimum quantity represented"); Skip_BF4( "Maximum data value"); Skip_BF4( "Maximum quantity represented"); Element_End0(); FILLING_BEGIN(); if (Frame_Count==0) { Fill(StreamKind_Last, StreamPos_Last, "Width", Width); Fill(StreamKind_Last, StreamPos_Last, "Height", Height); } FILLING_END(); } //--------------------------------------------------------------------------- void File_Dpx::GenericSectionHeader_Dpx() { Element_Name("Generic section header"); //Parsing Element_Begin1("File information"); std::string Version, 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"); Get_String(8, Version, "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; ImageElementFile_Current_Size) Size_Total=(int32u)(Config->File_Current_Size-(File_Offset+Buffer_Offset)); //The total size is bigger than the real size if (Size_Generic==(int32u)-1) Size_Generic=(int32u)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, DPX_DateTime2Iso(CreationDate)); Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", DPX_DateTime2Iso(CreationDate)); 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, "Format", "DPX"); if (Version.size()>2 && Version[0]=='V' && Version[1]>='0' && Version[2]<='9') Version.insert(1, "ersion "); Fill(StreamKind_Last, StreamPos_Last, "Format_Version", Version); Fill(Stream_General, 0, General_Format_Version, Version); 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_Dpx_ImageElement() { Element_Begin1("image element"); int8u Descriptor, TransferCharacteristic, ColorimetricSpecification, BitDephs; Info_B4(DataSign, "Data sign");Param_Info1((DataSign==0?"unsigned":"signed")); Skip_B4( "Reference low data code value"); Skip_BF4( "Reference low quantity represented"); Skip_B4( "Reference high data code value"); Skip_BF4( "Reference high quantity represented"); Get_B1 (Descriptor, "Descriptor");Param_Info1(DPX_Descriptors(Descriptor)); Get_B1 (TransferCharacteristic, "Transfer characteristic");Param_Info1(DPX_TransferCharacteristic(TransferCharacteristic)); Get_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, "ColorSpace", DPX_Descriptors_ColorSpace(Descriptor)); Fill(StreamKind_Last, StreamPos_Last, "ChromaSubsampling", DPX_Descriptors_ChromaSubsampling(Descriptor)); Fill(StreamKind_Last, StreamPos_Last, "BitDepth", BitDephs); Fill(StreamKind_Last, StreamPos_Last, "colour_description_present", "Yes"); Fill(StreamKind_Last, StreamPos_Last, "colour_primaries", DPX_TransferCharacteristic(TransferCharacteristic)); Fill(StreamKind_Last, StreamPos_Last, "transfer_characteristics", DPX_ColorimetricSpecification(ColorimetricSpecification)); } FILLING_END(); } //--------------------------------------------------------------------------- void File_Dpx::IndustrySpecificHeader_Cineon() { 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_Dpx() { Element_Name("Industry specific header"); //Parsing float32 FrameRate; 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)"); Get_BF4 (FrameRate, "Frame rate of original (frames/s)"); Skip_BF4( "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_BF4( "Horizontal sampling rate (Hz)"); Skip_BF4( "Vertical sampling rate (Hz)"); Skip_BF4( "Temporal sampling rate or frame rate (Hz)"); Skip_BF4( "Time offset from sync to first pixel (ms)"); Skip_BF4( "Gamma"); Skip_BF4( "Black level code value"); Skip_BF4( "Black gain"); Skip_BF4( "Breakpoint"); Skip_BF4( "Reference white level code value"); Skip_BF4( "Integration time (s)"); Skip_XX(76, "Reserved for future use"); Element_End0(); FILLING_BEGIN(); if (FrameRate) Fill(StreamKind_Last, StreamPos_Last, "FrameRate", FrameRate); FILLING_END(); } //--------------------------------------------------------------------------- void File_Dpx::UserDefinedHeader_Cineon() { Element_Name("User defined header"); //Parsing Skip_XX(Sizes[Pos_UserDefined], "Unknown"); } //--------------------------------------------------------------------------- void File_Dpx::UserDefinedHeader_Dpx() { 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++; if (Config->ParseSpeed<1.0) Finish("DPX"); //No need of more } //*************************************************************************** // 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 MediaInfoLib/Source/MediaInfo/Image/File_Png.h0000664000000000000000000000375212652076434020031 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Image/File_Exr.cpp0000664000000000000000000002461112652076434020373 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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) { TestContinuousFileNames(); Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image); if (File_Size!=(int64u)-1) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_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; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p) } //*************************************************************************** // 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) 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) 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_End==0) ImageData(); 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=Config->File_Current_Size; } //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Image/File_Ico.h0000664000000000000000000000322112652076434020006 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 Streams; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Bpg.cpp0000664000000000000000000001225312652076434020344 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // From http://bellard.org/bpg/bpg_spec.txt // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_BPG_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Image/File_Bpg.h" #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- const char* Bpg_ColorSpace(int8u ColorSpace) { switch (ColorSpace) { case 0: case 3: case 4: return "YUV"; case 1: return "RGB"; case 2: return "YCgCo"; default: return ""; } }; //--------------------------------------------------------------------------- const char* Bpg_colour_primaries(int8u ColorSpace) { switch (ColorSpace) { case 0: return "BT.601"; case 3: return "BT.701"; case 4: return "BT.2020"; default: return ""; } }; //--------------------------------------------------------------------------- const char* Bpg_Pixel_format(int8u PixelFormat) { switch (PixelFormat) { case 0 : return "Grayscale"; case 1 : case 4 : return "4:2:0"; case 2 : case 5 : return "4:2:2"; case 3 : return "4:4:4"; default: return ""; } }; //*************************************************************************** // Static stuff //*************************************************************************** //--------------------------------------------------------------------------- bool File_Bpg::FileHeader_Begin() { //Element_Size if (Buffer_Size<4) return false; //Must wait for more data if (CC4(Buffer) != 0x425047FB) //"BPG" { Reject("BPG"); return false; } //All should be OK... return true; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Bpg::Read_Buffer_Continue() { //Parsing Ztring Version; int64u Width, Height; int8u pixelformat, BitsDepth, ColorSpace; bool Alpha1_flag, Alpha2_flag, ReservedZeros, limited_range_flag, ExtensionPresentFlag; Element_Begin1("File header"); Skip_C4( "Magic"); // File Magic BS_Begin(); Get_S1 (3, pixelformat, "pixel_format"); Param_Info1(Bpg_Pixel_format(pixelformat)); Get_SB (Alpha1_flag, "Alpha1 Present Flag"); Get_S1 (4, BitsDepth, "bit_depth_minus_8"); Get_S1(4, ColorSpace, "color_space"); Param_Info1(Bpg_ColorSpace(ColorSpace)); Param_Info1(Bpg_colour_primaries(ColorSpace)); Get_SB (ExtensionPresentFlag, "Extension Present Flag"); Get_SB (Alpha2_flag, "Alpha2 Present Flag"); Get_SB (limited_range_flag, "limited_range_flag"); Get_SB (ReservedZeros, "Reserved"); BS_End(); Get_VS(Width, "Picture Width"); Get_VS(Height, "Picture Height"); Element_End0(); FILLING_BEGIN(); Accept("BPG"); 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("BPG")); Fill(Stream_Image, 0, Image_ChromaSubsampling, Bpg_Pixel_format(pixelformat)); Fill(Stream_Image, 0, Image_ColorSpace, Bpg_ColorSpace(ColorSpace)); Fill(Stream_Image, 0, Image_colour_primaries, Bpg_colour_primaries(ColorSpace)); Fill(Stream_Image, 0, Image_BitDepth, BitsDepth + 8); Fill(Stream_Image, 0, Image_Codec, __T("BPG")); FILLING_END(); Finish("BPG"); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_ArriRaw.h0000664000000000000000000000337012652076434020650 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about ARRI RAW files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_ArriRawH #define MediaInfo_File_ArriRawH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_ArriRaw //*************************************************************************** class File_ArriRaw : public File__Analyze { public : //Constructor/Destructor File_ArriRaw(); 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 void Read_Buffer_Continue (); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Psd.h0000664000000000000000000000241612652076434020027 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PSD files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_PsdH #define MediaInfo_File_PsdH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Psd //*************************************************************************** class File_Psd : public File__Analyze { protected : //Buffer - File header bool FileHeader_Begin(); //Elements void Read_Buffer_Continue(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Pcx.cpp0000664000000000000000000001264412652076434020372 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // // From http://courses.engr.illinois.edu/ece390/books/labmanual/graphics-pcx.html // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PCX_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Image/File_Pcx.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- const char* Pcx_VersionInfo(int16u Version) { switch(Version) { case 0 : return "Paintbrush v2.5"; case 2 : return "Paintbrush v2.8 with palette information"; case 3 : return "Paintbrush v2.8 without palette information"; case 4 : return "Paintbrush/Windows"; case 5 : return "Paintbrush v3.0+"; default: return ""; } } //*************************************************************************** // Static stuff //*************************************************************************** //--------------------------------------------------------------------------- bool File_Pcx::FileHeader_Begin() { //Element_Size if (Buffer_Size<130) //Size of the header return false; //Must wait for more data if (Buffer[0]!=0x0A || Buffer[1]>0x05 || Buffer[2]!=0x01 || !(Buffer[3]==1 || Buffer[3]==4 || Buffer[3]==8 || Buffer[3]==24)) { Reject("PCX"); return false; } //All should be OK... return true; } //*************************************************************************** // File Header Information //*************************************************************************** //--------------------------------------------------------------------------- void File_Pcx::Read_Buffer_Continue() { //Parsing int16u XMin, YMin, XMax, YMax, HorDPI, VertDPI, BytesPerLine, PaletteType, HScrSize, VScrSize; int8u Manufacturer, Version, EncodingScheme, BitsPerPixel, ColorPlanes; Get_L1 (Manufacturer, "Manufacturer"); Get_L1 (Version, "Version"); // 0,2,3,4,5 Get_L1 (EncodingScheme, "EncodingScheme"); // RLE=1 Get_L1 (BitsPerPixel, "Bits Per Pixel"); // 1,4,8,24 Get_L2 (XMin, "Left margin of image"); Get_L2 (YMin, "Upper margin of image"); Get_L2 (XMax, "Right margin of image"); Get_L2 (YMax, "Lower margin of image"); Get_L2 (HorDPI, "Horizontal Resolution"); Get_L2 (VertDPI, "Vertical Resolution"); Skip_XX(48, "Palette"); Skip_L1( "Reserved"); Get_L1 (ColorPlanes, "ColorPlanes"); Get_L2 (BytesPerLine, "BytesPerLine"); Get_L2 (PaletteType, "PaletteType"); Get_L2 (HScrSize, "Horizontal Screen Size"); Get_L2 (VScrSize, "Vertical Screen Size"); Skip_XX(56, "Filler"); FILLING_BEGIN(); //Integrity tests if (XMax<=XMin || YMax<=YMin || BytesPerLine ifditems; //Key is byte offset ifditems IfdItems; typedef std::map 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 MediaInfoLib/Source/MediaInfo/Image/File_Tga.h0000664000000000000000000000346012652076434020014 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Image/File_Ico.cpp0000664000000000000000000001237212652076434020350 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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; PosFile_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 MediaInfoLib/Source/MediaInfo/Image/File_ArriRaw.cpp0000664000000000000000000001102712652076434021201 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about ARRI RAW files // // 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_ARRIRAW_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Image/File_ArriRaw.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_ArriRaw::File_ArriRaw() { //Config #if MEDIAINFO_TRACE Trace_Layers_Update(8); //Stream #endif //MEDIAINFO_TRACE IsRawStream=true; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_ArriRaw::Streams_Accept() { Fill(Stream_General, 0, General_Format, "Arri Raw"); if (!IsSub) { 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_ArriRaw::FileHeader_Begin() { // Minimum buffer size if (Buffer_Size<8) return false; // Must wait for more data // Testing if (Buffer[0]!=0x41 // "ARRI.4Vx" || Buffer[1]!=0x52 || Buffer[2]!=0x52 || Buffer[3]!=0x49 || Buffer[4]!=0x12 || Buffer[5]!=0x34 || Buffer[6]!=0x56 || Buffer[7]!=0x78) { Reject("Arri Raw"); return false; } Accept(); //All should be OK... return true; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_ArriRaw::Read_Buffer_Unsynched() { Read_Buffer_Unsynched_OneFramePerFile(); } //--------------------------------------------------------------------------- void File_ArriRaw::Read_Buffer_Continue() { //Parsing Skip_C4( "Signature"); Skip_C1( "Signature"); Skip_C3( "Signature"); Skip_XX(File_Size-8, "Data"); FILLING_BEGIN(); Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (!Status[IsFilled]) { Fill(); if (Config->ParseSpeed<1.0) Finish(); } FILLING_END(); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Exr.h0000664000000000000000000000430712652076434020040 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about EXR files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_ExrH #define MediaInfo_File_ExrH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Image/File_Jpeg.h0000664000000000000000000001300112652076434020156 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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; #if MEDIAINFO_DEMUX float64 FrameRate; #endif //MEDIAINFO_DEMUX //Constructor/Destructor File_Jpeg(); private : //Streams management void Streams_Accept(); 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(); void Read_Buffer_Continue(); #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 POC () {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(); void APPE_Adobe0(); 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 APPE_Adobe0_transform; bool APP0_JFIF_Parsed; bool SOS_SOD_Parsed; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Dds.h0000664000000000000000000000362712652076434020020 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DDS (DirectDraw Surface) files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DdsH #define MediaInfo_File_DdsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Dds //*************************************************************************** class File_Dds : public File__Analyze { public : //Constructor/Destructor File_Dds(); private : //Streams management void Streams_Accept(); //Buffer - File header bool FileHeader_Begin(); void FileHeader_Parse(); //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 void Read_Buffer_Continue (); // Temp int32u Flags; int32u Width; int32u Height; int32u Depth; int32u pfFlags; int32u FourCC; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Bpg.h0000664000000000000000000000233312652076434020007 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about BPG files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_BpgH #define MediaInfo_File_BpgH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Bpg //*************************************************************************** class File_Bpg : public File__Analyze { protected : //Buffer - File header bool FileHeader_Begin(); //Buffer - Global void Read_Buffer_Continue (); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Gif.cpp0000664000000000000000000000772412652076434020350 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 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); if (PixelAspectRatio) Fill(Stream_Image, 0, Image_PixelAspectRatio, (((float)PixelAspectRatio)+15)/64); Finish("GIF"); FILLING_END(); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Image/File_Rle.cpp0000664000000000000000000000501712652076434020356 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/MediaInfo_Internal.h0000664000000000000000000002050312652076434021004 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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_Config.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "ZenLib/Thread.h" #if defined (MEDIAINFO_DEBUG_CONFIG) || defined (MEDIAINFO_DEBUG_BUFFER) || defined (MEDIAINFO_DEBUG_OUTPUT) #include #include #endif //MEDIAINFO_DEBUG //--------------------------------------------------------------------------- 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); #if MEDIAINFO_ADVANCED2 size_t Open_Buffer_SegmentChange (); #endif //MEDIAINFO_ADVANCED2 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_DcpAm; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats friend class File_DcpCpl;//Theses classes need access to internal structure for optimization. There is recursivity with theses formats friend class File_DcpPkl;//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 friend class resource;//Theses classes need access to internal structure for optimization. There is recursivity with theses formats friend class Reader_File; //For Info member //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 > Stream; std::vector > Stream_More; Ztring Details; void Traiter(Ztring &C); //enleve les $if... public : bool SelectFromExtension (const String &Parser); //Select File_* from the parser name void TestContinuousFileNames(); #if MEDIAINFO_EVENTS void Event_Prepare (struct MediaInfo_Event_Generic* Event); #endif // MEDIAINFO_EVENTS #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; static Ztring Xml_Name_Escape(const Ztring &Name); static Ztring Xml_Content_Escape(const Ztring &Content, size_t &Modified); static Ztring &Xml_Content_Escape_Modifying(Ztring &Content, size_t &Modified); 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 Debug_Output_Value_Stream; //Key is the memory address map Debug_Output_Value_Sizes; //Key is the memory address vector Debug_Output_Pos_Stream; //Key is the pos vector Debug_Output_Pos_Sizes; //Key is the pos vector Debug_Output_Pos_Pointer; //Key is the pos #endif //MEDIAINFO_DEBUG_OUTPUT }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/MediaInfo_Events_Internal.h0000664000000000000000000001050712652076434022333 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ #ifndef MediaInfo_Events_InternalH #define MediaInfo_Events_InternalH #include "MediaInfo/MediaInfo_Events.h" #include "MediaInfo/TimeCode.h" #include using namespace MediaInfoLib; using namespace std; //--------------------------------------------------------------------------- // Generic #define EVENT_BEGIN(_EventType, _EventName, _EventVersion) \ { \ struct MediaInfo_Event_##_EventType##_##_EventName##_##_EventVersion Event;\ Event_Prepare((struct MediaInfo_Event_Generic*)&Event); \ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_##_EventType, MediaInfo_Event_##_EventType##_##_EventName, _EventVersion); \ Event.EventSize=sizeof(struct MediaInfo_Event_##_EventType##_##_EventName##_##_EventVersion); \ #define EVENT_END() \ Config->Event_Send(Status[IsAccepted]?NULL:this, (const int8u*)&Event, Event.EventSize, IsSub?File_Name_WithoutDemux:File_Name); \ } \ #define EVENT(_EventType, _EventName, _EventVersion) \ EVENT_BEGIN(_EventType, _EventName, _EventVersion) \ EVENT_END () //--------------------------------------------------------------------------- // Helpers 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); } inline void Events_TimeCode(const TimeCode &Tc, MediaInfo_time_code &Event_TimeCode, char* Event_TimeCode_HR) { if (Tc.IsValid()) { Event_TimeCode.Hours=Tc.Hours; Event_TimeCode.Minutes=Tc.Minutes; Event_TimeCode.Seconds=Tc.Seconds; Event_TimeCode.Frames=Tc.Frames; Event_TimeCode.FramesPerSecond=Tc.FramesPerSecond; Event_TimeCode.DropFrame=Tc.DropFrame; Event_TimeCode_HR[ 0]='0'+Tc.Hours/10; Event_TimeCode_HR[ 1]='0'+Tc.Hours%10; Event_TimeCode_HR[ 2]=':'; Event_TimeCode_HR[ 3]='0'+Tc.Minutes/10; Event_TimeCode_HR[ 4]='0'+Tc.Minutes%10; Event_TimeCode_HR[ 5]=':'; Event_TimeCode_HR[ 6]='0'+Tc.Seconds/10; Event_TimeCode_HR[ 7]='0'+Tc.Seconds%10; Event_TimeCode_HR[ 8]=Tc.DropFrame?';':':'; Event_TimeCode_HR[ 9]='0'+Tc.Frames/10; Event_TimeCode_HR[10]='0'+Tc.Frames%10; Event_TimeCode_HR[11]='\0'; Event_TimeCode_HR[12]='\0'; } else { Event_TimeCode.Hours=(MediaInfo_int8u)-1; Event_TimeCode.Minutes=(MediaInfo_int8u)-1; Event_TimeCode.Seconds=(MediaInfo_int8u)-1; Event_TimeCode.Frames=(MediaInfo_int8u)-1; Event_TimeCode.FramesPerSecond=(MediaInfo_int8u)-1; Event_TimeCode.DropFrame=(MediaInfo_int8u)-1; memset(Event_TimeCode_HR, 0x00, 13); } } } #endif //MediaInfo_EventsH MediaInfoLib/Source/MediaInfo/MediaInfo_File.cpp0000664000000000000000000014100412652076434020442 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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/File__Analyze.h" #include "MediaInfo/Reader/Reader_File.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Multiple #if defined(MEDIAINFO_AAF_YES) #include "MediaInfo/Multiple/File_Aaf.h" #endif #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_DASHMPD_YES) #include "MediaInfo/Multiple/File_DashMpd.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpAm.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpCpl.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpPkl.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_HDSF4M_YES) #include "MediaInfo/Multiple/File_HdsF4m.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_IMF_YES) #include "MediaInfo/Multiple/File_ImfCpl.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_PMP_YES) #include "MediaInfo/Multiple/File_Pmp.h" #endif #if defined(MEDIAINFO_PTX_YES) #include "MediaInfo/Multiple/File_Ptx.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_HEVC_YES) #include "MediaInfo/Video/File_Hevc.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_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_CAF_YES) #include "MediaInfo/Audio/File_Caf.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_OPENMG_YES) #include "MediaInfo/Audio/File_OpenMG.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_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.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_PDF_YES) #include "MediaInfo/Text/File_Pdf.h" #endif #if defined(MEDIAINFO_SCC_YES) #include "MediaInfo/Text/File_Scc.h" #endif #if defined(MEDIAINFO_SDP_YES) #include "MediaInfo/Text/File_Sdp.h" #endif #if defined(MEDIAINFO_SUBRIP_YES) #include "MediaInfo/Text/File_SubRip.h" #endif #if defined(MEDIAINFO_TELETEXT_YES) #include "MediaInfo/Text/File_Teletext.h" #endif #if defined(MEDIAINFO_TTML_YES) #include "MediaInfo/Text/File_Ttml.h" #endif #if defined(MEDIAINFO_OTHERTEXT_YES) #include "MediaInfo/Text/File_OtherText.h" #endif //--------------------------------------------------------------------------- // Image #if defined(MEDIAINFO_ARRIRAW_YES) #include "MediaInfo/Image/File_ArriRaw.h" #endif #if defined(MEDIAINFO_BMP_YES) #include "MediaInfo/Image/File_Bmp.h" #endif #if defined(MEDIAINFO_BPG_YES) #include "MediaInfo/Image/File_Bpg.h" #endif #if defined(MEDIAINFO_DDS_YES) #include "MediaInfo/Image/File_Dds.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_PCX_YES) #include "MediaInfo/Image/File_Pcx.h" #endif #if defined(MEDIAINFO_PNG_YES) #include "MediaInfo/Image/File_Png.h" #endif #if defined(MEDIAINFO_PSD_YES) #include "MediaInfo/Image/File_Psd.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_AAF_YES) else if (Parser==__T("Aaf")) Info=new File_Aaf(); #endif #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_DASHMPD_YES) else if (Parser==__T("DashMpd")) Info=new File_DashMpd(); #endif #if defined(MEDIAINFO_DCP_YES) else if (Parser==__T("DcpAm")) Info=new File_DcpAm(); #endif #if defined(MEDIAINFO_DCP_YES) else if (Parser==__T("DcpCpl")) Info=new File_DcpCpl(); #endif #if defined(MEDIAINFO_DCP_YES) else if (Parser==__T("DcpPkg")) Info=new File_DcpPkl(); #endif #if defined(MEDIAINFO_DPG_YES) else if (Parser==__T("Dpg")) Info=new File_Dpg(); #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_HDSF4M_YES) else if (Parser==__T("HdsF4m")) Info=new File_HdsF4m(); #endif #if defined(MEDIAINFO_HLS_YES) else if (Parser==__T("Hls")) Info=new File_Hls(); #endif #if defined(MEDIAINFO_ISM_YES) else if (Parser==__T("Ism")) Info=new File_Ism(); #endif #if defined(MEDIAINFO_IVF_YES) else if (Parser==__T("Ivf")) Info=new File_Ivf(); #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_PMP_YES) else if (Parser==__T("Pmp")) Info=new File_Pmp(); #endif #if defined(MEDIAINFO_PTX_YES) else if (Parser==__T("Ptx")) Info=new File_Ptx(); #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 // Video #if defined(MEDIAINFO_AVC_YES) else if (Parser==__T("Avc")) Info=new File_Avc(); #endif #if defined(MEDIAINFO_HEVC_YES) else if (Parser==__T("Hevc")) Info=new File_Hevc(); #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("Adts")) {Info=new File_Aac(); ((File_Aac*)Info)->Mode=File_Aac::Mode_ADTS;} // Prioritization against ADIF #endif #if defined(MEDIAINFO_AC3_YES) else if (Parser==__T("Ac3")) Info=new File_Ac3(); #endif #if defined(MEDIAINFO_SMPTEST0337_YES) else if (Parser==__T("Aes3")) Info=new File_SmpteSt0337(); #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_CAF_YES) else if (Parser==__T("Caf")) Info=new File_Caf(); #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_OPENMG_YES) else if (Parser==__T("OpenMG")) Info=new File_OpenMG(); #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_N19_YES) else if (Parser==__T("N19")) Info=new File_N19(); #endif #if defined(MEDIAINFO_PDF_YES) else if (Parser==__T("PDF")) Info=new File_Pdf(); #endif #if defined(MEDIAINFO_SCC_YES) else if (Parser==__T("SCC")) Info=new File_Scc(); #endif #if defined(MEDIAINFO_SDP_YES) else if (Parser==__T("SDP")) Info=new File_Sdp(); #endif #if defined(MEDIAINFO_SUBRIP_YES) else if (Parser==__T("SubRip")) Info=new File_SubRip(); else if (Parser==__T("WebVTT")) Info=new File_SubRip(); #endif #if defined(MEDIAINFO_TELETEXT_YES) else if (Parser==__T("Teletext")) Info=new File_Teletext(); #endif #if defined(MEDIAINFO_TTML_YES) else if (Parser==__T("TTML")) Info=new File_Ttml(); #endif #if defined(MEDIAINFO_OTHERTEXT_YES) else if (Parser==__T("OtherText")) Info=new File_OtherText(); #endif // Image #if defined(MEDIAINFO_ARRIRAW_YES) else if (Parser==__T("Arri Raw")) Info=new File_ArriRaw(); #endif #if defined(MEDIAINFO_BMP_YES) else if (Parser==__T("Bmp")) Info=new File_Bmp(); #endif #if defined(MEDIAINFO_BPG_YES) else if (Parser==__T("Bpg")) Info=new File_Bpg(); #endif #if defined(MEDIAINFO_DDS_YES) else if (Parser==__T("Dds")) Info=new File_Dds(); #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_GIF_YES) else if (Parser==__T("Gif")) Info=new File_Gif(); #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_PCX_YES) else if (Parser==__T("PCX")) Info=new File_Pcx(); #endif #if defined(MEDIAINFO_PNG_YES) else if (Parser==__T("Png")) Info=new File_Png(); #endif #if defined(MEDIAINFO_PSD_YES) else if (Parser==__T("Psd")) Info=new File_Psd(); #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_AAF_YES) delete Info; Info=new File_Aaf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #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_DASHMPD_YES) delete Info; Info=new File_DashMpd(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DCP_YES) delete Info; Info=new File_DcpAm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DCP_YES) delete Info; Info=new File_DcpCpl(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DCP_YES) delete Info; Info=new File_DcpPkl(); 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_HDSF4M_YES) delete Info; Info=new File_HdsF4m(); 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_PMP_YES) delete Info; Info=new File_Pmp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_PTX_YES) delete Info; Info=new File_Ptx(); 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_HEVC_YES) delete Info; Info=new File_Hevc(); 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; //At the end, too much sensible #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_SMPTEST0337_YES) delete Info; Info=new File_SmpteSt0337(); 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_CAF_YES) delete Info; Info=new File_Caf(); 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 // Too many false-positives // #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_OPENMG_YES) delete Info; Info=new File_OpenMG(); 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_PDF_YES) delete Info; Info=new File_Pdf(); 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_SDP_YES) delete Info; Info=new File_Sdp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_SUBRIP_YES) delete Info; Info=new File_SubRip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TELETEXT_YES) delete Info; Info=new File_Teletext(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_TTML_YES) delete Info; Info=new File_Ttml(); 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_ARRIRAW_YES) delete Info; Info=new File_ArriRaw(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #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_BPG_YES) delete Info; Info=new File_Bpg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; #endif #if defined(MEDIAINFO_DDS_YES) delete Info; Info=new File_Dds(); 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_PCX_YES) delete Info; Info=new File_Pcx(); 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_PSD_YES) delete Info; Info=new File_Psd(); 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; //At the end, too much sensible #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 //At the end, too much sensible #if defined(MEDIAINFO_TGA_YES) delete Info; Info=new File_Tga(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1; //At the end, too much sensible #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 // 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_HDSF4M_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_AAF_NO) || defined(MEDIAINFO_CDXA_NO) || defined(MEDIAINFO_DPG_NO) || defined(MEDIAINFO_TSP_NO) \ || defined(MEDIAINFO_AVC_NO) || defined(MEDIAINFO_AVSV_NO) || defined(MEDIAINFO_HEVC_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_SMPTEST0337_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_OPENMG_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_ARRIRAW_NO) || defined(MEDIAINFO_BMP_NO) || defined(MEDIAINFO_DDS_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 MediaInfoLib/Source/MediaInfo/Duplicate/0000775000000000000000000000000012652076434017056 5ustar rootrootMediaInfoLib/Source/MediaInfo/Duplicate/File__Duplicate__Base.cpp0000664000000000000000000000255412652076434023671 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Duplicate/File__Duplicate__Writer.cpp0000664000000000000000000001230212652076434024263 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 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 MediaInfoLib/Source/MediaInfo/Duplicate/File__Duplicate_MpegTs.cpp0000664000000000000000000004454712652076434024067 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 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 StreamID_List; for (std::map::iterator PAT_=PAT.begin(); PAT_!=PAT.end(); ++PAT_) if (PAT_->first!=StreamID) StreamID_List.push_back(PAT_->first); for (size_t Pos=0; Pos &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; Pos0x0F) 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>24)^(FromTS.Buffer[CRC_32_Offset])]; if (CRC_32) return false; //Problem //Copying if (ToModify.Buffer!=NULL && ToModify.Size &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>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; Pos0x0F) 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 //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File__Duplicate__Base //*************************************************************************** class File__Duplicate__Base { public : //Constructor/Destructor File__Duplicate__Base(); //~File__Duplicate__Base(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Duplicate/File__Duplicate__Writer.h0000664000000000000000000000325612652076434023740 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__Duplicate__WriterH #define File__Duplicate__WriterH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Duplicate/File__Duplicate_MpegTs.h0000664000000000000000000000771612652076434023531 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__Duplicate_MpegTsH #define File__Duplicate_MpegTsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Duplicate/File__Duplicate__Base.h" #include "MediaInfo/Duplicate/File__Duplicate__Writer.h" #include //--------------------------------------------------------------------------- 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 Wanted_program_numbers; std::set Wanted_program_map_PIDs; std::set Wanted_elementary_PIDs; std::set Remove_program_numbers; std::set Remove_program_map_PIDs; std::set Remove_elementary_PIDs; //Current std::vector program_map_PIDs; std::vector elementary_PIDs; std::vector 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 PAT; std::map PMT; std::map BigBuffers; //key is pid //Helpers bool Parsing_Begin(const int8u* ToAdd, size_t ToAdd_Size, std::map &ToModify); void Parsing_End(std::map &ToModify); //Temp int16u StreamID; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/MediaInfoList.cpp0000664000000000000000000002253712652076434020350 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 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 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 Internal->Open(File, Options); } //--------------------------------------------------------------------------- size_t MediaInfoList::Open_Buffer_Init (int64u File_Size_, int64u File_Offset_) { return 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 Internal->Open_Buffer_Continue(FilePos, ToAdd, ToAdd_Size); } //--------------------------------------------------------------------------- int64u MediaInfoList::Open_Buffer_Continue_GoTo_Get (size_t FilePos) { return Internal->Open_Buffer_Continue_GoTo_Get(FilePos); } //--------------------------------------------------------------------------- size_t MediaInfoList::Open_Buffer_Finalize (size_t FilePos) { return Internal->Open_Buffer_Finalize(FilePos); } //--------------------------------------------------------------------------- size_t MediaInfoList::Save(size_t) { return 0; //Not yet implemented } //--------------------------------------------------------------------------- void MediaInfoList::Close(size_t FilePos) { Internal->Close(FilePos); } //*************************************************************************** // Get File info //*************************************************************************** //--------------------------------------------------------------------------- String MediaInfoList::Inform(size_t FilePos, size_t) { return Internal->Inform(FilePos); } //--------------------------------------------------------------------------- String MediaInfoList::Get(size_t FilePos, stream_t KindOfStream, size_t StreamNumber, size_t Parameter, info_t KindOfInfo) { return 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 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 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 Internal->Set(ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldValue); } //*************************************************************************** // Output buffer //*************************************************************************** /* //--------------------------------------------------------------------------- char* MediaInfoList::Output_Buffer_Get (size_t FilePos, size_t &Output_Buffer_Size) { return Internal->Output_Buffer_Get(FilePos, Output_Buffer_Size); } */ //*************************************************************************** // Information //*************************************************************************** //--------------------------------------------------------------------------- String MediaInfoList::Option (const String &Option, const String &Value) { return 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 Internal->State_Get(); } //--------------------------------------------------------------------------- size_t MediaInfoList::Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber) { return Internal->Count_Get(FilePos, StreamKind, StreamNumber); } //--------------------------------------------------------------------------- size_t MediaInfoList::Count_Get() { return Internal->Count_Get(); } } //NameSpace MediaInfoLib/Source/MediaInfo/MediaInfo_Events.h0000664000000000000000000007565012652076434020511 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ /*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__) && !defined(__stdcall) #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 */ /***************************************************************************/ /*-------------------------------------------------------------------------*/ /* Time code */ typedef struct MediaInfo_time_code { MediaInfo_int8u Hours; MediaInfo_int8u Minutes; MediaInfo_int8u Seconds; MediaInfo_int8u Frames; MediaInfo_int8u FramesPerSecond; MediaInfo_int8u DropFrame; //0= No, 1=Yes MediaInfo_int8u Reserved[2]; } MediaInfo_time_code; /*-------------------------------------------------------------------------*/ /* Generic */ #define MEDIAINFO_EVENT_GENERIC \ MediaInfo_int32u EventCode; \ MediaInfo_int32u ReservedI32; \ size_t EventSize; \ size_t StreamIDs_Size; \ MediaInfo_int64u StreamIDs[16]; \ MediaInfo_int8u StreamIDs_Width[16]; \ MediaInfo_int8u ParserIDs[16]; \ MediaInfo_int64u StreamOffset; \ MediaInfo_int64u FrameNumber; \ MediaInfo_int64u PCR; \ MediaInfo_int64u PTS; \ MediaInfo_int64u DTS; \ MediaInfo_int64u DUR; \ MediaInfo_int64u FrameNumber_PresentationOrder; \ MediaInfo_int64u ReservedI64[1]; \ MediaInfo_time_code TimeCode_Container; \ MediaInfo_time_code TimeCode_SDTI; \ MediaInfo_time_code TimeCode_RawStream; \ MediaInfo_time_code ReservedT[5]; \ typedef struct MediaInfo_Event_Generic { MEDIAINFO_EVENT_GENERIC } MediaInfo_Event_Generic; /*-------------------------------------------------------------------------*/ /* MediaInfo_Event_Log_0 */ #define MediaInfo_Event_Log 0x0F00 struct MediaInfo_Event_Log_0 { MEDIAINFO_EVENT_GENERIC 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_4 { MEDIAINFO_EVENT_GENERIC MediaInfo_int8u Content_Type; /*MediaInfo_Event_Global_Demux_0_contenttype*/ size_t Content_Size; const MediaInfo_int8u* Content; MediaInfo_int64u Flags; /*bit0=random_access*/ size_t Offsets_Size; const MediaInfo_int64u* Offsets_Stream; /* From the begin of the stream */ const MediaInfo_int64u* Offsets_Content; /* From the begin of the demuxed content */ size_t OriginalContent_Size; /* In case of decoded content inside MediaInfo, OriginalContent contain the not-decoded stream */ const MediaInfo_int8u* OriginalContent; /* In case of decoded content inside MediaInfo, OriginalContent contain the not-decoded stream */ }; /*-------------------------------------------------------------------------*/ /* BytesRead */ #define MediaInfo_Event_Global_BytesRead 0xAF02 struct MediaInfo_Event_Global_BytesRead_0 { MEDIAINFO_EVENT_GENERIC size_t Content_Size; const MediaInfo_int8u* Content; }; /*-------------------------------------------------------------------------*/ /* MediaInfo_Event_Video_SliceInfo_0 */ #define MediaInfo_Event_Video_SliceInfo 0x7801 struct MediaInfo_Event_Video_SliceInfo_0 { MEDIAINFO_EVENT_GENERIC MediaInfo_int64u FieldPosition; MediaInfo_int64u SlicePosition; MediaInfo_int8u SliceType; MediaInfo_int64u Flags; }; /***************************************************************************/ /* General */ /***************************************************************************/ #define MediaInfo_Parser_None 0x00 #define MediaInfo_Parser_General 0x00 #define MediaInfo_Parser_Global 0x00 #define MediaInfo_Parser_Video 0x01 /*-------------------------------------------------------------------------*/ /* SubFile_Missing */ #define MediaInfo_Event_General_SubFile_Missing 0x1F01 struct MediaInfo_Event_General_SubFile_Missing_0 { MEDIAINFO_EVENT_GENERIC const char* FileName_Relative; const wchar_t* FileName_Relative_Unicode; const char* FileName_Absolute; const wchar_t* FileName_Absolute_Unicode; }; /*-------------------------------------------------------------------------*/ /* Start */ #define MediaInfo_Event_General_Start 0x7001 struct MediaInfo_Event_General_Start_0 { MEDIAINFO_EVENT_GENERIC MediaInfo_int64u Stream_Size; const char* FileName; const wchar_t* FileName_Unicode; }; /*-------------------------------------------------------------------------*/ /* End */ #define MediaInfo_Event_General_End 0x7002 struct MediaInfo_Event_General_End_0 { MEDIAINFO_EVENT_GENERIC MediaInfo_int64u Stream_Bytes_Analyzed; MediaInfo_int64u Stream_Size; MediaInfo_int64u Stream_Bytes_Padding; MediaInfo_int64u Stream_Bytes_Junk; }; /*-------------------------------------------------------------------------*/ /* Parser_Selected */ #define MediaInfo_Event_General_Parser_Selected 0x7003 struct MediaInfo_Event_General_Parser_Selected_0 { MEDIAINFO_EVENT_GENERIC char Name[16]; }; /*-------------------------------------------------------------------------*/ /* Move request */ #define MediaInfo_Event_General_Move_Request 0x7004 struct MediaInfo_Event_General_Move_Request_0 { MEDIAINFO_EVENT_GENERIC }; /*-------------------------------------------------------------------------*/ /* Move done */ #define MediaInfo_Event_General_Move_Done 0x7005 struct MediaInfo_Event_General_Move_Done_0 { MEDIAINFO_EVENT_GENERIC }; /*-------------------------------------------------------------------------*/ /* SubFile_Start */ #define MediaInfo_Event_General_SubFile_Start 0x7006 struct MediaInfo_Event_General_SubFile_Start_0 { MEDIAINFO_EVENT_GENERIC const char* FileName_Relative; const wchar_t* FileName_Relative_Unicode; const char* FileName_Absolute; const wchar_t* FileName_Absolute_Unicode; }; /*-------------------------------------------------------------------------*/ /* SubFile_End */ #define MediaInfo_Event_General_SubFile_End 0x7007 struct MediaInfo_Event_General_SubFile_End_0 { MEDIAINFO_EVENT_GENERIC }; /***************************************************************************/ /* MPEG-TS / BDAV / TSP */ /***************************************************************************/ #define MediaInfo_Parser_SideCar 0x72 /***************************************************************************/ /* 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 /***************************************************************************/ /* DASH MPD */ /***************************************************************************/ #define MediaInfo_Parser_DashMpd 0x63 /***************************************************************************/ /* HDS F4M */ /***************************************************************************/ #define MediaInfo_Parser_HdsF4m 0x64 /***************************************************************************/ /* DCP Composition Asset Map */ /***************************************************************************/ #define MediaInfo_Parser_DcpAm 0x65 /***************************************************************************/ /* DCP Composition Playlist */ /***************************************************************************/ #define MediaInfo_Parser_DcpCpl 0x66 /***************************************************************************/ /* DCP Package List */ /***************************************************************************/ #define MediaInfo_Parser_DcpPkl 0x67 /***************************************************************************/ /* DCP Output List */ /***************************************************************************/ #define MediaInfo_Parser_DcpOpl 0x68 /***************************************************************************/ /* Pro Tools session 10 */ /***************************************************************************/ #define MediaInfo_Parser_Ptx 0x69 /***************************************************************************/ /* AAF */ /***************************************************************************/ #define MediaInfo_Parser_Aaf 0x6A /***************************************************************************/ /* DXW */ /***************************************************************************/ #define MediaInfo_Parser_Dxw 0x6B /***************************************************************************/ /* MPEG Video */ /***************************************************************************/ #define MediaInfo_Parser_Mpegv 0x80 /***************************************************************************/ /* AVC */ /***************************************************************************/ #define MediaInfo_Parser_Avc 0x81 /***************************************************************************/ /* AVC */ /***************************************************************************/ #define MediaInfo_Parser_Hevc 0x83 /***************************************************************************/ /* 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 /***************************************************************************/ /* JPEG */ /***************************************************************************/ #define MediaInfo_Parser_Jpeg 0xC0 /***************************************************************************/ /* 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 /***************************************************************************/ /* ARIB STD B24/B37 */ /***************************************************************************/ #define MediaInfo_Parser_AribStdB24B37 0xF9 /***************************************************************************/ /* TTML */ /***************************************************************************/ #define MediaInfo_Parser_Ttml 0xFA /***************************************************************************/ /* SubRip */ /***************************************************************************/ #define MediaInfo_Parser_SubRip 0xFB /***************************************************************************/ /* N19 */ /***************************************************************************/ #define MediaInfo_Parser_N19 0xFC /***************************************************************************/ /* SDP */ /***************************************************************************/ #define MediaInfo_Parser_Sdp 0xFD #endif //MediaInfo_EventsH MediaInfoLib/Source/MediaInfo/PreComp.cpp0000664000000000000000000000115012652076434017212 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Helpers for compilers (precompilation) // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include "MediaInfo/PreComp.h" //--------------------------------------------------------------------------- MediaInfoLib/Source/MediaInfo/TimeCode.h0000664000000000000000000000572612652076434017020 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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); TimeCode (int64s 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(); string ToString(); int64s ToFrames(); int64s ToMilliseconds(); public: int8u Hours; int8u Minutes; int8u Seconds; int8u Frames; int8u FramesPerSecond; bool DropFrame; bool MustUseSecondField; bool IsSecondField; bool IsNegative; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File__Duplicate.h0000664000000000000000000000261012652076434020324 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__DuplicateH #define File__DuplicateH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Duplicate/File__Duplicate__Writer.h" //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/TimeCode.cpp0000664000000000000000000001657512652076434017357 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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), IsNegative(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_), IsNegative(false) { } //--------------------------------------------------------------------------- TimeCode::TimeCode (int64s Frames_, int8u FramesPerSecond_, bool DropFrame_, bool MustUseSecondField_, bool IsSecondField_) : FramesPerSecond(FramesPerSecond_), DropFrame(DropFrame_), MustUseSecondField(MustUseSecondField_), IsSecondField(IsSecondField_) { if (!FramesPerSecond_) { Frames = 0; Seconds = 0; Minutes = 0; Hours = 0; IsNegative = true; //Forcing a weird display return; } if (Frames_<0) { IsNegative=true; Frames_=-Frames_; } else IsNegative=false; int8u Dropped=0; if (DropFrame_) { Dropped=2; if (FramesPerSecond_>30) Dropped+=2; if (FramesPerSecond_>60) Dropped+=2; if (FramesPerSecond_>90) Dropped+=2; if (FramesPerSecond_>120) Dropped+=2; } int64u Minutes_Tens = Frames_/(600*FramesPerSecond_-Dropped*9); //Count of 10 minutes int64u Minutes_Units = (Frames_-Minutes_Tens*(600*FramesPerSecond_-Dropped*9))/(60*FramesPerSecond_-Dropped); Frames_ += 9*Dropped*Minutes_Tens+Dropped*Minutes_Units; if (Minutes_Units && ((Frames_/FramesPerSecond_)%60)==0 && (Frames_%FramesPerSecond_)=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() { //TODO: negative values 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; } } //--------------------------------------------------------------------------- string TimeCode::ToString() { if (!FramesPerSecond) return string(); string TC; if (IsNegative) TC+='-'; TC+=('0'+Hours/10); TC+=('0'+Hours%10); TC+=':'; TC+=('0'+Minutes/10); TC+=('0'+Minutes%10); TC+=':'; TC+=('0'+Seconds/10); TC+=('0'+Seconds%10); TC+=DropFrame?';':':'; TC+=('0'+(Frames*(MustUseSecondField?2:1)+(IsSecondField?1:0))/10); TC+=('0'+(Frames*(MustUseSecondField?2:1)+(IsSecondField?1:0))%10); return TC; } //--------------------------------------------------------------------------- int64s TimeCode::ToFrames() { if (!FramesPerSecond) return 0; int64s TC=(int64s(Hours) *3600 + int64s(Minutes) * 60 + int64s(Seconds) )*int64s(FramesPerSecond) + int64s(Frames); if (DropFrame) { TC-= int64s(Hours) *108 + (int64s(Minutes)/10)*18 + (int64s(Minutes)%10)*2; } TC*=(MustUseSecondField?2:1); TC+=(IsSecondField?1:0); return IsNegative?-TC:TC; } //--------------------------------------------------------------------------- int64s TimeCode::ToMilliseconds() { if (!FramesPerSecond) return 0; int64s MS=(int64s(Hours) *3600 + int64s(Minutes) * 60 + int64s(Seconds) )*1000 + float64_int64s((float64(Frames*(MustUseSecondField?2:1)+(IsSecondField?1:0)))*1000/(FramesPerSecond*(MustUseSecondField?2:1))); return IsNegative?-MS:MS; } //*************************************************************************** // //*************************************************************************** } //NameSpace MediaInfoLib/Source/MediaInfo/File__MultipleParsing.h0000664000000000000000000000275212652076434021540 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about MPEG files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_MpegH #define MediaInfo_MpegH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 Parser; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File__Analyze_Buffer.cpp0000664000000000000000000026634612652076434021663 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 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() { size_t BS_Size; if (Element_Offset>=Element_Size) BS_Size=0; else if (Buffer_Offset+Element_Size<=Buffer_Size) BS_Size=(size_t)(Element_Size-Element_Offset); else if (Buffer_Offset+Element_Offset<=Buffer_Size) BS_Size=Buffer_Size-(size_t)(Buffer_Offset+Element_Offset); else BS_Size=0; BS->Attach(Buffer+Buffer_Offset+(size_t)Element_Offset, BS_Size); } //--------------------------------------------------------------------------- void File__Analyze::BS_Begin_LE() { size_t BS_Size; if (Buffer_Offset+Element_Size<=Buffer_Size) BS_Size=(size_t)(Element_Size-Element_Offset); else if (Buffer_Offset+Element_Offset<=Buffer_Size) BS_Size=Buffer_Size-(size_t)(Buffer_Offset+Element_Offset); else BS_Size=0; 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) { switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : Param(Name, Ztring::ToZtring(Info)); break; default : { 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; } //--------------------------------------------------------------------------- // Big Endian - float 16 bits // TODO: remove it when Linux version of ZenLib is updated float32 BigEndian2float16corrected(const char* Liste) { //sign 1 bit //exponent 5 bit //significand 10 bit //Retrieving data int16u Integer=BigEndian2int16u(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-=0x0F; //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; } inline float32 BigEndian2float16corrected (const int8u* List) {return BigEndian2float16corrected ((const char*)List);} //--------------------------------------------------------------------------- void File__Analyze::Get_BF2(float32 &Info, const char* Name) { INTEGRITY_SIZE_ATLEAST_INT(2); Info=BigEndian2float16corrected(Buffer+Buffer_Offset+(size_t)Element_Offset); if (Trace_Activated) Param(Name, Info); Element_Offset+=2; } //--------------------------------------------------------------------------- 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(int8u 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<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; } int8u 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); int8u 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(InfoDRemain(), "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(InfoDSkip(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)<Remain()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_6937_2(int64u Bytes, Ztring &Info, const char* Name) { INTEGRITY_SIZE_ATLEAST_STRING(Bytes); Info.clear(); size_t End = Buffer_Offset + (size_t)Element_Offset + (size_t)Bytes; for (size_t Pos=Buffer_Offset+(size_t)Element_Offset; PosRemain(), "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(int8u Bits, int8u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get1(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S2(int8u Bits, int16u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get2(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S3(int8u Bits, int32u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get4(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S4(int8u Bits, int32u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get4(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S5(int8u Bits, int64u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get8(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S6(int8u Bits, int64u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get8(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S7(int8u Bits, int64u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get8(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Get_S8(int8u Bits, int64u &Info, const char* Name) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Get8(Bits); #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, Info); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File__Analyze::Peek_BS(int8u 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(int8u Bits, int8u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek1(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S2(int8u Bits, int16u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek2(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S3(int8u Bits, int32u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek4(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S4(int8u Bits, int32u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek4(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S5(int8u Bits, int64u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek8(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S6(int8u Bits, int64u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek8(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S7(int8u Bits, int64u &Info) { INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) Info=BS->Peek8(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_S8(int8u 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((int8u)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(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get1(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S2(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get2(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S3(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get4(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S4(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get4(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S5(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get8(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S6(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get8(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S7(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get8(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE BS->Skip(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Skip_S8(int8u Bits, const char* Name) { INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get()) #if MEDIAINFO_TRACE if (Trace_Activated) { Param(Name, BS->Get8(Bits)); Param_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); } else #endif //MEDIAINFO_TRACE 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_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); Param(Name, Info); } } //--------------------------------------------------------------------------- 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_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_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_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_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_Info(__T("(")+Ztring::ToZtring(Bits)+__T(" bits)")); Param(Name, BT->Get1(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_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_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 MediaInfoLib/Source/MediaInfo/File__Duplicate.cpp0000664000000000000000000000565412652076434020672 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/0000775000000000000000000000000012652076434016212 5ustar rootrootMediaInfoLib/Source/MediaInfo/Video/File_Theora.cpp0000664000000000000000000001240412652076434021100 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_Flic.cpp0000664000000000000000000001412312652076434020533 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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_* MediaInfoLib/Source/MediaInfo/Video/File_Y4m.cpp0000664000000000000000000002073212652076434020332 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // // 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 slices_size; Element_Begin1("Picture header"); int64u pic_hdr_End, pic_data_End; int32u pic_data_size; int8u pic_hdr_size; Get_B1 (pic_hdr_size, "pic_hdr_size"); if (pic_hdr_size<64) { Trusted_IsNot("pic_hdr_size"); Element_End(); Element_End(); return; } pic_hdr_End=Element_Offset+pic_hdr_size/8-((pic_hdr_size%8)?0:1); Get_B4 (pic_data_size, "pic_data_size"); if (pic_data_size<8) { Trusted_IsNot("pic_data_size"); Element_End(); Element_End(); return; } pic_data_End=Element_Offset+pic_data_size-5; Get_B2 (total_slices, "total_slices"); BS_Begin(); Skip_S1(4, "slice_width_factor"); Skip_S1(4, "slice_height_factor"); BS_End(); if (Element_OffsetElement_Size) { Skip_XX(Element_Size-Element_Offset, "Problem"); Element_End0(); return; } Skip_L4( "Unknown"); Skip_L4( "Unknown"); Get_L4 (PAR_X, "PAR_X"); Get_L4 (PAR_Y, "PAR_Y"); while (Element_OffsetInfo_End) { Skip_XX(Info_End-Element_Offset, "Problem"); break; } if (Element_OffsetInfo_End) { Skip_XX(Info_End-Element_Offset, "Problem"); break; } while (Element_OffsetParseSpeed<1.0) Finish(); } FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_CANOPUS_YES MediaInfoLib/Source/MediaInfo/Video/File_Vp8.h0000664000000000000000000000272012652076434020000 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_AvsV.h0000664000000000000000000000672012652076434020206 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 Streams; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Avc_Duplicate.cpp0000664000000000000000000002206112652076434022361 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 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 Targets_ToAdd; std::vector Targets_ToRemove; std::vector Orders_ToAdd; std::vector Orders_ToRemove; for (ZtringList::iterator Current=List.begin(); Currentfind(__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::iterator Target=Targets_ToAdd.begin(); Target::iterator Order=Orders_ToAdd.begin(); Orderprofile_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 MediaInfoLib/Source/MediaInfo/Video/File_Aic.cpp0000664000000000000000000001021612652076434020351 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_AIC_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Video/File_Aic.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Aic::Streams_Fill() { //Filling Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Format, "AIC"); Fill(Stream_Video, 0, Video_Width, Width); Fill(Stream_Video, 0, Video_Height, Height); Fill(Stream_Video, 0, Video_BitDepth, 8); //Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); //Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:0"); switch (FieldFrame) { case 0 : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); break; case 3 : Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); break; default: ; } } //*************************************************************************** // Buffer - Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_Aic::Header_Parse() { //Parsing int32u Size; int16u Sync; Get_B2 (Sync, "Sync"); Get_B4 (Size, "Size"); if (Sync!=0x0116 || Size<24 || Size!=Buffer_Size) { Reject("AIC"); return; } Get_B2 (Width, "Width"); Get_B2 (Height, "Height"); Skip_B2( "Width again?"); Skip_B2( "Height again?"); Skip_B2( "Unknown"); BS_Begin(); Get_S1 (4, FieldFrame, "field/Frame info?"); Skip_S1(4, "Unknown"); Skip_S1(4, "Unknown"); Skip_S1(4, "Unknown"); BS_End(); Skip_B3( "Unknown"); Skip_B3( "Unknown"); Header_Fill_Code(0, "Frame"); Header_Fill_Size(Size); } //--------------------------------------------------------------------------- void File_Aic::Data_Parse() { //Parsing Skip_XX(Element_Size, "Data"); FILLING_BEGIN(); Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (!Status[IsFilled]) { Accept("AIC"); Finish("AIC"); } FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_AIC_* MediaInfoLib/Source/MediaInfo/Video/File_Hevc.h0000664000000000000000000004545712652076434020226 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef MediaInfo_HevcH #define MediaInfo_HevcH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Hevc //*************************************************************************** class File_Hevc : public File__Analyze { public : //In int64u Frame_Count_Valid; bool FrameIsAlwaysComplete; bool MustParse_VPS_SPS_PPS; bool MustParse_VPS_SPS_PPS_FromMatroska; bool MustParse_VPS_SPS_PPS_FromFlv; bool SizedBlocks; //Constructor/Destructor File_Hevc(); ~File_Hevc(); private : File_Hevc(const File_Hevc &File_Hevc); //No copy //Structures - video_parameter_set struct video_parameter_set_struct { #if MEDIAINFO_DEMUX int8u* AnnexB_Buffer; size_t AnnexB_Buffer_Size; #endif //MEDIAINFO_DEMUX int8u vps_max_sub_layers_minus1; //Constructor/Destructor video_parameter_set_struct(int8u vps_max_sub_layers_minus1_) : #if MEDIAINFO_DEMUX AnnexB_Buffer(NULL), AnnexB_Buffer_Size(0), #endif //MEDIAINFO_DEMUX vps_max_sub_layers_minus1(vps_max_sub_layers_minus1_) { } ~video_parameter_set_struct() { #if MEDIAINFO_DEMUX delete[] AnnexB_Buffer; #endif //MEDIAINFO_DEMUX } private: video_parameter_set_struct &operator=(const video_parameter_set_struct &v); video_parameter_set_struct(); }; typedef vector video_parameter_set_structs; //Structures - seq_parameter_set struct seq_parameter_set_struct { struct vui_parameters_struct { struct xxl { struct xxl_data { //HRD configuration int64u bit_rate_value; int64u cpb_size_value; bool cbr_flag; //sei_message_buffering_period //int32u initial_cpb_removal_delay; //int32u initial_cpb_removal_delay_offset; xxl_data(int64u bit_rate_value_, int64u cpb_size_value_, bool cbr_flag_) //int32u initial_cpb_removal_delay_, int32u initial_cpb_removal_delay_offset_) : bit_rate_value(bit_rate_value_), cpb_size_value(cpb_size_value_), cbr_flag(cbr_flag_) //initial_cpb_removal_delay(initial_cpb_removal_delay_), //initial_cpb_removal_delay_offset(initial_cpb_removal_delay_offset_) { } xxl_data &operator=(const xxl_data &x) { bit_rate_value = x.bit_rate_value; cpb_size_value = x.cpb_size_value; cbr_flag = x.cbr_flag; //initial_cpb_removal_delay=x.initial_cpb_removal_delay; //initial_cpb_removal_delay_offset=x.initial_cpb_removal_delay_offset; return *this; } private: xxl_data(); }; vector SchedSel; xxl(const vector &SchedSel_) : SchedSel(SchedSel_) { } xxl &operator=(const xxl &x) { SchedSel = x.SchedSel; return *this; } private: xxl(); }; struct xxl_common { //Common to all xxl bool sub_pic_hrd_params_present_flag; int8u du_cpb_removal_delay_increment_length_minus1; int8u dpb_output_delay_du_length_minus1; int8u initial_cpb_removal_delay_length_minus1; int8u au_cpb_removal_delay_length_minus1; int8u dpb_output_delay_length_minus1; xxl_common(bool sub_pic_hrd_params_present_flag_, int8u du_cpb_removal_delay_increment_length_minus1_, int8u dpb_output_delay_du_length_minus1_, int8u initial_cpb_removal_delay_length_minus1_, int8u au_cpb_removal_delay_length_minus1_, int8u dpb_output_delay_length_minus1_) : sub_pic_hrd_params_present_flag(sub_pic_hrd_params_present_flag_), du_cpb_removal_delay_increment_length_minus1(du_cpb_removal_delay_increment_length_minus1_), dpb_output_delay_du_length_minus1(dpb_output_delay_du_length_minus1_), initial_cpb_removal_delay_length_minus1(initial_cpb_removal_delay_length_minus1_), au_cpb_removal_delay_length_minus1(au_cpb_removal_delay_length_minus1_), dpb_output_delay_length_minus1(dpb_output_delay_length_minus1_) { } xxl_common &operator=(const xxl_common &x) { sub_pic_hrd_params_present_flag = x.sub_pic_hrd_params_present_flag; du_cpb_removal_delay_increment_length_minus1 = x.du_cpb_removal_delay_increment_length_minus1; dpb_output_delay_du_length_minus1 = x.dpb_output_delay_du_length_minus1; initial_cpb_removal_delay_length_minus1 = x.initial_cpb_removal_delay_length_minus1; au_cpb_removal_delay_length_minus1 = x.au_cpb_removal_delay_length_minus1; dpb_output_delay_length_minus1 = x.dpb_output_delay_length_minus1; return *this; } private: xxl_common(); }; xxl* NAL; xxl* VCL; xxl_common* xxL_Common; int32u num_units_in_tick; int32u time_scale; int16u sar_width; int16u sar_height; int8u aspect_ratio_idc; int8u video_format; int8u video_full_range_flag; int8u colour_primaries; int8u transfer_characteristics; int8u matrix_coefficients; bool aspect_ratio_info_present_flag; bool video_signal_type_present_flag; bool frame_field_info_present_flag; bool colour_description_present_flag; bool timing_info_present_flag; vui_parameters_struct(xxl* NAL_, xxl* VCL_, xxl_common* xxL_Common_, int32u num_units_in_tick_, int32u time_scale_, int16u sar_width_, int16u sar_height_, int8u aspect_ratio_idc_, int8u video_format_, int8u video_full_range_flag_, int8u colour_primaries_, int8u transfer_characteristics_, int8u matrix_coefficients_, bool aspect_ratio_info_present_flag_, bool video_signal_type_present_flag_, bool frame_field_info_present_flag_, bool colour_description_present_flag_, bool timing_info_present_flag_) : NAL(NAL_), VCL(VCL_), xxL_Common(xxL_Common_), num_units_in_tick(num_units_in_tick_), time_scale(time_scale_), sar_width(sar_width_), sar_height(sar_height_), aspect_ratio_idc(aspect_ratio_idc_), video_format(video_format_), video_full_range_flag(video_full_range_flag_), colour_primaries(colour_primaries_), transfer_characteristics(transfer_characteristics_), matrix_coefficients(matrix_coefficients_), aspect_ratio_info_present_flag(aspect_ratio_info_present_flag_), video_signal_type_present_flag(video_signal_type_present_flag_), frame_field_info_present_flag(frame_field_info_present_flag_), colour_description_present_flag(colour_description_present_flag_), timing_info_present_flag(timing_info_present_flag_) { } ~vui_parameters_struct() { delete NAL; //NAL=NULL; delete VCL; //VCL=NULL; delete xxL_Common; //xxL_Common=NULL } private: vui_parameters_struct &operator=(const vui_parameters_struct &v); vui_parameters_struct(); }; vui_parameters_struct* vui_parameters; #if MEDIAINFO_DEMUX int8u* AnnexB_Buffer; size_t AnnexB_Buffer_Size; #endif //MEDIAINFO_DEMUX int32u profile_space; bool tier_flag; int32u profile_idc; int32u level_idc; int32u pic_width_in_luma_samples; int32u pic_height_in_luma_samples; int32u conf_win_left_offset; int32u conf_win_right_offset; int32u conf_win_top_offset; int32u conf_win_bottom_offset; int8u video_parameter_set_id; int8u chroma_format_idc; bool separate_colour_plane_flag; int8u log2_max_pic_order_cnt_lsb_minus4; int8u bit_depth_luma_minus8; int8u bit_depth_chroma_minus8; bool general_progressive_source_flag; bool general_interlaced_source_flag; bool general_frame_only_constraint_flag; //Computed value bool NalHrdBpPresentFlag() {return vui_parameters && vui_parameters->NAL;} bool VclHrdBpPresentFlag() {return vui_parameters && vui_parameters->VCL;} bool CpbDpbDelaysPresentFlag() {return vui_parameters && vui_parameters->xxL_Common;} //xxL_Common is present if NAL or VCL int8u ChromaArrayType() {return separate_colour_plane_flag?0:chroma_format_idc;} //Constructor/Destructor seq_parameter_set_struct(vui_parameters_struct* vui_parameters_, int32u profile_space_, bool tier_flag_, int32u profile_idc_, int32u level_idc_, int32u pic_width_in_luma_samples_, int32u pic_height_in_luma_samples_, int32u conf_win_left_offset_, int32u conf_win_right_offset_, int32u conf_win_top_offset_, int32u conf_win_bottom_offset_, int8u video_parameter_set_id_, int8u chroma_format_idc_, bool separate_colour_plane_flag_, int8u log2_max_pic_order_cnt_lsb_minus4_, int8u bit_depth_luma_minus8_, int8u bit_depth_chroma_minus8_, bool general_progressive_source_flag_, bool general_interlaced_source_flag_, bool general_frame_only_constraint_flag_) : vui_parameters(vui_parameters_), #if MEDIAINFO_DEMUX AnnexB_Buffer(NULL), AnnexB_Buffer_Size(0), #endif //MEDIAINFO_DEMUX profile_space(profile_space_), profile_idc(profile_idc_), tier_flag(tier_flag_), level_idc(level_idc_), pic_width_in_luma_samples(pic_width_in_luma_samples_), pic_height_in_luma_samples(pic_height_in_luma_samples_), conf_win_left_offset(conf_win_left_offset_), conf_win_right_offset(conf_win_right_offset_), conf_win_top_offset(conf_win_top_offset_), conf_win_bottom_offset(conf_win_bottom_offset_), video_parameter_set_id(video_parameter_set_id_), chroma_format_idc(chroma_format_idc_), separate_colour_plane_flag(separate_colour_plane_flag_), log2_max_pic_order_cnt_lsb_minus4(log2_max_pic_order_cnt_lsb_minus4_), bit_depth_luma_minus8(bit_depth_luma_minus8_), bit_depth_chroma_minus8(bit_depth_chroma_minus8_), general_progressive_source_flag(general_progressive_source_flag_), general_interlaced_source_flag(general_interlaced_source_flag_), general_frame_only_constraint_flag(general_frame_only_constraint_flag_) { } ~seq_parameter_set_struct() { delete vui_parameters; //vui_parameters=NULL; #if MEDIAINFO_DEMUX delete[] AnnexB_Buffer; #endif //MEDIAINFO_DEMUX } private: seq_parameter_set_struct &operator=(const seq_parameter_set_struct &v); seq_parameter_set_struct(); }; typedef vector seq_parameter_set_structs; //Structures - pic_parameter_set struct pic_parameter_set_struct { #if MEDIAINFO_DEMUX int8u* AnnexB_Buffer; size_t AnnexB_Buffer_Size; #endif //MEDIAINFO_DEMUX int8u seq_parameter_set_id; int8u num_ref_idx_l0_default_active_minus1; int8u num_ref_idx_l1_default_active_minus1; int8u num_extra_slice_header_bits; bool dependent_slice_segments_enabled_flag; //Constructor/Destructor 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 num_extra_slice_header_bits_, bool dependent_slice_segments_enabled_flag_) : #if MEDIAINFO_DEMUX AnnexB_Buffer(NULL), AnnexB_Buffer_Size(0), #endif //MEDIAINFO_DEMUX seq_parameter_set_id(seq_parameter_set_id_), num_ref_idx_l0_default_active_minus1(num_ref_idx_l0_default_active_minus1_), num_ref_idx_l1_default_active_minus1(num_ref_idx_l1_default_active_minus1_), num_extra_slice_header_bits(num_extra_slice_header_bits_), dependent_slice_segments_enabled_flag(dependent_slice_segments_enabled_flag_) { } ~pic_parameter_set_struct() { #if MEDIAINFO_DEMUX delete[] AnnexB_Buffer; #endif //MEDIAINFO_DEMUX } private: pic_parameter_set_struct &operator=(const pic_parameter_set_struct &v); pic_parameter_set_struct(); }; typedef vector pic_parameter_set_structs; //Streams management void Streams_Fill(); void Streams_Fill(vector::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(); bool Demux_Transcode_Iso14496_15_to_AnnexB; #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 slice_segment_layer(); void slice_layer(); void video_parameter_set(); void seq_parameter_set(); void pic_parameter_set(); void access_unit_delimiter(); void end_of_seq(); void end_of_bitstream(); void filler_data(); void sei(); void sei_message(int32u &seq_parameter_set_id); void sei_message_buffering_period(int32u &seq_parameter_set_id, int32u payloadSize); void sei_message_buffering_period_xxl(seq_parameter_set_struct::vui_parameters_struct::xxl_common* xxL_Common, bool irap_cpb_params_present_flag, seq_parameter_set_struct::vui_parameters_struct::xxl* xxl); void sei_message_pic_timing(int32u &seq_parameter_set_id, int32u payloadSize); void sei_message_user_data_unregistered(int32u payloadSize); void sei_message_user_data_unregistered_Ateme(int32u payloadSize); void sei_message_user_data_unregistered_x265(int32u payloadSize); void sei_message_active_parameter_sets(); void sei_message_decoded_picture_hash(int32u payloadSize); //Packets - SubElements void slice_segment_header(); void profile_tier_level(int8u maxNumSubLayersMinus1); void short_term_ref_pic_sets(int8u num_short_term_ref_pic_sets); void vui_parameters(std::vector::iterator video_parameter_set_Item, seq_parameter_set_struct::vui_parameters_struct* &vui_parameters_Item); void hrd_parameters(bool commonInfPresentFlag, int8u maxNumSubLayersMinus1, seq_parameter_set_struct::vui_parameters_struct::xxl_common* &xxL_Common, seq_parameter_set_struct::vui_parameters_struct::xxl* &NAL, seq_parameter_set_struct::vui_parameters_struct::xxl* &VCL); void sub_layer_hrd_parameters(seq_parameter_set_struct::vui_parameters_struct::xxl_common* xxL_Common, int8u bit_rate_scale, int8u cpb_size_scale, int32u cpb_cnt_minus1, seq_parameter_set_struct::vui_parameters_struct::xxl* &hrd_parameters_Item); void scaling_list_data(); //Packets - Specific void VPS_SPS_PPS(); void VPS_SPS_PPS_FromMatroska(); //Streams struct stream { bool Searching_Payload; stream() : Searching_Payload(false) { } }; vector Streams; //Replacement of File__Analyze buffer const int8u* Buffer_ToSave; size_t Buffer_Size_ToSave; //parameter_sets video_parameter_set_structs video_parameter_sets; seq_parameter_set_structs seq_parameter_sets; pic_parameter_set_structs pic_parameter_sets; //File specific int8u lengthSizeMinusOne; //File specific size_t IFrame_Count; //Temp Ztring Encoded_Library; Ztring Encoded_Library_Name; Ztring Encoded_Library_Version; Ztring Encoded_Library_Date; Ztring Encoded_Library_Settings; int32u chroma_format_idc; int32u slice_pic_parameter_set_id; int32u slice_type; int8u nuh_layer_id; int8u profile_space; int8u profile_idc; int8u level_idc; bool tier_flag; bool general_progressive_source_flag; bool general_interlaced_source_flag; bool general_frame_only_constraint_flag; bool RapPicFlag; bool first_slice_segment_in_pic_flag; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Dirac.cpp0000664000000000000000000010357212652076434020707 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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-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 MediaInfoLib/Source/MediaInfo/Video/File_Lagarith.h0000664000000000000000000000245412652076434021062 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_Vc3.cpp0000664000000000000000000005743012652076434020321 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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" #if defined(MEDIAINFO_CDP_YES) #include "MediaInfo/Text/File_Cdp.h" #endif //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- const bool Vc3_FromCID_IsSupported (int32u CompressionID) { switch (CompressionID) { case 1235 : case 1237 : case 1238 : case 1241 : case 1242 : case 1243 : case 1250 : case 1251 : case 1252 : case 1253 : case 1256 : case 1258 : case 1259 : case 1260 : return true; default : return false; } } //--------------------------------------------------------------------------- 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 1244 : return 606208; case 1250 : return 458752; case 1251 : return 458752; case 1252 : return 303104; case 1253 : return 188416; case 1256 : return 1835008; case 1258 : return 212992; case 1259 : return 417792; case 1260 : return 417792; 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 int8u Vc3_SBD_FromCID (int32u CompressionID) { switch (CompressionID) { case 1237 : case 1238 : case 1242 : case 1243 : case 1251 : case 1252 : case 1253 : case 1258 : case 1259 : case 1260 : return 8; case 1235 : case 1241 : case 1250 : case 1256 : return 10; default : return 0; } } //--------------------------------------------------------------------------- const char* Vc3_FFC[4]= { "", "Progressive", "Interlaced", "Interlaced", }; //--------------------------------------------------------------------------- const char* Vc3_FFC_ScanOrder[4]= { "", "", "TFF", "BFF", }; //--------------------------------------------------------------------------- const char* Vc3_FFE[2]= { "Interlaced", "Progressive", }; //--------------------------------------------------------------------------- const char* Vc3_SST[2]= { "Progressive", "Interlaced", }; //--------------------------------------------------------------------------- const char* Vc3_SST_FromCID (int32u CompressionID) { switch (CompressionID) { case 1235 : case 1237 : case 1238 : case 1250 : case 1251 : case 1252 : case 1253 : return Vc3_SST[0]; case 1241 : case 1242 : case 1243 : return Vc3_SST[1]; default : return ""; } } //--------------------------------------------------------------------------- const int16u Vc3_SPL_FromCID (int32u CompressionID) { switch (CompressionID) { case 1250 : case 1251 : case 1252 : return 1280; case 1235 : case 1237 : case 1238 : case 1241 : case 1242 : case 1243 : case 1253 : return 1920; default : return 0; } } //--------------------------------------------------------------------------- const int16u Vc3_ALPF_PerFrame_FromCID (int32u CompressionID) { switch (CompressionID) { case 1250 : case 1251 : case 1252 : return 720; case 1235 : case 1237 : case 1238 : case 1241 : case 1242 : case 1243 : case 1253 : return 1080; default : return 0; } } //--------------------------------------------------------------------------- const char* Vc3_CLR[8]= { "YUV", "RGB", "", "", "", "", "", "", }; //--------------------------------------------------------------------------- const char* Vc3_CLR_FromCID (int32u CompressionID) { switch (CompressionID) { case 1235 : case 1237 : case 1238 : case 1241 : case 1242 : case 1243 : case 1250 : case 1251 : case 1252 : case 1253 : case 1258 : case 1259 : case 1260 : return Vc3_CLR[0]; case 1256 : return Vc3_CLR[1]; default : return ""; } }; //--------------------------------------------------------------------------- const char* Vc3_SSC[2]= { "4:2:2", "4:4:4", }; //--------------------------------------------------------------------------- const char* Vc3_SSC_FromCID (int32u CompressionID) { switch (CompressionID) { case 1235 : case 1237 : case 1238 : case 1241 : case 1242 : case 1243 : case 1250 : case 1251 : case 1252 : case 1253 : case 1258 : case 1259 : case 1260 : return Vc3_SSC[0]; case 1256 : return Vc3_SSC[1]; default : return ""; } }; //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Vc3::File_Vc3() :File__Analyze() { //Configuration MustSynchronize=true; //In Frame_Count_Valid=2; FrameRate=0; //Parsers #if defined(MEDIAINFO_CDP_YES) Cdp_Parser=NULL; #endif //defined(MEDIAINFO_CDP_YES) //Temp FFC_FirstFrame=(int8u)-1; } //--------------------------------------------------------------------------- File_Vc3::~File_Vc3() { #if defined(MEDIAINFO_CDP_YES) delete Cdp_Parser; //Cdp_Parser=NULL; #endif //defined(MEDIAINFO_CDP_YES) } //*************************************************************************** // 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 && Vc3_CompressedFrameSize(CID)) Fill(Stream_Video, 0, Video_BitRate, Vc3_CompressedFrameSize(CID)*8*FrameRate, 0); Fill(Stream_Video, 0, Video_Format_Version, __T("Version ")+Ztring::ToZtring(HVN)); if (Vc3_FromCID_IsSupported(CID)) { if (Vc3_SPL_FromCID(CID)) Fill(Stream_Video, 0, Video_Width, Vc3_SPL_FromCID(CID)); if (Vc3_ALPF_PerFrame_FromCID(CID)) Fill(Stream_Video, 0, Video_Height, Vc3_ALPF_PerFrame_FromCID(CID)); if (Vc3_SBD_FromCID(CID)) Fill(Stream_Video, 0, Video_BitDepth, Vc3_SBD_FromCID(CID)); Fill(Stream_Video, 0, Video_ScanType, Vc3_SST_FromCID(CID)); Fill(Stream_Video, 0, Video_ColorSpace, Vc3_CLR_FromCID(CID)); if (!strcmp(Vc3_CLR_FromCID(CID), "YUV")) // YUV Fill(Stream_Video, 0, Video_ChromaSubsampling, Vc3_SSC_FromCID(CID)); } else { Fill(Stream_Video, 0, Video_Width, SPL); Fill(Stream_Video, 0, Video_Height, ALPF*(SST?2:1)); Fill(Stream_Video, 0, Video_BitDepth, Vc3_SBD(SBD)); Fill(Stream_Video, 0, Video_ScanType, Vc3_SST[SST]); Fill(Stream_Video, 0, Video_ColorSpace, Vc3_CLR[CLR]); if (CLR==0) // YUV Fill(Stream_Video, 0, Video_ChromaSubsampling, Vc3_SSC[SSC]); } if (FFC_FirstFrame!=(int8u)-1) Fill(Stream_Video, 0, Video_ScanOrder, Vc3_FFC_ScanOrder[FFC_FirstFrame]); } //--------------------------------------------------------------------------- void File_Vc3::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; StreamPosCount_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("VC-3 / Nexio user data / ")+MuxingMode, true); } Ztring LawRating=Cdp_Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Cdp_Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } #endif //defined(MEDIAINFO_CDP_YES) } //*************************************************************************** // 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]==0x00)) { Buffer_Offset+=2; while (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]==0x00) { 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); size_t Size=Vc3_CompressedFrameSize(CompressionID); if (!Size) { if (!IsSub) { Reject(); return false; } Size=Buffer_Size; //Hoping that the packet is complete. TODO: add a flag in the container parser saying if the packet is complete } 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 - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Vc3::Read_Buffer_Unsynched() { #if defined(MEDIAINFO_CDP_YES) if (Cdp_Parser) Cdp_Parser->Open_Buffer_Unsynch(); #endif //defined(MEDIAINFO_CDP_YES) } //*************************************************************************** // 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"); size_t Size=Vc3_CompressedFrameSize(CompressionID); if (!Size) { if (!IsSub) { Reject(); return; } Size=Buffer_Size; //Hoping that the packet is complete. TODO: add a flag in the container parser saying if the packet is complete } Header_Fill_Size(Size); } //--------------------------------------------------------------------------- void File_Vc3::Data_Parse() { //Parsing if (Status[IsFilled]) { Skip_XX(Element_Size, "Data"); } else { Element_Info1(Frame_Count+1); HeaderPrefix(); if (HVN <= 2) { CodingControlA(); Skip_XX(16, "Reserved"); ImageGeometry(); Skip_XX( 5, "Reserved"); CompressionID(); CodingControlB(); Skip_XX( 3, "Reserved"); TimeCode(); Skip_XX(38, "Reserved"); UserData(); Skip_XX(640-Element_Offset, "ToDo"); } Skip_XX(Element_Size-Element_Offset, "Data"); } FILLING_BEGIN(); Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (FrameRate) { FrameInfo.PTS=FrameInfo.DTS+=float64_int64s(1000000000/FrameRate); FrameInfo.DUR=float64_int64s(1000000000/FrameRate); } else { FrameInfo.PTS=FrameInfo.DTS=FrameInfo.DUR=(int64u)-1; } if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) { Fill("VC-3"); if (!IsSub && Config->ParseSpeed<1) Finish("VC-1"); } FILLING_END(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Vc3::HeaderPrefix() { //Parsing Element_Begin1("Header Prefix"); int32u Data; Get_B4 (Data, "Magic number"); Get_B1 (HVN, "HVN: Header Version Number"); Element_End0(); FILLING_BEGIN(); if (Data==0x00000280LL) Accept("VC-3"); else Reject("VC-3"); FILLING_END(); } //--------------------------------------------------------------------------- void File_Vc3::CodingControlA() { //Parsing Element_Begin1("Coding Control A"); BS_Begin(); int8u FFC; Mark_0(); Mark_0(); Mark_0(); Mark_0(); Mark_0(); Mark_0(); Get_S1 (2, FFC, "Field/Frame Count"); Param_Info1(Vc3_FFC[FFC]); Mark_1(); Mark_0(); if (HVN==1) Mark_0(); else Skip_SB( "MACF: Macroblock Adaptive Control Flag"); 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(); FILLING_BEGIN(); if (FFC_FirstFrame==(int8u)-1) FFC_FirstFrame=FFC; FILLING_END(); } //--------------------------------------------------------------------------- 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"); Param_Info1(Vc3_SST[SST]); 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; FILLING_END(); } //--------------------------------------------------------------------------- void File_Vc3::CodingControlB() { //Parsing Element_Begin1("Coding Control B"); BS_Begin(); Info_S1(1, FFE, "Field/Frame Count"); Param_Info1(Vc3_FFE[FFE]); if (HVN==1) { Mark_0(); SSC=false; } else { Get_SB (SSC, "SSC: Sub Sampling Control"); Param_Info1(Vc3_SSC[SSC]); } Mark_0(); Mark_0(); Mark_0(); if (HVN==1) { Mark_0(); Mark_0(); Mark_0(); CLR=0; } else { Get_S1 (3, CLR, "CLR: Color"); Param_Info1(Vc3_CLR[CLR]); } BS_End(); Element_End0(); } //--------------------------------------------------------------------------- void File_Vc3::TimeCode() { //Parsing Element_Begin1("Time Code"); bool TCP; BS_Begin(); Get_SB ( TCP, "TCP: Time Code Present"); Mark_0(); Mark_0(); Mark_0(); Mark_0(); Mark_0(); Mark_0(); Mark_0(); BS_End(); if (TCP) { Skip_B8( "Time Code"); } else Skip_B8( "Junk"); Element_End0(); } //--------------------------------------------------------------------------- void File_Vc3::UserData() { //Parsing Element_Begin1("User Data"); int8u UserDataLabel; BS_Begin(); Get_S1 (4, UserDataLabel, "User Data Label"); Mark_0(); Mark_0(); Mark_0(); Mark_1(); BS_End(); switch (UserDataLabel) { case 0x00: Skip_XX(260, "Reserved"); break; case 0x08: UserData_8(); break; default : Skip_XX(260, "Reserved for future use"); } Element_End0(); } //--------------------------------------------------------------------------- void File_Vc3::UserData_8() { if (Element_Offset + 0x104 < Element_Size && Buffer[Buffer_Offset + (size_t)Element_Offset + 0xBA] == 0x96 && Buffer[Buffer_Offset + (size_t)Element_Offset + 0xBB] == 0x69) { Skip_XX(0xBA, "Nexio private data?"); #if defined(MEDIAINFO_CDP_YES) if (Cdp_Parser==NULL) { Cdp_Parser=new File_Cdp; Open_Buffer_Init(Cdp_Parser); Frame_Count_Valid=300; } if (!Cdp_Parser->Status[IsFinished]) { ((File_Cdp*)Cdp_Parser)->AspectRatio=16.0/9.0; Open_Buffer_Continue(Cdp_Parser, Buffer + Buffer_Offset + (size_t)Element_Offset, 0x49); } Element_Offset+=0x49; Skip_B1( "Nexio private data?"); #else //MEDIAINFO_CDP_YES Skip_XX(0x4A "CDP data"); #endif //MEDIAINFO_CDP_YES } else Skip_XX(260, "Nexio private data?"); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_VC3_* MediaInfoLib/Source/MediaInfo/Video/File_Dirac.h0000664000000000000000000000533312652076434020350 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 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 MediaInfoLib/Source/MediaInfo/Video/File_Theora.h0000664000000000000000000000240112652076434020541 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_Lagarith.cpp0000664000000000000000000000677012652076434021422 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 : case 0x04 : 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 0x05 : Fill(Stream_Video, 0, Video_ColorSpace, "Y"); break; case 0x06 : case 0x07 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); break; case 0x08 : case 0x09 : Fill(Stream_Video, 0, Video_ColorSpace, "RGBA"); break; case 0x0A : 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 MediaInfoLib/Source/MediaInfo/Video/File_Mpegv.cpp0000664000000000000000000053600012652076434020737 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //*************************************************************************** // Infos (Global) //*************************************************************************** //--------------------------------------------------------------------------- #if defined(MEDIAINFO_MPEGV_YES) || defined(MEDIAINFO_MPEG4V_YES) || defined(MEDIAINFO_AVC_YES) || defined(MEDIAINFO_MPEG4_YES) || defined(MEDIAINFO_PRORES_YES) //--------------------------------------------------------------------------- namespace MediaInfoLib { #include "ZenLib/Conf.h" using namespace ZenLib; //--------------------------------------------------------------------------- extern const char* Mpegv_colour_primaries(int8u colour_primaries) { switch (colour_primaries) { case 1 : return "BT.709"; case 4 : return "BT.470 System M"; case 5 : return "BT.601 PAL"; case 6 : return "BT.601 NTSC"; case 7 : return "SMPTE 240M"; //Same as BT.601 NTSC case 8 : return "Generic film"; case 9 : return "BT.2020"; //Added in HEVC default : return ""; } } //--------------------------------------------------------------------------- extern const char* Mpegv_transfer_characteristics(int8u transfer_characteristics) { switch (transfer_characteristics) { case 1 : return "BT.709"; //Same as BT.609 case 4 : return "BT.470 System M"; case 5 : return "BT.470 System B, BT.470 System G"; case 6 : return "BT.601"; case 7 : return "SMPTE 240M"; case 8 : return "Linear"; case 9 : return "Logarithmic (100:1)"; //Added in MPEG-4 Visual case 10 : return "Logarithmic (316.22777:1)"; //Added in MPEG-4 Visual case 11 : return "IEC 61966-2-4"; //Added in AVC case 12 : return "BT.1361 extended colour gamut system"; //Added in AVC case 13 : return "sYCC"; //Added in HEVC case 14 : return "BT.2020"; //Added in HEVC case 15 : return "BT.2020"; //Added in HEVC default : return ""; } } //--------------------------------------------------------------------------- extern const char* Mpegv_matrix_coefficients(int8u matrix_coefficients) { switch (matrix_coefficients) { case 0 : return "RGB"; //Added in AVC case 1 : return "BT.709"; case 4 : return "FCC 73.682"; case 5 : return "BT.601"; case 6 : return "BT.601"; case 7 : return "SMPTE 240M"; case 8 : return "YCgCo"; //Added in AVC case 9 : return "BT.2020 non-constant"; //Added in HEVC case 10 : return "BT.2020 constant"; //Added in HEVC default : return ""; } } } //NameSpace #if !MEDIAINFO_ADVANCED const int64u Config_VariableGopDetection_Occurences=4; #endif // MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #endif //... //--------------------------------------------------------------------------- //*************************************************************************** // 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 float64 Mpegv_frame_rate[16]= { (float64) 0, (float64)24000/(float64)1001, (float64)24, (float64)25, (float64)30000/(float64)1001, (float64)30, (float64)50, (float64)60000/(float64)1001, (float64)60, (float64) 0, (float64) 0, (float64) 0, (float64) 0, (float64) 0, (float64) 0, (float64) 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 "MediaInfo/TimeCode.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 #endif //defined(MEDIAINFO_CDP_YES) #if defined(MEDIAINFO_AFDBARDATA_YES) #include "MediaInfo/Video/File_AfdBarData.h" #include #endif //defined(MEDIAINFO_AFDBARDATA_YES) #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #include using namespace ZenLib; using namespace std; #undef FILLING_BEGIN #define FILLING_BEGIN() \ while (Element_Offset=0.3?512:2; FrameIsAlwaysComplete=false; TimeCodeIsNotTrustable=false; #if defined(MEDIAINFO_ANCILLARY_YES) Ancillary=NULL; #endif //defined(MEDIAINFO_ANCILLARY_YES) #if MEDIAINFO_ADVANCED InitDataNotRepeated_Optional=false; #endif // MEDIAINFO_ADVANCED //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; Frame_Count_LastIFrame=(int64u)-1; 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 #if MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS Slices_Count=0; Has_sequence_header=false; Has_sequence_extension=false; #endif // MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS } //--------------------------------------------------------------------------- File_Mpegv::~File_Mpegv() { for (size_t Pos=0; PosStatus[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++) { //Saving previous Muxing mode Ztring MuxingMode=Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode"); 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_Pos2Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=(*Text_Positions[Text_Positions_Pos].Parser)->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); if (IsNewStream) { #if defined(MEDIAINFO_DTVCCTRANSPORT_YES) if ((*Text_Positions[Text_Positions_Pos].Parser)==GA94_03_Parser) MuxingMode=__T("A/53 / ")+Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode"); #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES) #if defined(MEDIAINFO_SCTE20_YES) if ((*Text_Positions[Text_Positions_Pos].Parser)==Scte_Parser) MuxingMode=Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode"); #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES) #if defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES) if ((*Text_Positions[Text_Positions_Pos].Parser)==Cdp_Parser) MuxingMode=__T("Ancillary data / ")+Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode"); #endif //defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES) } Fill(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode", MuxingMode, true); } } } } //--------------------------------------------------------------------------- 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 if (Mpegv_frame_rate[frame_rate_code]) Fill(Stream_Video, StreamPos_Last, Video_FrameRate, Mpegv_frame_rate[frame_rate_code] * (frame_rate_extension_n + 1) / (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 && progressive_frame_Count!=Frame_Count+1) //In case the stream is cut before a slice { //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 || progressive_frame_Count==Frame_Count+1) { 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"); } if (!(PictureStructure_Field && PictureStructure_Frame) && !(!PictureStructure_Field && !PictureStructure_Frame)) Fill(Stream_Video, 0, Video_Format_Settings_PictureStructure, PictureStructure_Field?"Field":"Frame"); } std::string TempRef; for (size_t Pos=0; PosHasPictureCoding) { TempRef+=TemporalReference[Pos]->top_field_first?"T":"B"; TempRef+=TemporalReference[Pos]->repeat_first_field?"3":"2"; } 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); } } } //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]); if (colour_description) { Fill(Stream_Video, 0, Video_colour_description_present, "Yes"); Fill(Stream_Video, 0, Video_colour_primaries, Mpegv_colour_primaries(colour_primaries)); Fill(Stream_Video, 0, Video_transfer_characteristics, Mpegv_transfer_characteristics(transfer_characteristics)); Fill(Stream_Video, 0, Video_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_General, 0, General_Encoded_Library, Library); Fill(Stream_General, 0, General_Encoded_Library_Name, Library_Name); Fill(Stream_General, 0, General_Encoded_Library_Version, Library_Version); } //Delay if (group_start_FirstPass && !TimeCodeIsNotTrustable && Time_Begin_Seconds!=Error) { 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"); Fill(Stream_Video, 0, Video_Delay_DropFrame, group_start_drop_frame_flag?"Yes":"No"); if (group_start_closed_gop_Closed+group_start_closed_gop_Open>=4 && ((group_start_closed_gop && group_start_closed_gop_Closed==1) || group_start_closed_gop_Closed==0 || group_start_closed_gop_Open==0)) // Testing a couple of GOPs, and coherant { if (group_start_closed_gop_Open) { Fill(Stream_Video, 0, "Gop_OpenClosed", "Open"); if (group_start_closed_gop) Fill(Stream_Video, 0, "Gop_OpenClosed_FirstFrame", "Closed"); } else { Fill(Stream_Video, 0, "Gop_OpenClosed", "Closed"); } } Fill(Stream_Video, 0, Video_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); if (IsSub) Fill(Stream_Video, 0, Video_TimeCode_Source, "Group of pictures header"); } //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[0xB3].Searching_TimeStamp_End=true; 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); Ztring LawRating=GA94_06_Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=GA94_06_Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } #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) { if (PTS_End_temporal_reference::iterator Temp=picture_coding_types.begin(); Temp!=picture_coding_types.end(); ++Temp) { if (Temp->second>MaxCount) { MaxCount=Temp->second; MaxCount_type=Temp->first; } Total+=Temp->second; } if (Total>=4) { int64u Count=0; for (std::map::iterator Temp=picture_coding_types.begin(); Temp!=picture_coding_types.end(); ++Temp) if (Temp->first!=MaxCount_type) Count+=Temp->second; if (CountM_Max) M_Max=M; } else M=1; Ztring GOP; if (M_Max>1) { GOP+=__T("M="); GOP+=Ztring::ToZtring(M_Max); GOP+=__T(", "); } GOP+=__T("N="); GOP+=Ztring::ToZtring(MaxCount_type.size()); Fill(Stream_Video, 0, Video_Format_Settings_GOP, GOP, true); } else Fill(Stream_Video, 0, Video_Format_Settings_GOP, "Variable", Unlimited, true, true); } } //InitDataNotRepeated #if MEDIAINFO_ADVANCED if (!InitDataNotRepeated_Optional && Config_InitDataNotRepeated_Occurences!=(int64u)-1) Fill(Stream_Video, 0, "InitDataRepeated", InitDataNotRepeated>=Config_InitDataNotRepeated_Occurences?"No":"Yes", Unlimited, true, true); #endif // MEDIAINFO_ADVANCED //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_IBIUSAGE 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_IBIUSAGE } //*************************************************************************** // 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 (!Header_Parser_QuickSearch()) return false; #if MEDIAINFO_IBIUSAGE if ((Ibi_SliceParsed && (Buffer[Buffer_Offset+3]==0x00)) || Buffer[Buffer_Offset+3]==0xB3) // picture_start without sequence_header or sequence_header { if (Buffer_Offset+6>Buffer_Size) return false; bool RandomAccess=(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_IBIUSAGE //We continue return true; } //--------------------------------------------------------------------------- void File_Mpegv::Synched_Init() { //Temp BVOP_Count=0; progressive_frame_Count=0; Interlaced_Top=0; Interlaced_Bottom=0; PictureStructure_Field=0; PictureStructure_Frame=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; temporal_reference_Max=0; aspect_ratio_information=0; frame_rate_code=0; profile_and_level_indication_profile=(int8u)-1; profile_and_level_indication_level=(int8u)-1; chroma_format=1; //Default is 4:2: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; PTS_End_temporal_reference=(int16u)-1; bit_rate_value_IsValid=false; profile_and_level_indication_escape=false; colour_description=false; low_delay=false; RefFramesCount=0; BVOPsSinceLastRefFrames=0; temporal_reference_LastIFrame=0; tc=0; IFrame_IsParsed=false; IFrame_Count=0; #if MEDIAINFO_IBIUSAGE Ibi_SliceParsed=true; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_ADVANCED Config_VariableGopDetection_Occurences=MediaInfoLib::Config.VariableGopDetection_Occurences_Get(); Config_VariableGopDetection_GiveUp=MediaInfoLib::Config.VariableGopDetection_GiveUp_Get(); InitDataNotRepeated=0; Config_InitDataNotRepeated_Occurences=MediaInfoLib::Config.InitDataNotRepeated_Occurences_Get(); Config_InitDataNotRepeated_GiveUp=MediaInfoLib::Config.InitDataNotRepeated_GiveUp_Get(); #endif //MEDIAINFO_ADVANCED //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; } if (IsSub && ParserIDs[0]==MediaInfo_Parser_Mxf) //TODO: find a better way to demux, currently implemeted this way because we need I-frame status info from MXF { Demux_Offset=Buffer_Size; Demux_IntermediateItemFound=true; } else { while (Demux_Offset+4<=Buffer_Size) { //Synchronizing while(Demux_Offset+4<=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[Demux_Offset-1]==0x00) Demux_Offset--; } if (Demux_Offset+4>Buffer_Size) { if (File_Offset+Buffer_Size==File_Size) Demux_Offset=Buffer_Size; break; } if (Demux_IntermediateItemFound) { bool MustBreak; switch (Buffer[Demux_Offset+3]) { case 0x00 : case 0xB3 : MustBreak=true; break; default : Demux_Offset+=3; 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]) { if (Config->Demux_EventWasSent) return false; File_Mpegv* MI=new File_Mpegv; Element_Code=(int64u)-1; Open_Buffer_Init(MI); Open_Buffer_Continue(MI, Buffer, Buffer_Size); bool IsOk=MI->Status[IsAccepted]; delete MI; if (!IsOk) 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; picture_coding_types_Current.clear(); #if MEDIAINFO_IBIUSAGE Ibi_SliceParsed=true; #endif //MEDIAINFO_IBIUSAGE #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; PosOpen_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-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; #if MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS if (start_code==0xB3) // sequence_header { // Has_sequence_header=true; } if (start_code==0xB5) // extension_start { if (Buffer_Offset+5>Buffer_Size) return false; if ((Buffer[Buffer_Offset+4]&0xF0)==0x10) // sequence_extension Has_sequence_extension=true; } #endif // MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS //Synchronizing Buffer_Offset+=4; Synched=false; if (!Synchronize()) { UnSynched_IsNotJunk=true; return false; } if (Buffer_Offset+4>Buffer_Size) { UnSynched_IsNotJunk=true; 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_OffsetParseSpeed<=0.5)) { if (MustExtendParsingDuration && Frame_CountSizeToAnalyse_Begin*10+SizeToAnalyse_End*10 && File_Offset+Buffer_Offset+Element_Offset>SizeToAnalyse_Begin*10 && File_Offset+Buffer_Offset+Element_Offset=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; //picture_coding_types if (picture_coding_type==1) //I-Frame { if (!picture_coding_types_Current.empty()) { picture_coding_types[picture_coding_types_Current]++; #if MEDIAINFO_ADVANCED // Testing if we must give up if (Config_VariableGopDetection_GiveUp && picture_coding_types.size()>1) { int64u MaxCount=0; string MaxCount_type; for (std::map::iterator Temp=picture_coding_types.begin(); Temp!=picture_coding_types.end(); ++Temp) if (Temp->second>MaxCount) { MaxCount=Temp->second; MaxCount_type=Temp->first; } int64u Count=0; for (std::map::iterator Temp=picture_coding_types.begin(); Temp!=picture_coding_types.end(); ++Temp) if (Temp->first!=MaxCount_type) Count+=Temp->second; if (Count>=Config_VariableGopDetection_Occurences) Config->ParseSpeed=0; // Give up } #endif // MEDIAINFO_ADVANCED } picture_coding_types_Current='I'; } else if (!picture_coding_types_Current.empty()) //If an I-Frame is already found picture_coding_types_Current+=Mpegv_picture_coding_type[picture_coding_type]; //Detecting streams with only I-Frames if (picture_coding_type==1 && picture_coding_type_Old==1 && !FirstFieldFound) 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() { //Encryption management if (CA_system_ID_MustSkipSlices) { //Is not decodable Finish("MPEG Video"); return; } 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(); int64u tc_ToAdd=tc/((progressive_sequence || picture_structure==3)?1:2); //Progressive of Frame //Timestamp if (!TimeCodeIsNotTrustable && group_start_FirstPass && (Time_Begin_Seconds==Error || (Frame_Count<16 && Time_Current_Seconds*FrameRate+Time_Current_Frames+temporal_referenceAspectRatio=MPEG_Version==1?Mpegv_aspect_ratio1[aspect_ratio_information]:Mpegv_aspect_ratio2[aspect_ratio_information]; (*Ancillary)->FrameRate=FrameRate; if ((*Ancillary)->PTS_DTS_Needed) (*Ancillary)->FrameInfo.DTS=FrameInfo.DTS; 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 (!MustExtendParsingDuration && 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++; 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_EndPTS_End || (PTS_End>1000000000 && FrameInfo.PTS+tc_ToAdd<=PTS_End-1000000000)) //More than current PTS_End or less than current PTS_End minus 1 second (there is a problem?) { PTS_End=FrameInfo.PTS+tc_ToAdd; PTS_End_temporal_reference=temporal_reference; } if (low_delay) FrameInfo.PTS+=tc_ToAdd; else FrameInfo.PTS=(int64u)-1; //With repeat_first_field option, it is impossible to know what is the next 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 (!MustExtendParsingDuration && IFrame_Count==8) Frame_Count_Valid=Frame_Count; //We have enough frames if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) { Fill("MPEG Video"); if (File_Size==(int64u)-1) Finish("MPEG Video"); else if (!IsSub && 2*(File_Offset+Buffer_Size+SizeToAnalyse_End)ParseSpeed<1.0) { Open_Buffer_Unsynch(); GoToFromEnd(SizeToAnalyse_End); } } //Skipping slices (if already unpacketized) #if MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer && Buffer_TotalBytes+Buffer_Offset=Config_InitDataNotRepeated_Occurences) Config->ParseSpeed=0; // Give up } #endif // MEDIAINFO_ADVANCED } #endif // MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS #if MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS //Packets Has_sequence_header=false; Has_sequence_extension=false; #endif // MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS 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=¯oblock_type_I; break; case 2: macroblock_type_X=¯oblock_type_P; break; case 3: macroblock_type_X=¯oblock_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¯oblock_quant)); Element_Info1(__T("macroblock_motion_forward=")+Ztring::ToZtring(macroblock_type¯oblock_motion_forward)); Element_Info1(__T("macroblock_motion_backward=")+Ztring::ToZtring(macroblock_type¯oblock_motion_backward)); Element_Info1(__T("macroblock_pattern=")+Ztring::ToZtring(macroblock_type¯oblock_pattern)); Element_Info1(__T("macroblock_intra=")+Ztring::ToZtring(macroblock_type¯oblock_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¯oblock_intra && concealment_motion_vectors) frame_motion_type=2; if (macroblock_type¯oblock_motion_forward || macroblock_type¯oblock_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¯oblock_intra || macroblock_type¯oblock_pattern)) Skip_SB( "dct_type"); Element_Trace_End0(); if (macroblock_type¯oblock_quant) Skip_S1(5, "quantiser_scale_code"); if (macroblock_type¯oblock_motion_forward || (macroblock_type¯oblock_intra && concealment_motion_vectors)) slice_start_macroblock_motion_vectors(false); if (macroblock_type¯oblock_motion_backward) slice_start_macroblock_motion_vectors(true); if (macroblock_type¯oblock_intra && concealment_motion_vectors) Mark_1(); if (macroblock_type¯oblock_pattern) slice_start_macroblock_coded_block_pattern(); for (int8u i=0; i "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; } 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¯oblock_intra) && !((macroblock_type¯oblock_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¯oblock_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=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_Offset3 && 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; } #if MEDIAINFO_DEMUX int8u Demux_Level_Save=Demux_Level; Demux_Level=8; //Ancillary Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream); Demux_Level=Demux_Level_Save; #endif // MEDIAINFO_DEMUX 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+8IsValid || 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_PosIsValid || 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_PosAspectRatio=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; PosScte.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; } #if MEDIAINFO_DEMUX int8u Demux_Level_Save=Demux_Level; Demux_Level=8; //Ancillary Demux(TemporalReference[Scte20_Pos]->Scte[Pos]->Data, TemporalReference[Scte20_Pos]->Scte[Pos]->Size, ContentType_MainStream); Demux_Level=Demux_Level_Save; #endif // MEDIAINFO_DEMUX 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+8IsValid || 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_PosIsValid || 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_PosFormat=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); } #if MEDIAINFO_DEMUX int8u Demux_Level_Save=Demux_Level; Demux_Level=8; //Ancillary Demux(TemporalReference[GA94_03_Pos]->GA94_03->Data, TemporalReference[GA94_03_Pos]->GA94_03->Size, ContentType_MainStream); Demux_Level=Demux_Level_Save; #endif // MEDIAINFO_DEMUX #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) GA94_03_Parser->ServiceDescriptors=ServiceDescriptors; #endif ((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"); //Reset display_horizontal_size=0; display_vertical_size=0; //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_OffsetElement_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_Adapt(); //TODO: this line should not exist but some streams do not have group_start and/or do not start from temporal_reference 0, fast and dirty patch //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=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; PictureStructure_Field++; } } else { progressive_frame_Count++; if (top_field_first) Interlaced_Top++; else Interlaced_Bottom++; PictureStructure_Frame++; 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(); temporal_reference_Adapt(); //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_End_Seconds=(size_t)-1; TimeCode_FirstFrame.clear(); 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; TimeCode_FirstFrame+=('0'+Hours/10); TimeCode_FirstFrame+=('0'+Hours%10); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Minutes/10); TimeCode_FirstFrame+=('0'+Minutes%10); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Seconds/10); TimeCode_FirstFrame+=('0'+Seconds%10); TimeCode_FirstFrame+=drop_frame_flag?';':':'; TimeCode_FirstFrame+=('0'+Frames/10); TimeCode_FirstFrame+=('0'+Frames%10); group_start_closed_gop_Closed=0; group_start_closed_gop_Open=0; } if (closed_gop) group_start_closed_gop_Closed++; else group_start_closed_gop_Open++; 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(); } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- // Packet "B8" void File_Mpegv::temporal_reference_Adapt() { //Temporal reference temporal_reference_Old=(int16u)-1; temporal_reference_Max=0; 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 #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) #if MEDIAINFO_ADVANCED bool InitDataNotRepeated_Optional; #endif // MEDIAINFO_ADVANCED //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(); //Helpers void temporal_reference_Adapt(); //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 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 Scte; std::vector 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 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_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_CDP_YES) File__Analyze* Cdp_Parser; bool Cdp_IsPresent; #endif //defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES) #if 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; string TimeCode_FirstFrame; size_t BVOP_Count; size_t progressive_frame_Count; size_t Interlaced_Top; size_t Interlaced_Bottom; size_t PictureStructure_Field; size_t PictureStructure_Frame; 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 int64u Frame_Count_LastIFrame; int32u bit_rate_value; float64 FrameRate; int16u horizontal_size_value; int16u vertical_size_value; int16u bit_rate_extension; int16u temporal_reference; int16u temporal_reference_Old; int16u temporal_reference_Max; 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; size_t group_start_closed_gop_Closed; size_t group_start_closed_gop_Open; 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; bool colour_description; bool low_delay; int8u RefFramesCount; int8u BVOPsSinceLastRefFrames; int16u temporal_reference_LastIFrame; int64u PTS_LastIFrame; int16u PTS_End_temporal_reference; int64u tc; bool IFrame_IsParsed; size_t IFrame_Count; std::map picture_coding_types; //per picture_coding_type value ("IPBB..."), updated at each I-frame std::string picture_coding_types_Current; //Current picture_coding_type value ("IPBB..."), updated at each frame #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_IBIUSAGE bool Ibi_SliceParsed; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_ADVANCED int64u InitDataNotRepeated; int64u Config_InitDataNotRepeated_Occurences; bool Config_InitDataNotRepeated_GiveUp; int64u Config_VariableGopDetection_Occurences; bool Config_VariableGopDetection_GiveUp; #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS size_t Slices_Count; bool Has_sequence_header; bool Has_sequence_extension; #endif // MEDIAINFO_ADVANCED || MEDIAINFO_EVENTS }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Ffv1.h0000664000000000000000000001772212652076434020135 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about FFV1 files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Ffv1H #define MediaInfo_Ffv1H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class RangeCoder //*************************************************************************** const size_t states_size=32; const size_t state_transitions_size=256; typedef int8u states[states_size]; typedef int8u state_transitions[state_transitions_size]; typedef int8u **states_context_plane; const size_t MAX_PLANES=4; const size_t MAX_QUANT_TABLES=8; const size_t MAX_CONTEXT_INPUTS=5; class RangeCoder { public : RangeCoder(const int8u* Buffer, size_t Buffer_Size, const state_transitions default_state_transition); void AssignStateTransitions (const state_transitions new_state_transition); bool get_rac(int8u* States); int32u get_symbol_u(int8u* States); int32s get_symbol_s(int8u* States); int16u Current; int16u Mask; state_transitions zero_state; public : //Temp state_transitions one_state; const int8u* Buffer_Cur; const int8u* Buffer_End; }; //*************************************************************************** // Class Slice //*************************************************************************** const int32u RUN_MODE_STOP = 0; const int32u RUN_MODE_PROCESSING = 1; const int32u RUN_MODE_INTERRUPTED = 2; class Slice { public: Slice() : run_index(0), run_mode(RUN_MODE_STOP), sample_buffer(NULL) { for (size_t i = 0; i < MAX_QUANT_TABLES; ++i) plane_states[i] = NULL; for (size_t i = 0; i < MAX_PLANES; ++i) contexts[i] = NULL; } ~Slice() { if (sample_buffer) { delete [] sample_buffer; sample_buffer = NULL; } contexts_clean(); } void sample_buffer_new(size_t size) { if (sample_buffer) { delete [] sample_buffer; sample_buffer = NULL; } sample_buffer = new int16s[size]; } void run_index_init() { run_index=0; } void run_mode_init() { run_mode=RUN_MODE_STOP; } //TEMP int32u x; int32u y; int32u w; int32u h; int32u run_index; int32u run_mode; int32s run_segment_length; int16s* sample_buffer; struct Context { static const int32u N0; // Determined threshold to divide N and B static const int32s Cmax; // Storage limitation, C never upper than 127 static const int32s Cmin; // Storage limitation, C never below than -128 int32s N; // Count where the context was encountred int32s B; // Accumulated sum of corrected prediction residuals int32s A; // Accumulated sum of the absolute corrected prediction residuals (St + Nt) int32s C; // Correction value }; typedef Context* ContextPtr; ContextPtr contexts[MAX_PLANES]; states_context_plane plane_states[MAX_QUANT_TABLES]; // HELPER void contexts_init(int32u plane_count, int32u quant_table_index[MAX_PLANES], int32u context_count[MAX_QUANT_TABLES]); void contexts_clean(); }; //*************************************************************************** // Class File_Ffv1 //*************************************************************************** class File_Ffv1 : public File__Analyze { public : //Constructor/Destructor File_Ffv1(); ~File_Ffv1(); //Input int32u Width; int32u Height; private : //Streams management void Streams_Accept(); //Buffer - Global void Read_Buffer_OutOfBand(); void Read_Buffer_Continue(); //Elements void FrameHeader(); void slice(states &States); void slice_header(states &States); int32u CRC_Compute(size_t Size); int32s get_symbol_with_bias_correlation(Slice::Context* context); void rgb(); void plane(int32u pos); void line(int pos, int16s *sample[2]); int32s line_range_coder(int32s pos, int32s context); int32s line_adaptive_symbol_by_symbol(size_t x, int32s pos, int32s context); void read_quant_tables(int i); void read_quant_table(int i, int j, size_t scale); void copy_plane_states_to_slice(int8u plane_count); //Range coder #if MEDIAINFO_TRACE void Get_RB (states &States, bool &Info, const char* Name); void Get_RU (states &States, int32u &Info, const char* Name); void Get_RS (states &States, int32s &Info, const char* Name); void Get_RS (int8u* &States, int32s &Info, const char* Name); void Skip_RC(states &States, const char* Name); void Skip_RU(states &States, const char* Name); void Skip_RS(states &States, const char* Name); #define Info_RC(_STATE, _INFO, _NAME) bool _INFO; Get_RB (_STATE, _INFO, _NAME) #define Info_RU(_STATE, _INFO, _NAME) int32u _INFO; Get_RU (_STATE, _INFO, _NAME) #define Info_RS(_STATE, _INFO, _NAME) int32s _INFO; Get_RS (_STATE, _INFO, _NAME) #else //MEDIAINFO_TRACE void Get_RB_ (states &States, bool &Info); void Get_RU_ (states &States, int32u &Info); void Get_RS_ (states &States, int32s &Info); void Get_RS_ (int8u* &States, int32s &Info); #define Get_RB(Bits, Info, Name) Get_RB_(Bits, Info) #define Get_RU(Bits, Info, Name) Get_RU_(Bits, Info) #define Get_RS(Bits, Info, Name) Get_RS_(Bits, Info) void Skip_RC_(states &States); void Skip_RU_(states &States); void Skip_RS_(states &States); #define Skip_RC(Bits, Name) Skip_RC_(Bits) #define Skip_RU(Bits, Name) Skip_RU_(Bits) #define Skip_RS(Bits, Name) Skip_RS_(Bits) #define Info_RC(_STATE, _INFO, _NAME) Skip_RC_(_STATE) #define Info_RU(_STATE, _INFO, _NAME) Skip_RU_(_STATE) #define Info_RS(_STATE, _INFO, _NAME) Skip_RS_(_STATE) #endif //MEDIAINFO_TRACE RangeCoder* RC; Slice *slices; Slice *current_slice; //Temp bool ConfigurationRecordIsPresent; int32u context_count[MAX_QUANT_TABLES]; int32u len_count[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS]; int16s quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]; int32u quant_table_index[MAX_PLANES]; int32u quant_table_count; int32u version; int32u micro_version; int32u error_correction; int32u num_h_slices; int32u num_v_slices; int32u chroma_h_shift; int32u chroma_v_shift; int8u coder_type; int8u colorspace_type; int8u bits_per_sample; bool keyframe; bool chroma_planes; bool alpha_plane; state_transitions state_transitions_table; //TEMP static const int32u PREFIX_MAX = 12; //limit int8u bits_max; states_context_plane plane_states[MAX_QUANT_TABLES]; int32s get_median_number(int32s one, int32s two, int32s three); int32s predict(int16s *current, int16s *current_top); void update_correlation_value_and_shift(Slice::Context *c); int32s golomb_rice_decode(int k); void plane_states_clean(states_context_plane states[MAX_QUANT_TABLES]); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Mpeg4v.cpp0000664000000000000000000022745012652076434021031 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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) || defined(MEDIAINFO_MXF_YES) //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #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", }; //--------------------------------------------------------------------------- const char* Mpegv_colour_primaries(int8u colour_primaries); const char* Mpegv_transfer_characteristics(int8u transfer_characteristics); const char* Mpegv_matrix_coefficients(int8u matrix_coefficients); //*************************************************************************** // 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; colour_description=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+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 (!Header_Parser_QuickSearch()) return false; #if MEDIAINFO_IBIUSAGE bool RandomAccess=Buffer[Buffer_Offset+3]==0xB0; //SequenceHeader if (RandomAccess) Ibi_Add(); #endif //MEDIAINFO_IBIUSAGE //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; colour_primaries=(int8u)-1; transfer_characteristics=(int8u)-1; matrix_coefficients=(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)33; 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 (colour_description) { Fill(Stream_Video, 0, Video_colour_description_present, "Yes"); Fill(Stream_Video, 0, Video_colour_primaries, Mpegv_colour_primaries(colour_primaries)); Fill(Stream_Video, 0, Video_transfer_characteristics, Mpegv_transfer_characteristics(transfer_characteristics)); Fill(Stream_Video, 0, Video_matrix_coefficients, Mpegv_matrix_coefficients(matrix_coefficients)); } 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=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 : Demux_Offset+=3; 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]) { if (Config->Demux_EventWasSent) return false; File_Mpeg4v* MI=new File_Mpeg4v; Element_Code=(int64u)-1; Open_Buffer_Init(MI); Open_Buffer_Continue(MI, Buffer, Buffer_Size); bool IsOk=MI->Status[IsAccepted]; delete MI; if (!IsOk) 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-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()) { UnSynched_IsNotJunk=true; return false; } if (Buffer_Offset+4>Buffer_Size) { UnSynched_IsNotJunk=true; 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_resolution10) 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=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_Offset3 && 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; PosFrame_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=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 { EVENT_BEGIN (Video, SliceInfo, 0) 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; EVENT_END () } #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 MediaInfoLib/Source/MediaInfo/Video/File_Y4m.h0000664000000000000000000000257312652076434020002 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_Vc1.cpp0000664000000000000000000013114012652076434020306 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX #include #include "base64.h" #endif //MEDIAINFO_DEMUX 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 }; //--------------------------------------------------------------------------- int32u Vc1_FrameRate_enr(int8u Code) { switch (Code) { case 0x01 : return 24000; case 0x02 : return 25000; case 0x03 : return 30000; case 0x04 : return 50000; case 0x05 : return 60000; case 0x06 : return 48000; case 0x07 : return 72000; default : return 0; } } //--------------------------------------------------------------------------- int16u Vc1_FrameRate_dr(int8u Code) { switch (Code) { case 0x01 : return 1000; case 0x02 : return 1001; default : return 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; #if MEDIAINFO_DEMUX InitData_Buffer=NULL; InitData_Buffer_Size=0; #endif //MEDIAINFO_DEMUX } //--------------------------------------------------------------------------- File_Vc1::~File_Vc1() { #if MEDIAINFO_DEMUX delete[] InitData_Buffer; #endif //MEDIAINFO_DEMUX } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Vc1::Streams_Accept() { //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); } //--------------------------------------------------------------------------- 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 Ztring Profile; if (profile!=(int8u)-1) Profile=Vc1_Profile[profile]; if (profile==3 && level!=(int8u)-1) 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_ColorSpace, "YUV"); 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::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; PosPTS_Begin) Fill(Stream_Video, 0, Video_Duration, float64_int64s(((float64)(PTS_End-PTS_Begin))/1000000)); #if MEDIAINFO_IBIUSAGE 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_IBIUSAGE } //*************************************************************************** // 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+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 (!Header_Parser_QuickSearch()) return false; #if MEDIAINFO_IBIUSAGE bool RandomAccess=Buffer[Buffer_Offset+3]==0x0F; //SequenceHeader if (RandomAccess) Ibi_Add(); #endif //MEDIAINFO_IBIUSAGE //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=(int8u)-1; level=(int8u)-1; colordiff_format=1; //Default is 4:2: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[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 : Demux_Offset+=3; 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 #if MEDIAINFO_DEMUX if (InitData_Buffer_Size && Buffer[Buffer_Offset+3]==0x0F) //First SequenceHeader { //Searching begin of frame (after SequenceHeader/EntryPointHeader) size_t Header_End=4; for (; Header_EndDemux_InitData_Get()) { case 0 : //In demux event break; //Will be done in the first demux event case 1 : //In field { std::string Data_Raw((const char*)(Buffer+Buffer_Offset), (size_t)(Header_End-Buffer_Offset)); std::string Data_Base64(Base64::encode(Data_Raw)); Fill(Stream_Video, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[Stream_Video][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } delete[] InitData_Buffer; InitData_Buffer=NULL; InitData_Buffer_Size=0; } #endif //MEDIAINFO_DEMUX 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-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()) { UnSynched_IsNotJunk=true; return false; } if (Buffer_Offset+4>Buffer_Size) { UnSynched_IsNotJunk=true; 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=Frame_Count_Valid) { Fill("VC-1"); if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1) Finish("VC-1"); } #if MEDIAINFO_EVENTS { EVENT_BEGIN (Video, SliceInfo, 0) 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; EVENT_END () } #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; PosDemux_InitData_Get()) { case 0 : //In demux event break; //Will be done in the first demux event case 1 : //In field { std::string Data_Raw((char*)InitData_Buffer_Temp, InitData_Buffer_Temp_Size); std::string Data_Base64(Base64::encode(Data_Raw)); Fill(Stream_Video, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[Stream_Video][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } delete[] InitData_Buffer; InitData_Buffer=NULL; delete[] InitData_Buffer_Temp; //InitData_Buffer_Temp=NULL; InitData_Buffer_Size=0; } #endif //MEDIAINFO_DEMUX 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 using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** const char* HuffYUV_ColorSpace (int16u BitCount) { switch (BitCount&0xFFF8) { case 8 : case 16 : return "YUV"; case 24 : return "RGB"; case 32 : return "RGBA"; default : return ""; } } const char* HuffYUV_ChromaSubsampling (int16u BitCount) { switch (BitCount&0xFFF8) { case 8 : return "4:2:0"; case 16 : return "4:2:2"; default : return ""; } } const string HuffYUV_ColorSpace(bool rgb, bool chroma, bool alpha) { string ToReturn; if (rgb) { ToReturn="RGB"; } else { ToReturn=chroma?"YUV":"Y"; } if (alpha) ToReturn+='A'; return ToReturn; } const char* HuffYUV_method (int16u BitCount, int8u method) { switch (BitCount&0x0007) { case 0 : switch (method) { case 0xFE : return "old"; case 0 : return "left"; case 1 : return "gradient"; case 2 : return "median"; case 64 : return "left with decorrelation"; case 65 : return "gradient with decorrelation"; default : return ""; } case 1 : return "left"; case 2 : return "left with decorrelation"; case 3 : switch (BitCount&0xFFF8) { case 16 : return "gradient"; case 24 : case 32 : return "gradient with decorrelation"; default : return ""; } case 4 : return "median"; default : return ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_HuffYuv::File_HuffYuv() :File__Analyze() { //Configuration ParserName=__T("HuffYUV"); IsRawStream=true; //In IsOutOfBandData=false; BitCount=0; Height=0; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_HuffYuv::Streams_Accept() { Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Format, "HuffYUV"); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_HuffYuv::Read_Buffer_Continue() { Accept(); if (IsOutOfBandData) { FrameHeader(); } else if (Frame_Count==0) Fill(Stream_Video, 0, Video_Format_Version, "Version 1"); Skip_XX(Element_Size-Element_Offset, "Other data"); Frame_Count++; Finish(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_HuffYuv::FrameHeader() { //Version if (Element_Size<4) { Reject(); return; } int8u Version; if (Buffer[3]==0) { Version=Element_Size>4?2:1; } else Version=3; //Parsing int8u bpp_override=0, chroma_v_shift=0, chroma_h_shift=0, interlace; bool alpha=false, chroma=false, rgb=false; Element_Begin1("method"); BS_Begin(); Skip_SB( "unknown"); Skip_SB( "decorrelate"); Skip_S1(6, "predictor"); Element_End0(); if (Version<=2) { Get_S1 (8, bpp_override, "bpp_override"); } else { Get_S1 (4, bpp_override, "bit_depth"); Param_Info2(bpp_override+1, "bits"); Get_S1 (2, chroma_v_shift, "chroma_v_shift"); Get_S1 (2, chroma_h_shift, "chroma_h_shift"); } Skip_SB( "unknown"); Skip_SB( "context"); Get_S1 (2, interlace, "interlace"); if (Version<=2) { Skip_S1(4, "unknown"); Skip_S1(8, "zero"); } else { Skip_SB( "unknown"); Get_SB ( alpha, "alpha"); Get_SB ( rgb, "rgb"); if (rgb) Skip_SB( "unused"); else Get_SB ( chroma, "chroma"); Skip_S1(7, "unused"); Skip_SB( "version 3+ indicator"); } BS_End(); if (Frame_Count==0) { if (Version==2) { //BiCount; if (bpp_override) BitCount=bpp_override; Fill(Stream_Video, 0, Video_BitDepth, 8); } else { Fill(Stream_Video, 0, Video_BitDepth, bpp_override+1); } Fill(Stream_Video, 0, Video_Format_Version, __T("Version ")+Ztring::ToZtring(Version)); if (Version==2) { Fill(Stream_Video, 0, Video_ColorSpace, HuffYUV_ColorSpace(BitCount)); Fill(Stream_Video, 0, Video_ChromaSubsampling, HuffYUV_ChromaSubsampling(BitCount)); } else { Fill(Stream_Video, 0, Video_ColorSpace, HuffYUV_ColorSpace(rgb, chroma, alpha)); string ChromaSubsampling; if (chroma) { switch (chroma_h_shift) { case 0 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:4:4"; break; default: ; } break; case 1 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:2:2"; break; case 1 : ChromaSubsampling="4:2:0"; break; default: ; } break; case 2 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:1:1"; break; case 1 : ChromaSubsampling="4:1:0"; break; case 2 : ChromaSubsampling="4:1:0 (4x4)"; break; default: ; } break; default: ; } } if (!ChromaSubsampling.empty() && alpha) ChromaSubsampling+=":4"; Fill(Stream_Video, 0, Video_ChromaSubsampling, ChromaSubsampling); } switch (interlace) { case 0 : if (Version<=2 && Height) Fill(Stream_Video, 0, Video_ScanType, Height>288?"Interlaced":"Progressive"); break; case 1 : Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); break; case 2 : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); break; default:; } } } } //NameSpace #endif //MEDIAINFO_HUFFYUV_YES MediaInfoLib/Source/MediaInfo/Video/File_Hevc.cpp0000664000000000000000000037756212652076434020566 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_HEVC_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Video/File_Hevc.h" #include #include #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** //--------------------------------------------------------------------------- const int8u Hevc_SubWidthC[]= { 1, 2, 2, 1, }; //--------------------------------------------------------------------------- const int8u Hevc_SubHeightC[]= { 1, 2, 1, 1, }; //--------------------------------------------------------------------------- const char* Hevc_tier_flag(bool tier_flag) { return tier_flag ? "High" : "Main"; } //--------------------------------------------------------------------------- const char* Hevc_profile_idc(int32u profile_idc) { switch (profile_idc) { case 0 : return "No profile"; case 1 : return "Main"; case 2 : return "Main 10"; case 3 : return "Main Still"; default : return ""; } } //--------------------------------------------------------------------------- const char* Hevc_chroma_format_idc(int8u chroma_format_idc) { switch (chroma_format_idc) { case 0 : return "monochrome"; case 1 : return "4:2:0"; case 2 : return "4:2:2"; case 3 : return "4:4:4"; default : return "Unknown"; } } //--------------------------------------------------------------------------- const char* Hevc_pic_type[]= { "I", "I, P", "I, P, B", "", "", "", "", "", "", "", }; //--------------------------------------------------------------------------- const char* Hevc_slice_type(int32u slice_type) { switch (slice_type) { case 0 : return "P"; case 1 : return "B"; case 2 : return "I"; default: return ""; } }; //--------------------------------------------------------------------------- extern const char* Mpegv_colour_primaries(int8u colour_primaries); extern const char* Mpegv_transfer_characteristics(int8u transfer_characteristics); extern const char* Mpegv_matrix_coefficients(int8u matrix_coefficients); //--------------------------------------------------------------------------- extern const int8u Avc_PixelAspectRatio_Size; extern const float32 Avc_PixelAspectRatio[]; extern const char* Avc_video_format[]; extern const char* Avc_video_full_range[]; //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Hevc::File_Hevc() { //Config #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Hevc; 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?16:16; //Note: should be replaced by "512:2" when I-frame/GOP detection is OK FrameIsAlwaysComplete=false; MustParse_VPS_SPS_PPS=false; MustParse_VPS_SPS_PPS_FromMatroska=false; MustParse_VPS_SPS_PPS_FromFlv=false; SizedBlocks=false; //File specific lengthSizeMinusOne=(int8u)-1; } //--------------------------------------------------------------------------- File_Hevc::~File_Hevc() { } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Hevc::Streams_Fill() { if (MustParse_VPS_SPS_PPS_FromFlv) return; if (Count_Get(Stream_Video)==0) Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Format, "HEVC"); Fill(Stream_Video, 0, Video_Codec, "HEVC"); for (std::vector::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); //Library name Fill(Stream_General, 0, General_Encoded_Library, Encoded_Library); Fill(Stream_General, 0, General_Encoded_Library_Name, Encoded_Library_Name); Fill(Stream_General, 0, General_Encoded_Library_Version, Encoded_Library_Version); Fill(Stream_General, 0, General_Encoded_Library_Settings, Encoded_Library_Settings); 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); } //--------------------------------------------------------------------------- void File_Hevc::Streams_Fill(std::vector::iterator seq_parameter_set_Item) { int32u Width = (*seq_parameter_set_Item)->pic_width_in_luma_samples; int32u Height= (*seq_parameter_set_Item)->pic_height_in_luma_samples; int32u CropUnitX=Hevc_SubWidthC [(*seq_parameter_set_Item)->ChromaArrayType()]; int32u CropUnitY=Hevc_SubHeightC[(*seq_parameter_set_Item)->ChromaArrayType()]; Width -=((*seq_parameter_set_Item)->conf_win_left_offset+(*seq_parameter_set_Item)->conf_win_right_offset)*CropUnitX; Height-=((*seq_parameter_set_Item)->conf_win_top_offset +(*seq_parameter_set_Item)->conf_win_bottom_offset)*CropUnitY; Ztring Profile; if ((*seq_parameter_set_Item)->profile_space==0) { if ((*seq_parameter_set_Item)->profile_idc) Profile=Ztring().From_Local(Hevc_profile_idc((*seq_parameter_set_Item)->profile_idc)); if ((*seq_parameter_set_Item)->level_idc) { if ((*seq_parameter_set_Item)->profile_idc) Profile+=__T('@'); Profile+=__T('L')+Ztring().From_Number(((float)(*seq_parameter_set_Item)->level_idc)/30, ((*seq_parameter_set_Item)->level_idc%10)?1:0); Profile+=__T('@'); Profile+=Ztring().From_Local(Hevc_tier_flag((*seq_parameter_set_Item)->tier_flag)); } } 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); if ((*seq_parameter_set_Item)->conf_win_left_offset || (*seq_parameter_set_Item)->conf_win_right_offset) Fill(Stream_Video, StreamPos_Last, Video_Stored_Width, (*seq_parameter_set_Item)->pic_width_in_luma_samples); if ((*seq_parameter_set_Item)->conf_win_top_offset || (*seq_parameter_set_Item)->conf_win_bottom_offset) Fill(Stream_Video, StreamPos_Last, Video_Stored_Height, (*seq_parameter_set_Item)->pic_height_in_luma_samples); Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); Fill(Stream_Video, 0, Video_Colorimetry, Hevc_chroma_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); if ((*seq_parameter_set_Item)->vui_parameters) { if ((*seq_parameter_set_Item)->vui_parameters->timing_info_present_flag) { 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); } if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_info_present_flag) { float64 PixelAspectRatio = 1; if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idcvui_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; Fill(Stream_Video, 0, Video_PixelAspectRatio, PixelAspectRatio, 3, true); Fill(Stream_Video, 0, Video_DisplayAspectRatio, Width*PixelAspectRatio/Height, 3, true); //More precise } //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]); Fill(Stream_Video, 0, Video_colour_range, Avc_video_full_range[(*seq_parameter_set_Item)->vui_parameters->video_full_range_flag]); if ((*seq_parameter_set_Item)->vui_parameters->colour_description_present_flag) { Fill(Stream_Video, 0, Video_colour_description_present, "Yes"); Fill(Stream_Video, 0, Video_colour_primaries, Mpegv_colour_primaries((*seq_parameter_set_Item)->vui_parameters->colour_primaries)); Fill(Stream_Video, 0, Video_transfer_characteristics, Mpegv_transfer_characteristics((*seq_parameter_set_Item)->vui_parameters->transfer_characteristics)); Fill(Stream_Video, 0, Video_matrix_coefficients, Mpegv_matrix_coefficients((*seq_parameter_set_Item)->vui_parameters->matrix_coefficients)); } } } } //--------------------------------------------------------------------------- void File_Hevc::Streams_Finish() { } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Hevc::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_Hevc::Synchronize() { //Synchronizing size_t Buffer_Offset_Min=Buffer_Offset; 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-1]==0x00) Buffer_Offset--; } if (Buffer_Offset>Buffer_Offset_Min && 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; if (File_Offset==0 && Buffer_Offset==0 && (Buffer[3]==0xE0 || Buffer[3]==0xFE)) { //It is from MPEG-PS Reject(); return false; } //Synched is OK Synched=true; return true; } //--------------------------------------------------------------------------- bool File_Hevc::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+6>Buffer_Size) return false; //Quick test of synchro if (Buffer[Buffer_Offset ]!=0x00 || Buffer[Buffer_Offset+1]!=0x00 || (Buffer[Buffer_Offset+2]!=0x01 && (Buffer[Buffer_Offset+2]!=0x00 || Buffer[Buffer_Offset+3]!=0x01))) { Synched=false; return true; } //Quick search if (!Header_Parser_QuickSearch()) return false; //We continue return true; } //*************************************************************************** // Buffer - Demux //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX bool File_Hevc::Demux_UnpacketizeContainer_Test() { const int8u* Buffer_Temp=NULL; size_t Buffer_Temp_Size=0; bool RandomAccess=true; //Default, in case of problem if ((MustParse_VPS_SPS_PPS || SizedBlocks) && Demux_Transcode_Iso14496_15_to_AnnexB) { if (MustParse_VPS_SPS_PPS) return true; //Wait for SPS and PPS //Random access check RandomAccess=false; //Computing final size size_t TranscodedBuffer_Size=0; while (Buffer_Offset+lengthSizeMinusOne+1+1<=Buffer_Size) { size_t Size; switch (lengthSizeMinusOne) { case 0: Size=Buffer[Buffer_Offset]; TranscodedBuffer_Size+=2; break; case 1: Size=BigEndian2int16u(Buffer+Buffer_Offset); TranscodedBuffer_Size++; break; case 2: Size=BigEndian2int24u(Buffer+Buffer_Offset); break; case 3: Size=BigEndian2int32u(Buffer+Buffer_Offset); TranscodedBuffer_Size--; break; default: return true; //Problem } Size+=lengthSizeMinusOne+1; //Coherency checking if (Size==0 || Buffer_Offset+Size>Buffer_Size || (Buffer_Offset+Size!=Buffer_Size && Buffer_Offset+Size+lengthSizeMinusOne+1>Buffer_Size)) Size=Buffer_Size-Buffer_Offset; //Random access check if (!RandomAccess && Buffer_Offset+lengthSizeMinusOne+1>1; //nal_unit_type RapPicFlag=Element_Code>=16 && Element_Code<=23; if (RapPicFlag) Skip_SB( "no_output_of_prior_pics_flag"); Get_UE ( slice_pic_parameter_set_id, "slice_pic_parameter_set_id"); int8u num_extra_slice_header_bits=(int8u)-1; std::vector::iterator pic_parameter_set_Item; if (MustParse_VPS_SPS_PPS_FromFlv) num_extra_slice_header_bits=0; // We bet it is old, so without num_extra_slice_header_bits else if (!(slice_pic_parameter_set_id>=pic_parameter_sets.size() || (*(pic_parameter_set_Item=pic_parameter_sets.begin()+slice_pic_parameter_set_id))==NULL)) { num_extra_slice_header_bits=(*pic_parameter_set_Item)->num_extra_slice_header_bits; } if (num_extra_slice_header_bits!=(int8u)-1) { int32u slice_type; Skip_S1(num_extra_slice_header_bits, "slice_reserved_flags"); Get_UE (slice_type, "slice_type"); switch (slice_type) { case 2 : case 7 : RandomAccess=true; } } } BS_End(); } TranscodedBuffer_Size+=Size; Buffer_Offset+=Size; } Buffer_Offset=0; //Adding VPS/SPS/PPS sizes if (RandomAccess) { for (video_parameter_set_structs::iterator Data_Item=video_parameter_sets.begin(); Data_Item!=video_parameter_sets.end(); ++Data_Item) TranscodedBuffer_Size+=(*Data_Item)->AnnexB_Buffer_Size; for (seq_parameter_set_structs::iterator Data_Item=seq_parameter_sets.begin(); Data_Item!=seq_parameter_sets.end(); ++Data_Item) TranscodedBuffer_Size+=(*Data_Item)->AnnexB_Buffer_Size; for (pic_parameter_set_structs::iterator Data_Item=pic_parameter_sets.begin(); Data_Item!=pic_parameter_sets.end(); ++Data_Item) TranscodedBuffer_Size+=(*Data_Item)->AnnexB_Buffer_Size; } //Copying int8u* TranscodedBuffer=new int8u[TranscodedBuffer_Size+100]; size_t TranscodedBuffer_Pos=0; if (RandomAccess) { for (video_parameter_set_structs::iterator Data_Item=video_parameter_sets.begin(); Data_Item!=video_parameter_sets.end(); ++Data_Item) { std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, (*Data_Item)->AnnexB_Buffer, (*Data_Item)->AnnexB_Buffer_Size); TranscodedBuffer_Pos+=(*Data_Item)->AnnexB_Buffer_Size; } for (seq_parameter_set_structs::iterator Data_Item=seq_parameter_sets.begin(); Data_Item!=seq_parameter_sets.end(); ++Data_Item) { std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, (*Data_Item)->AnnexB_Buffer, (*Data_Item)->AnnexB_Buffer_Size); TranscodedBuffer_Pos+=(*Data_Item)->AnnexB_Buffer_Size; } for (pic_parameter_set_structs::iterator Data_Item=pic_parameter_sets.begin(); Data_Item!=pic_parameter_sets.end(); ++Data_Item) { std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, (*Data_Item)->AnnexB_Buffer, (*Data_Item)->AnnexB_Buffer_Size); TranscodedBuffer_Pos+=(*Data_Item)->AnnexB_Buffer_Size; } } while (Buffer_OffsetBuffer_Size || (Buffer_Offset+Size!=Buffer_Size && Buffer_Offset+Size+lengthSizeMinusOne+1>Buffer_Size)) Size=Buffer_Size-Buffer_Offset; std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, Buffer+Buffer_Offset, Size); TranscodedBuffer_Pos+=Size; Buffer_Offset+=Size; } Buffer_Offset=0; Buffer_Temp=Buffer; Buffer=TranscodedBuffer; Buffer_Temp_Size=Buffer_Size; Buffer_Size=TranscodedBuffer_Size; Demux_Offset=Buffer_Size; } else { bool zero_byte=Buffer[Buffer_Offset+2]==0x00; if (!(((Buffer[Buffer_Offset+(zero_byte?4:3)]&0x40)==0 && (Buffer[Buffer_Offset+(zero_byte?6:5)]&0x80)!=0x80) || (Buffer[Buffer_Offset+(zero_byte?4:3)]&0x7E)==(38<<1))) { 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[Demux_Offset-1]==0x00) Demux_Offset--; } if (Demux_Offset+6>Buffer_Size) { if (File_Offset+Buffer_Size==File_Size) Demux_Offset=Buffer_Size; break; } zero_byte=Buffer[Demux_Offset+2]==0x00; int8u nal_unit_type=Buffer[Demux_Offset+(zero_byte?4:3)]>>1; bool Next; switch (nal_unit_type) { case 0 : case 1 : case 2 : case 3 : case 4 : case 5 : case 6 : case 7 : case 8 : case 9 : case 16 : case 17 : case 18 : case 19 : case 20 : case 21 : if (Demux_IntermediateItemFound) { if (Buffer[Demux_Offset+(zero_byte?6:5)]&0x80) Next=true; else Next=false; } else { Next=false; Demux_IntermediateItemFound=true; } break; case 32 : case 33 : case 34 : case 35 : if (Demux_IntermediateItemFound) Next=true; else Next=false; break; default : Next=false; } if (Next) { Demux_IntermediateItemFound=false; break; } Demux_Offset++; } if (Demux_Offset+6>Buffer_Size && !FrameIsAlwaysComplete && File_Offset+Buffer_SizeDemux_EventWasSent) return false; File_Hevc* MI=new File_Hevc; Element_Code=(int64u)-1; Open_Buffer_Init(MI); Open_Buffer_Continue(MI, Buffer, Buffer_Size); bool IsOk=MI->Status[IsAccepted]; delete MI; if (!IsOk) return false; } if (IFrame_Count || RandomAccess) { int64u PTS_Temp=FrameInfo.PTS; if (!IsSub) FrameInfo.PTS=(int64u)-1; Demux_UnpacketizeContainer_Demux(RandomAccess); if (!IsSub) FrameInfo.PTS=PTS_Temp; } else Demux_UnpacketizeContainer_Demux_Clear(); if (Buffer_Temp) { Demux_TotalBytes-=Buffer_Size; Demux_TotalBytes+=Buffer_Temp_Size; delete[] Buffer; Buffer=Buffer_Temp; Buffer_Size=Buffer_Temp_Size; } return true; } #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- void File_Hevc::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; //Status IFrame_Count=0; //Temp //Default values Streams.resize(0x100); Streams[32].Searching_Payload=true; //video_parameter_set Streams[35].Searching_Payload=true; //access_unit_delimiter Streams[39].Searching_Payload=true; //sei for (int8u Pos=0xFF; Pos>=48; Pos--) Streams[Pos].Searching_Payload=true; //unspecified #if MEDIAINFO_DEMUX Demux_Transcode_Iso14496_15_to_AnnexB=Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get(); #endif //MEDIAINFO_DEMUX } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Hevc::Read_Buffer_Unsynched() { //Impossible to know TimeStamps now PTS_End=0; DTS_End=0; } //*************************************************************************** // Buffer - Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_Hevc::Header_Parse() { //Specific case if (MustParse_VPS_SPS_PPS) { Header_Fill_Size(Element_Size); Header_Fill_Code((int64u)-1, "Specific"); return; } //Parsing int8u nal_unit_type, nuh_temporal_id_plus1; 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 (6, nal_unit_type, "nal_unit_type"); Get_S1 (6, nuh_layer_id, "nuh_layer_id"); Get_S1 (3, nuh_temporal_id_plus1, "nuh_temporal_id_plus1"); BS_End(); if (!Header_Parser_Fill_Size()) { Element_WaitForMoreData(); return; } if (nuh_temporal_id_plus1==0) Trusted_IsNot("nuh_temporal_id_plus1"); } else { int32u Size; switch (lengthSizeMinusOne) { 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 (6, nal_unit_type, "nal_unit_type"); Get_S1 (6, nuh_layer_id, "nuh_layer_id"); Get_S1 (3, nuh_temporal_id_plus1, "nuh_temporal_id_plus1"); BS_End(); if (nuh_temporal_id_plus1==0) Trusted_IsNot("nuh_temporal_id_plus1"); FILLING_BEGIN(); Header_Fill_Size(Size?(Element_Offset-2+Size):(Buffer_Size-Buffer_Offset)); //If Size is 0, it is not normal, we skip the complete frame FILLING_END(); } //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_Hevc::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-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_Hevc::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 nal_unit_type; if (Buffer[Buffer_Offset+2]==0x00) nal_unit_type=(CC1(Buffer+Buffer_Offset+4)&0x7E)>>1; else nal_unit_type=(CC1(Buffer+Buffer_Offset+3)&0x7E)>>1; //Searching start if (Streams[nal_unit_type].Searching_Payload) return true; //Synchronizing Buffer_Offset+=4; Synched=false; if (!Synchronize()) { UnSynched_IsNotJunk=true; return false; } if (Buffer_Offset+6>Buffer_Size) { UnSynched_IsNotJunk=true; return false; } } Trusted_IsNot("HEVC, Synchronisation lost"); return Synchronize(); } //--------------------------------------------------------------------------- void File_Hevc::Data_Parse() { //Specific case if (Element_Code==(int64u)-1) { VPS_SPS_PPS(); return; } if (nuh_layer_id) { //Skip_XX(Element_Size, "(Extension)"); //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--; } //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 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-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 0 : case 1 : case 2 : case 3 : case 16 : case 17 : case 18 : case 19 : case 20 : case 21 : slice_segment_layer(); break; case 4 : case 5 : case 6 : case 7 : case 8 : case 9 : slice_layer(); break; case 32 : video_parameter_set(); break; case 33 : seq_parameter_set(); break; case 34 : pic_parameter_set(); break; case 35 : access_unit_delimiter(); break; case 36 : end_of_seq(); break; case 37 : end_of_bitstream(); break; case 38 : filler_data(); break; case 39 : case 40 : sei(); break; default : Skip_XX(Element_Size-Element_Offset, "Data"); if (Element_Code>=48) Trusted_IsNot("Unspecified"); } 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(); } #if MEDIAINFO_DEMUX if (Demux_Transcode_Iso14496_15_to_AnnexB) { if (Element_Code==32) { std::vector::iterator Data_Item=video_parameter_sets.begin(); if (Data_Item!=video_parameter_sets.end() && (*Data_Item)) { delete[] (*Data_Item)->AnnexB_Buffer; (*Data_Item)->AnnexB_Buffer_Size=(size_t)(Element_Size+5); (*Data_Item)->AnnexB_Buffer=new int8u[(*Data_Item)->AnnexB_Buffer_Size]; (*Data_Item)->AnnexB_Buffer[0]=0x00; (*Data_Item)->AnnexB_Buffer[1]=0x00; (*Data_Item)->AnnexB_Buffer[2]=0x01; (*Data_Item)->AnnexB_Buffer[3]=Buffer[Buffer_Offset-2]; (*Data_Item)->AnnexB_Buffer[4]=Buffer[Buffer_Offset-1]; std::memcpy((*Data_Item)->AnnexB_Buffer+5, Buffer+Buffer_Offset, (size_t)Element_Size); } } if (Element_Code==33) { std::vector::iterator Data_Item=seq_parameter_sets.begin(); if (Data_Item!=seq_parameter_sets.end() && (*Data_Item)) { delete[] (*Data_Item)->AnnexB_Buffer; (*Data_Item)->AnnexB_Buffer_Size=(size_t)(Element_Size+5); (*Data_Item)->AnnexB_Buffer=new int8u[(*Data_Item)->AnnexB_Buffer_Size]; (*Data_Item)->AnnexB_Buffer[0]=0x00; (*Data_Item)->AnnexB_Buffer[1]=0x00; (*Data_Item)->AnnexB_Buffer[2]=0x01; (*Data_Item)->AnnexB_Buffer[3]=Buffer[Buffer_Offset-2]; (*Data_Item)->AnnexB_Buffer[4]=Buffer[Buffer_Offset-1]; std::memcpy((*Data_Item)->AnnexB_Buffer+5, Buffer+Buffer_Offset, (size_t)Element_Size); } } if (Element_Code==34) { std::vector::iterator Data_Item=pic_parameter_sets.begin(); if (Data_Item!=pic_parameter_sets.end() && (*Data_Item)) { delete[] (*Data_Item)->AnnexB_Buffer; (*Data_Item)->AnnexB_Buffer_Size=(size_t)(Element_Size+5); (*Data_Item)->AnnexB_Buffer=new int8u[(*Data_Item)->AnnexB_Buffer_Size]; (*Data_Item)->AnnexB_Buffer[0]=0x00; (*Data_Item)->AnnexB_Buffer[1]=0x00; (*Data_Item)->AnnexB_Buffer[2]=0x01; (*Data_Item)->AnnexB_Buffer[3]=Buffer[Buffer_Offset-2]; (*Data_Item)->AnnexB_Buffer[4]=Buffer[Buffer_Offset-1]; std::memcpy((*Data_Item)->AnnexB_Buffer+5, Buffer+Buffer_Offset, (size_t)Element_Size); } } } #endif //MEDIAINFO_DEMUX //Trailing zeroes Element_Size=Element_Size_SaveBeforeZeroes; } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- // Packets void File_Hevc::slice_segment_layer() { #if MEDIAINFO_TRACE Element_Name("slice_segment_layer"); switch (Element_Code) { case 0 : case 1 : break; case 2 : case 3 : Element_Info("TSA"); break; case 16 : case 17 : case 18 : Element_Info("BLA"); break; case 19 : case 20 : Element_Info("IDR"); break; case 21 : Element_Info("CRA"); break; default: ; } #endif //MEDIAINFO_TRACE //Parsing RapPicFlag=Element_Code>=16 && Element_Code<=23; BS_Begin(); slice_segment_header(); BS_End(); Skip_XX(Element_Size-Element_Offset, "(ToDo)"); FILLING_BEGIN(); if (slice_pic_parameter_set_id==(int32u)-1) return; //Count of I-Frames if (first_slice_segment_in_pic_flag && (Element_Code==19 || Element_Code==20)) IFrame_Count++; if (first_slice_segment_in_pic_flag) { //Frame_Count Frame_Count++; if (IFrame_Count && Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; Frame_Count_InThisBlock++; //Filling only if not already done if (Frame_Count==1 && !Status[IsAccepted]) Accept("HEVC"); if (!Status[IsFilled]) { if (IFrame_Count>=8) Frame_Count_Valid=Frame_Count; //We have enough frames if (Frame_Count>=Frame_Count_Valid) { Fill("HEVC"); if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1.0) Finish("HEVC"); } } } FILLING_END(); } //--------------------------------------------------------------------------- // Packets void File_Hevc::slice_layer() { #if MEDIAINFO_TRACE Element_Name("slice_layer"); switch (Element_Code) { case 4 : case 5 : Element_Info("STSA"); break; case 6 : case 7 : Element_Info("RADL"); break; case 8 : case 9 : Element_Info("RASL"); break; default: ; } #endif //MEDIAINFO_TRACE //Parsing Skip_XX(Element_Size-Element_Offset, "(ToDo)"); } //--------------------------------------------------------------------------- // Packet "32" void File_Hevc::video_parameter_set() { Element_Name("video_parameter_set"); //Parsing int32u vps_num_layer_sets_minus1; int8u vps_video_parameter_set_id, vps_max_sub_layers_minus1, vps_max_layer_id; bool vps_temporal_id_nesting_flag, vps_sub_layer_ordering_info_present_flag; BS_Begin(); Get_S1 (4, vps_video_parameter_set_id, "vps_video_parameter_set_id"); if (MustParse_VPS_SPS_PPS_FromFlv) { BS_End(); Skip_XX(Element_Size-Element_Offset, "Data"); //Creating Data if (vps_video_parameter_set_id>=video_parameter_sets.size()) video_parameter_sets.resize(vps_video_parameter_set_id+1); std::vector::iterator Data_Item=video_parameter_sets.begin()+vps_video_parameter_set_id; delete *Data_Item; *Data_Item=new video_parameter_set_struct( 0 //TODO: check which code is intended here ); //NextCode NextCode_Clear(); NextCode_Add(33); //Autorisation of other streams Streams[33].Searching_Payload=true; //seq_parameter_set Streams[36].Searching_Payload=true; //end_of_seq Streams[37].Searching_Payload=true; //end_of_bitstream Streams[38].Searching_Payload=true; //filler_data return; } Skip_S1(2, "vps_reserved_three_2bits"); Skip_S1(6, "vps_reserved_zero_6bits"); Get_S1 (3, vps_max_sub_layers_minus1, "vps_max_sub_layers_minus1"); if (vps_max_sub_layers_minus1>6) { Trusted_IsNot("vps_max_sub_layers_minus1 not valid"); BS_End(); return; //Problem, not valid } Get_SB ( vps_temporal_id_nesting_flag, "vps_temporal_id_nesting_flag"); //if (vps_max_sub_layers_minus1==0 && !vps_temporal_id_nesting_flag) //{ // Trusted_IsNot("vps_temporal_id_nesting_flag not valid"); // BS_End(); // return; //Problem, not valid //} Skip_S2(16, "vps_reserved_0xffff_16bits"); profile_tier_level(vps_max_sub_layers_minus1); Get_SB ( vps_sub_layer_ordering_info_present_flag, "vps_sub_layer_ordering_info_present_flag"); for (int32u SubLayerPos=(vps_sub_layer_ordering_info_present_flag?0:vps_max_sub_layers_minus1); SubLayerPos<=vps_max_sub_layers_minus1; SubLayerPos++) { Element_Begin1("SubLayer"); Skip_UE( "vps_max_dec_pic_buffering_minus1"); Skip_UE( "vps_max_num_reorder_pics"); Skip_UE( "vps_max_latency_increase_plus1"); Element_End0(); } Get_S1 ( 6, vps_max_layer_id, "vps_max_layer_id"); Get_UE ( vps_num_layer_sets_minus1, "vps_num_layer_sets_minus1"); if (vps_num_layer_sets_minus1>=1024) { Trusted_IsNot("vps_num_layer_sets_minus1 not valid"); BS_End(); return; //Problem, not valid } for (int32u LayerSetPos=1; LayerSetPos<=vps_num_layer_sets_minus1; LayerSetPos++) for (int8u LayerId=0; LayerId<=vps_max_layer_id; LayerId++) Skip_SB( "layer_id_included_flag"); TEST_SB_SKIP( "vps_timing_info_present_flag"); int32u vps_time_scale, vps_num_hrd_parameters; Skip_S4(32, "vps_num_units_in_tick"); Get_S4 (32, vps_time_scale, "vps_time_scale"); if (vps_time_scale==0) { Trusted_IsNot("vps_time_scale not valid"); Element_End0(); BS_End(); return; //Problem, not valid } TEST_SB_SKIP( "vps_poc_proportional_to_timing_flag"); Skip_UE( "vps_num_ticks_poc_diff_one_minus1"); TEST_SB_END(); Get_UE ( vps_num_hrd_parameters, "vps_num_hrd_parameters"); if (vps_num_hrd_parameters>1024) { Trusted_IsNot("vps_num_hrd_parameters not valid"); vps_num_hrd_parameters=0; } for (int32u HrdPos=0; HrdPos=1024) Trusted_IsNot("hrd_layer_set_idx not valid"); if (HrdPos) Skip_SB( "cprms_present_flag"); Trusted_IsNot("hrd_parameters not supported"); //hrd_parameters } TEST_SB_END(); TESTELSE_SB_SKIP( "vps_extension_flag"); Skip_BS(Data_BS_Remain(), "vps_extension_data"); Trusted_IsNot("(Not supported)"); // Should be skipped, but the detection is too sensible in that case, do not remove it until the detection is adapted TESTELSE_SB_ELSE( "vps_extension_flag"); Mark_1(); while (Data_BS_Remain()) Mark_0(); TESTELSE_SB_END(); BS_End(); FILLING_BEGIN_PRECISE(); //Creating Data if (vps_video_parameter_set_id>=video_parameter_sets.size()) video_parameter_sets.resize(vps_video_parameter_set_id+1); std::vector::iterator Data_Item=video_parameter_sets.begin()+vps_video_parameter_set_id; delete *Data_Item; *Data_Item=new video_parameter_set_struct( vps_max_sub_layers_minus1 ); //NextCode NextCode_Clear(); NextCode_Add(33); //Autorisation of other streams Streams[33].Searching_Payload=true; //seq_parameter_set Streams[36].Searching_Payload=true; //end_of_seq Streams[37].Searching_Payload=true; //end_of_bitstream Streams[38].Searching_Payload=true; //filler_data FILLING_END(); } //--------------------------------------------------------------------------- // Packet "33" void File_Hevc::seq_parameter_set() { Element_Name("seq_parameter_set"); //Parsing seq_parameter_set_struct::vui_parameters_struct* vui_parameters_Item=NULL; int32u sps_seq_parameter_set_id, chroma_format_idc, pic_width_in_luma_samples, pic_height_in_luma_samples, bit_depth_luma_minus8, bit_depth_chroma_minus8, log2_max_pic_order_cnt_lsb_minus4, num_short_term_ref_pic_sets; int32u conf_win_left_offset=0, conf_win_right_offset=0, conf_win_top_offset=0, conf_win_bottom_offset=0; int8u video_parameter_set_id, max_sub_layers_minus1; bool separate_colour_plane_flag=false, sps_sub_layer_ordering_info_present_flag; BS_Begin(); Get_S1 (4, video_parameter_set_id, "sps_video_parameter_set_id"); std::vector::iterator video_parameter_set_Item; if (video_parameter_set_id >= video_parameter_sets.size() || (*(video_parameter_set_Item = video_parameter_sets.begin() + video_parameter_set_id)) == NULL) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (video_parameter_set is missing)"); BS_End(); return; } Get_S1 (3, max_sub_layers_minus1, "sps_max_sub_layers_minus1"); Skip_SB( "sps_temporal_id_nesting_flag"); profile_tier_level(max_sub_layers_minus1); Get_UE ( sps_seq_parameter_set_id, "sps_seq_parameter_set_id"); if (MustParse_VPS_SPS_PPS_FromFlv) { BS_End(); Skip_XX(Element_Size-Element_Offset, "Data"); //Creating Data if (sps_seq_parameter_set_id>=seq_parameter_sets.size()) seq_parameter_sets.resize(sps_seq_parameter_set_id+1); std::vector::iterator Data_Item=seq_parameter_sets.begin()+sps_seq_parameter_set_id; delete *Data_Item; *Data_Item=new seq_parameter_set_struct( NULL, //TODO: check which code is intended here 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, false, false ); //NextCode NextCode_Clear(); NextCode_Add(34); //Autorisation of other streams Streams[34].Searching_Payload=true; //pic_parameter_set return; } Get_UE ( chroma_format_idc, "chroma_format_idc"); Param_Info1(Hevc_chroma_format_idc((int8u)chroma_format_idc)); if (chroma_format_idc>=4) { Trusted_IsNot("chroma_format_idc not valid"); BS_End(); return; //Problem, not valid } if (chroma_format_idc==3) Get_SB (separate_colour_plane_flag, "separate_colour_plane_flag"); Get_UE ( pic_width_in_luma_samples, "pic_width_in_luma_samples"); Get_UE ( pic_height_in_luma_samples, "pic_height_in_luma_samples"); TEST_SB_SKIP( "conformance_window_flag"); Get_UE (conf_win_left_offset, "conf_win_left_offset"); Get_UE (conf_win_right_offset, "conf_win_right_offset"); Get_UE (conf_win_top_offset, "conf_win_top_offset"); Get_UE (conf_win_bottom_offset, "conf_win_bottom_offset"); TEST_SB_END(); Get_UE ( bit_depth_luma_minus8, "bit_depth_luma_minus8"); if (bit_depth_luma_minus8>6) { Trusted_IsNot("bit_depth_luma_minus8 not valid"); return; //Problem, not valid } Get_UE ( bit_depth_chroma_minus8, "bit_depth_chroma_minus8"); if (bit_depth_chroma_minus8>6) { Trusted_IsNot("bit_depth_chroma_minus8 not valid"); return; //Problem, not valid } Get_UE ( log2_max_pic_order_cnt_lsb_minus4, "log2_max_pic_order_cnt_lsb_minus4"); if (log2_max_pic_order_cnt_lsb_minus4>12) { Trusted_IsNot("log2_max_pic_order_cnt_lsb_minus4 not valid"); return; //Problem, not valid } Get_SB ( sps_sub_layer_ordering_info_present_flag, "sps_sub_layer_ordering_info_present_flag"); for (int32u SubLayerPos = (sps_sub_layer_ordering_info_present_flag ? 0 : max_sub_layers_minus1); SubLayerPos <= max_sub_layers_minus1; SubLayerPos++) { Element_Begin1("SubLayer"); Skip_UE( "sps_max_dec_pic_buffering_minus1"); Skip_UE( "sps_max_num_reorder_pics"); Skip_UE( "sps_max_latency_increase_plus1"); Element_End0(); } Skip_UE( "log2_min_luma_coding_block_size_minus3"); Skip_UE( "log2_diff_max_min_luma_coding_block_size"); Skip_UE( "log2_min_transform_block_size_minus2"); Skip_UE( "log2_diff_max_min_transform_block_size"); Skip_UE( "max_transform_hierarchy_depth_inter"); Skip_UE( "max_transform_hierarchy_depth_intra"); TEST_SB_SKIP( "scaling_list_enabled_flag"); TEST_SB_SKIP( "sps_scaling_list_data_present_flag"); scaling_list_data(); TEST_SB_END(); TEST_SB_END(); Skip_SB( "amp_enabled_flag"); Skip_SB( "sample_adaptive_offset_enabled_flag"); TEST_SB_SKIP( "pcm_enabled_flag"); Element_Begin1("pcm"); Skip_S1(4, "pcm_sample_bit_depth_luma_minus1"); Skip_S1(4, "pcm_sample_bit_depth_chroma_minus1"); Skip_UE( "log2_min_pcm_luma_coding_block_size_minus3"); Skip_UE( "log2_diff_max_min_pcm_luma_coding_block_size"); Skip_SB( "pcm_loop_filter_disabled_flag"); Element_End0(); TEST_SB_END(); Get_UE ( num_short_term_ref_pic_sets, "num_short_term_ref_pic_sets"); if (num_short_term_ref_pic_sets>64) { BS_End(); Trusted_IsNot("num_short_term_ref_pic_sets not valid"); return; //Problem, not valid } short_term_ref_pic_sets((int8u)num_short_term_ref_pic_sets); TEST_SB_SKIP( "long_term_ref_pics_present_flag"); Element_Begin1("long_term_ref_pics"); int32u num_long_term_ref_pics_sps; Get_UE (num_long_term_ref_pics_sps, "num_long_term_ref_pics_sps"); for (int32u long_term_ref_pics_sps_pos=0; long_term_ref_pics_sps_pos=seq_parameter_sets.size()) seq_parameter_sets.resize(sps_seq_parameter_set_id+1); std::vector::iterator Data_Item=seq_parameter_sets.begin()+sps_seq_parameter_set_id; delete *Data_Item; *Data_Item=new seq_parameter_set_struct( vui_parameters_Item, profile_space, tier_flag, profile_idc, level_idc, pic_width_in_luma_samples, pic_height_in_luma_samples, conf_win_left_offset, conf_win_right_offset, conf_win_top_offset, conf_win_bottom_offset, (int8u)video_parameter_set_id, (int8u)chroma_format_idc, separate_colour_plane_flag, (int8u)log2_max_pic_order_cnt_lsb_minus4, (int8u)bit_depth_luma_minus8, (int8u)bit_depth_chroma_minus8, general_progressive_source_flag, general_interlaced_source_flag, general_frame_only_constraint_flag ); //NextCode NextCode_Clear(); NextCode_Add(34); //Autorisation of other streams Streams[34].Searching_Payload=true; //pic_parameter_set FILLING_ELSE(); delete vui_parameters_Item; //vui_parameters_Item=NULL; FILLING_END(); } //--------------------------------------------------------------------------- // Packet "34" void File_Hevc::pic_parameter_set() { Element_Name("pic_parameter_set"); //Parsing int32u pps_pic_parameter_set_id, pps_seq_parameter_set_id, num_ref_idx_l0_default_active_minus1, num_ref_idx_l1_default_active_minus1; int8u num_extra_slice_header_bits; bool tiles_enabled_flag, dependent_slice_segments_enabled_flag; BS_Begin(); Get_UE ( pps_pic_parameter_set_id, "pps_pic_parameter_set_id"); if (pps_pic_parameter_set_id>=64) { Trusted_IsNot("pic_parameter_set_id not valid"); BS_End(); return; //Problem, not valid } Get_UE ( pps_seq_parameter_set_id, "pps_seq_parameter_set_id"); if (pps_seq_parameter_set_id>=16) { Trusted_IsNot("seq_parameter_set_id not valid"); return; //Problem, not valid } //std::vector::iterator seq_parameter_set_Item; if (pps_seq_parameter_set_id>=seq_parameter_sets.size() || (*(seq_parameter_sets.begin()+pps_seq_parameter_set_id))==NULL) //(seq_parameter_set_Item=seq_parameter_sets.begin()+pps_seq_parameter_set_id) not usd for the moment { //Not yet present Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)"); BS_End(); return; } if (MustParse_VPS_SPS_PPS_FromFlv) { BS_End(); Skip_XX(Element_Size-Element_Offset, "Data"); //Filling if (pps_pic_parameter_set_id>=pic_parameter_sets.size()) pic_parameter_sets.resize(pps_pic_parameter_set_id+1); std::vector::iterator pic_parameter_sets_Item=pic_parameter_sets.begin()+pps_pic_parameter_set_id; delete *pic_parameter_sets_Item; *pic_parameter_sets_Item=new pic_parameter_set_struct( 0, 0, 0, 0, false ); //NextCode NextCode_Clear(); //Autorisation of other streams Streams[ 0].Searching_Payload=true; //slice_segment_layer Streams[ 1].Searching_Payload=true; //slice_segment_layer Streams[ 2].Searching_Payload=true; //slice_segment_layer Streams[ 3].Searching_Payload=true; //slice_segment_layer Streams[ 4].Searching_Payload=true; //slice_layer Streams[ 5].Searching_Payload=true; //slice_layer Streams[ 6].Searching_Payload=true; //slice_layer Streams[ 7].Searching_Payload=true; //slice_layer Streams[ 8].Searching_Payload=true; //slice_layer Streams[ 9].Searching_Payload=true; //slice_layer Streams[16].Searching_Payload=true; //slice_segment_layer Streams[17].Searching_Payload=true; //slice_segment_layer Streams[18].Searching_Payload=true; //slice_segment_layer Streams[19].Searching_Payload=true; //slice_segment_layer Streams[20].Searching_Payload=true; //slice_segment_layer Streams[21].Searching_Payload=true; //slice_segment_layer return; } Get_SB ( dependent_slice_segments_enabled_flag, "dependent_slice_segments_enabled_flag"); Skip_SB( "output_flag_present_flag"); Get_S1 (3, num_extra_slice_header_bits, "num_extra_slice_header_bits"); Skip_SB( "sign_data_hiding_flag"); Skip_SB( "cabac_init_present_flag"); 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"); Skip_SE( "init_qp_minus26"); Skip_SB( "constrained_intra_pred_flag"); Skip_SB( "transform_skip_enabled_flag"); TEST_SB_SKIP( "cu_qp_delta_enabled_flag"); Skip_UE( "diff_cu_qp_delta_depth"); TEST_SB_END(); Skip_SE( "pps_cb_qp_offset"); Skip_SE( "pps_cr_qp_offset"); Skip_SB( "pps_slice_chroma_qp_offsets_present_flag"); Skip_SB( "weighted_pred_flag"); Skip_SB( "weighted_bipred_flag"); Skip_SB( "transquant_bypass_enable_flag"); Get_SB ( tiles_enabled_flag, "tiles_enabled_flag"); Skip_SB( "entropy_coding_sync_enabled_flag"); if (tiles_enabled_flag) { Element_Begin1("tiles"); int32u num_tile_columns_minus1, num_tile_rows_minus1; bool uniform_spacing_flag; Get_UE ( num_tile_columns_minus1, "num_tile_columns_minus1"); Get_UE ( num_tile_rows_minus1, "num_tile_rows_minus1"); Get_SB ( uniform_spacing_flag, "uniform_spacing_flag"); if (!uniform_spacing_flag) { for (int32u tile_pos=0; tile_pos=pic_parameter_sets.size()) pic_parameter_sets.resize(pps_pic_parameter_set_id+1); std::vector::iterator pic_parameter_sets_Item=pic_parameter_sets.begin()+pps_pic_parameter_set_id; delete *pic_parameter_sets_Item; *pic_parameter_sets_Item = new pic_parameter_set_struct( (int8u)pps_seq_parameter_set_id, (int8u)num_ref_idx_l0_default_active_minus1, (int8u)num_ref_idx_l1_default_active_minus1, num_extra_slice_header_bits, dependent_slice_segments_enabled_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; // } //} //NextCode NextCode_Clear(); //Autorisation of other streams Streams[ 0].Searching_Payload=true; //slice_segment_layer Streams[ 1].Searching_Payload=true; //slice_segment_layer Streams[ 2].Searching_Payload=true; //slice_segment_layer Streams[ 3].Searching_Payload=true; //slice_segment_layer Streams[ 4].Searching_Payload=true; //slice_layer Streams[ 5].Searching_Payload=true; //slice_layer Streams[ 6].Searching_Payload=true; //slice_layer Streams[ 7].Searching_Payload=true; //slice_layer Streams[ 8].Searching_Payload=true; //slice_layer Streams[ 9].Searching_Payload=true; //slice_layer Streams[16].Searching_Payload=true; //slice_segment_layer Streams[17].Searching_Payload=true; //slice_segment_layer Streams[18].Searching_Payload=true; //slice_segment_layer Streams[19].Searching_Payload=true; //slice_segment_layer Streams[20].Searching_Payload=true; //slice_segment_layer Streams[21].Searching_Payload=true; //slice_segment_layer FILLING_END(); } //--------------------------------------------------------------------------- // Packet "35" void File_Hevc::access_unit_delimiter() { Element_Name("access_unit_delimiter"); //Parsing BS_Begin(); Info_S1( 3, pic_type, "pic_type"); Param_Info1(Hevc_pic_type[pic_type]); BS_End(); } //--------------------------------------------------------------------------- // Packet "36" void File_Hevc::end_of_seq() { Element_Name("end_of_seq"); } //--------------------------------------------------------------------------- // Packet "37" void File_Hevc::end_of_bitstream() { Element_Name("end_of_bitstream"); } //--------------------------------------------------------------------------- // Packet "38" void File_Hevc::filler_data() { Element_Name("filler_data"); //Parsing Skip_XX(Element_Size, "ff_bytes"); } //--------------------------------------------------------------------------- // Packet "39" or "40 void File_Hevc::sei() { Element_Name("sei"); //Parsing int32u seq_parameter_set_id=(int32u)-1; while(Element_Offset+1Element_Size) { Trusted_IsNot("Wrong size"); Skip_XX(Element_Size-Element_Offset, "unknown"); return; } int64u Element_Size_Save=Element_Size; Element_Size=Element_Offset_Save; switch (payloadType) { case 0 : sei_message_buffering_period(seq_parameter_set_id, payloadSize); break; case 1 : sei_message_pic_timing(seq_parameter_set_id, payloadSize); 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; case 129 : sei_message_active_parameter_sets(); break; case 132 : sei_message_decoded_picture_hash(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_Hevc::sei_message_buffering_period(int32u &seq_parameter_set_id, int32u payloadSize) { Element_Info1("buffering_period"); //Parsing if (Element_Offset==Element_Size) return; //Nothing to do BS_Begin(); Get_UE (seq_parameter_set_id, "seq_parameter_set_id"); std::vector::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) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)"); BS_End(); return; } bool sub_pic_hrd_params_present_flag=false; //Default bool irap_cpb_params_present_flag=((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->xxL_Common)?(*seq_parameter_set_Item)->vui_parameters->xxL_Common->sub_pic_hrd_params_present_flag:false; if (!sub_pic_hrd_params_present_flag) Get_SB (irap_cpb_params_present_flag, "irap_cpb_params_present_flag"); int8u au_cpb_removal_delay_length_minus1=((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->xxL_Common)?(*seq_parameter_set_Item)->vui_parameters->xxL_Common->au_cpb_removal_delay_length_minus1:23; int8u dpb_output_delay_length_minus1=((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->xxL_Common)?(*seq_parameter_set_Item)->vui_parameters->xxL_Common->dpb_output_delay_length_minus1:23; if (irap_cpb_params_present_flag) { Skip_S4(au_cpb_removal_delay_length_minus1+1, "cpb_delay_offset"); Skip_S4(dpb_output_delay_length_minus1+1, "dpb_delay_offset"); } Skip_SB( "concatenation_flag"); Skip_S4(au_cpb_removal_delay_length_minus1+1, "au_cpb_removal_delay_delta_minus1"); if ((*seq_parameter_set_Item)->NalHrdBpPresentFlag()) sei_message_buffering_period_xxl((*seq_parameter_set_Item)->vui_parameters?(*seq_parameter_set_Item)->vui_parameters->xxL_Common:NULL, irap_cpb_params_present_flag, (*seq_parameter_set_Item)->vui_parameters->NAL); if ((*seq_parameter_set_Item)->VclHrdBpPresentFlag()) sei_message_buffering_period_xxl((*seq_parameter_set_Item)->vui_parameters?(*seq_parameter_set_Item)->vui_parameters->xxL_Common:NULL, irap_cpb_params_present_flag, (*seq_parameter_set_Item)->vui_parameters->VCL); BS_End(); } void File_Hevc::sei_message_buffering_period_xxl(seq_parameter_set_struct::vui_parameters_struct::xxl_common* xxL_Common, bool irap_cpb_params_present_flag, seq_parameter_set_struct::vui_parameters_struct::xxl* xxl) { if (xxL_Common==NULL || xxl==NULL) { //Problem? Skip_BS(Data_BS_Remain(), "Problem?"); return; } for (int32u SchedSelIdx=0; SchedSelIdxSchedSel.size(); SchedSelIdx++) { //Get_S4 (xxl->SchedSel[SchedSelIdx].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->SchedSel[SchedSelIdx].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"); Info_S4 (xxL_Common->initial_cpb_removal_delay_length_minus1+1, initial_cpb_removal_delay, "initial_cpb_removal_delay"); Param_Info2(initial_cpb_removal_delay/90, " ms"); Info_S4 (xxL_Common->initial_cpb_removal_delay_length_minus1+1, initial_cpb_removal_delay_offset, "initial_cpb_removal_delay_offset"); Param_Info2(initial_cpb_removal_delay_offset/90, " ms"); if (xxL_Common->sub_pic_hrd_params_present_flag || irap_cpb_params_present_flag) { Info_S4 (xxL_Common->initial_cpb_removal_delay_length_minus1+1, initial_alt_cpb_removal_delay, "initial_alt_cpb_removal_delay"); Param_Info2(initial_alt_cpb_removal_delay/90, " ms"); Info_S4 (xxL_Common->initial_cpb_removal_delay_length_minus1+1, initial_alt_cpb_removal_delay_offset, "initial_alt_cpb_removal_delay_offset"); Param_Info2(initial_alt_cpb_removal_delay_offset/90, " ms"); } } } //--------------------------------------------------------------------------- // SEI - 1 void File_Hevc::sei_message_pic_timing(int32u &seq_parameter_set_id, int32u payloadSize) { 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::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) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)"); return; } //Parsing BS_Begin(); if ((*seq_parameter_set_Item)->vui_parameters?(*seq_parameter_set_Item)->vui_parameters->frame_field_info_present_flag:((*seq_parameter_set_Item)->general_progressive_source_flag && (*seq_parameter_set_Item)->general_interlaced_source_flag)) { Skip_S1(4, "pic_struct"); Skip_S1(2, "source_scan_type"); Skip_SB( "duplicate_flag"); } if ((*seq_parameter_set_Item)->CpbDpbDelaysPresentFlag()) { int8u au_cpb_removal_delay_length_minus1=(*seq_parameter_set_Item)->vui_parameters->xxL_Common->au_cpb_removal_delay_length_minus1; int8u dpb_output_delay_length_minus1=(*seq_parameter_set_Item)->vui_parameters->xxL_Common->dpb_output_delay_length_minus1; bool sub_pic_hrd_params_present_flag=(*seq_parameter_set_Item)->vui_parameters->xxL_Common->sub_pic_hrd_params_present_flag; Skip_S4(au_cpb_removal_delay_length_minus1+1, "au_cpb_removal_delay_minus1"); Skip_S4(dpb_output_delay_length_minus1+1, "pic_dpb_output_delay"); if (sub_pic_hrd_params_present_flag) { int8u dpb_output_delay_du_length_minus1=(*seq_parameter_set_Item)->vui_parameters->xxL_Common->dpb_output_delay_du_length_minus1; Skip_S4(dpb_output_delay_du_length_minus1+1, "pic_dpb_output_du_delay"); } } BS_End(); } //--------------------------------------------------------------------------- // SEI - 5 void File_Hevc::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 0x214892b89bCC7f42LL : Element_Info1("Ateme"); sei_message_user_data_unregistered_Ateme(payloadSize-16); break; case 0xDB4717b509DEA22CLL : Element_Info1("x265"); sei_message_user_data_unregistered_x265(payloadSize-16); break; default : Element_Info1("unknown"); Skip_XX(payloadSize-16, "data"); } } //--------------------------------------------------------------------------- // SEI - 5 - Ateme void File_Hevc::sei_message_user_data_unregistered_Ateme(int32u payloadSize) { //Parsing Get_Local(payloadSize, Encoded_Library, "Library name"); //Encoded_Library if (Encoded_Library.find(__T("ATEME "))==0) { size_t Pos=Encoded_Library.find_first_of(__T("0123456789")); if (Pos && Encoded_Library[Pos-1]==__T(' ')) { Encoded_Library_Name=Encoded_Library.substr(0, Pos-1); Encoded_Library_Version=Encoded_Library.substr(Pos); } } } //--------------------------------------------------------------------------- // SEI - 5 - x265 void File_Hevc::sei_message_user_data_unregistered_x265(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_Before=0; size_t Loop=0; do { size_t 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_Before=Data_Pos_Before; Encoded_Library_Settings.clear(); while (Options_Pos_Before!=Data.size()) { size_t 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; while (Options_Pos_Before!=Data.size()) { Ztring Separator; Peek_Local(1, Separator); if (Separator==__T(" ")) { Skip_Local(1, "separator"); Options_Pos_Before+=1; } else break; } //Filling if (option!=__T("options:") && !(!option.empty() && option[0]>=__T('0') && option[0]<=__T('9')) && option.find(__T("fps="))!=0 && option.find(__T("bitdepth="))!=0) //Ignoring redundant information e.g. width, height, frame rate, bit depth { if (!Encoded_Library_Settings.empty()) Encoded_Library_Settings+=__T(" / "); Encoded_Library_Settings+=option; } } 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); size_t Value_Pos=Value.find(__T(" ")); if (Value_Pos!=string::npos) Value.resize(Value_Pos); Encoded_Library=Value; } if (Loop==1 && Encoded_Library.find(__T("x265"))==0) { size_t Value_Pos=Value.find(__T(" 8bpp")); if (Value_Pos!=string::npos) Value.resize(Value_Pos); 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("x265 - "))==0) { Encoded_Library_Name=__T("x265"); Encoded_Library_Version=Encoded_Library.SubString(__T("x265 - "), Ztring()); } else Encoded_Library_Name=Encoded_Library; } //--------------------------------------------------------------------------- void File_Hevc::sei_message_active_parameter_sets() { Element_Info1("active_parameter_sets"); //Parsing int32u num_sps_ids_minus1; BS_Begin(); Skip_S1(4, "active_video_parameter_set_id"); Skip_SB( "self_contained_cvs_flag"); Skip_SB( "no_parameter_set_update_flag"); Get_UE ( num_sps_ids_minus1, "num_sps_ids_minus1"); for (int32u i=0; i<=num_sps_ids_minus1; ++i) { Skip_UE( "active_seq_parameter_set_id"); } BS_End(); } //--------------------------------------------------------------------------- void File_Hevc::sei_message_decoded_picture_hash(int32u payloadSize) { Element_Info1("decoded_picture_hash"); //Parsing int8u hash_type; Get_B1 (hash_type, "hash_type"); for (int8u cIdx=0; cIdx<(chroma_format_idc?3:1); cIdx++) switch (hash_type) { case 0 : // md5 Skip_XX(16, "md5"); break; case 1 : // crc Skip_XX( 2, "crc"); break; case 2 : // checksum Skip_XX( 4, "checksum"); break; default : // Skip_XX((Element_Size-1)/(chroma_format_idc?1:3), "unknown"); break; } } //*************************************************************************** // Sub-elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Hevc::slice_segment_header() { Element_Begin1("slice_segment_header"); //Parsing bool dependent_slice_segment_flag=false; Get_SB ( first_slice_segment_in_pic_flag, "first_slice_segment_in_pic_flag"); if (RapPicFlag) Skip_SB( "no_output_of_prior_pics_flag"); Get_UE ( slice_pic_parameter_set_id, "slice_pic_parameter_set_id"); std::vector::iterator pic_parameter_set_Item; if (slice_pic_parameter_set_id>=pic_parameter_sets.size() || (*(pic_parameter_set_Item=pic_parameter_sets.begin()+slice_pic_parameter_set_id))==NULL) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (pic_parameter_set is missing)"); Element_End0(); slice_pic_parameter_set_id=(int32u)-1; slice_type=(int32u)-1; return; } if (!first_slice_segment_in_pic_flag) { if (!MustParse_VPS_SPS_PPS_FromFlv && (*pic_parameter_set_Item)->dependent_slice_segments_enabled_flag) Get_SB (dependent_slice_segment_flag, "dependent_slice_segment_flag"); //Skip_BS(Ceil( Log2( PicSizeInCtbsY ) ), "slice_segment_address"); Skip_BS(Data_BS_Remain(), "(ToDo)"); Element_End0(); slice_type=(int32u)-1; return; } if (!dependent_slice_segment_flag) { if (!MustParse_VPS_SPS_PPS_FromFlv) Skip_S1((*pic_parameter_set_Item)->num_extra_slice_header_bits, "slice_reserved_flags"); Get_UE (slice_type, "slice_type"); Param_Info1(Hevc_slice_type(slice_type)); } //TODO... Skip_BS(Data_BS_Remain(), "(ToDo)"); Element_End0(); } //--------------------------------------------------------------------------- void File_Hevc::profile_tier_level(int8u maxNumSubLayersMinus1) { Element_Begin1("profile_tier_level"); //Parsing std::vectorsub_layer_profile_present_flags, sub_layer_level_present_flags; Get_S1 (2, profile_space, "general_profile_space"); Get_SB ( tier_flag, "general_tier_flag"); Get_S1 (5, profile_idc, "general_profile_idc"); Element_Begin1("general_profile_compatibility_flags"); for (int8u profile_pos=0; profile_pos<32; profile_pos++) if (profile_pos==profile_idc) { bool general_profile_compatibility_flag; Get_SB ( general_profile_compatibility_flag, "general_profile_compatibility_flag"); //if (!general_profile_compatibility_flag && !profile_space) //found some files without this flag, ignoring the test for the moment (not really important) // Trusted_IsNot("general_profile_compatibility_flag not valid"); } else Skip_SB( "general_profile_compatibility_flag"); Element_End0(); Get_SB ( general_progressive_source_flag, "general_progressive_source_flag"); Get_SB ( general_interlaced_source_flag, "general_interlaced_source_flag"); Skip_SB( "general_non_packed_constraint_flag"); Get_SB ( general_frame_only_constraint_flag, "general_frame_only_constraint_flag"); Skip_S8(44, "general_reserved_zero_44bits"); Get_S1 (8, level_idc, "general_level_idc"); for (int32u SubLayerPos=0; SubLayerPosstRpsIdx) { Skip_BS(Data_BS_Remain(), "(Problem)"); Element_End0(); Element_End0(); return; } Get_SB ( delta_rps_sign, "delta_rps_sign"); Get_UE ( abs_delta_rps_minus1, "abs_delta_rps_minus1"); int32u num_pics_new=0; for(int32u pic_pos=0 ; pic_pos<=num_pics; pic_pos++) { TESTELSE_SB_SKIP( "used_by_curr_pic_flag"); num_pics_new++; TESTELSE_SB_ELSE( "used_by_curr_pic_flag"); bool use_delta_flag; Get_SB (use_delta_flag, "use_delta_flag"); if (use_delta_flag) num_pics_new++; TESTELSE_SB_END(); } num_pics=num_pics_new; } else { int32u num_negative_pics, num_positive_pics; Get_UE (num_negative_pics, "num_negative_pics"); Get_UE (num_positive_pics, "num_positive_pics"); num_pics=num_negative_pics+num_positive_pics; for (int32u i=0; i::iterator video_parameter_set_Item, seq_parameter_set_struct::vui_parameters_struct* &vui_parameters_Item_) { //Parsing seq_parameter_set_struct::vui_parameters_struct::xxl_common *xxL_Common=NULL; seq_parameter_set_struct::vui_parameters_struct::xxl *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, video_full_range_flag=0, colour_primaries=2, transfer_characteristics=2, matrix_coefficients=2; bool aspect_ratio_info_present_flag, video_signal_type_present_flag, frame_field_info_present_flag, colour_description_present_flag=false, timing_info_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_idcvps_max_sub_layers_minus1, xxL_Common, NAL, VCL); TEST_SB_END(); TEST_SB_END(); TEST_SB_SKIP( "bitstream_restriction_flag"); Skip_SB( "tiles_fixed_structure_flag"); Skip_SB( "motion_vectors_over_pic_boundaries_flag"); Skip_SB( "restricted_ref_pic_lists_flag"); Skip_UE( "min_spatial_segmentation_idc"); Skip_UE( "max_bytes_per_pic_denom"); Skip_UE( "max_bits_per_min_cu_denom"); Skip_UE( "log2_max_mv_length_horizontal"); Skip_UE( "log2_max_mv_length_vertical"); TEST_SB_END(); FILLING_BEGIN(); vui_parameters_Item_ = new seq_parameter_set_struct::vui_parameters_struct( NAL, VCL, xxL_Common, num_units_in_tick, time_scale, sar_width, sar_height, aspect_ratio_idc, video_format, video_full_range_flag, colour_primaries, transfer_characteristics, matrix_coefficients, aspect_ratio_info_present_flag, video_signal_type_present_flag, frame_field_info_present_flag, colour_description_present_flag, timing_info_present_flag ); FILLING_ELSE(); delete xxL_Common; delete NAL; delete VCL; FILLING_END(); } //--------------------------------------------------------------------------- void File_Hevc::hrd_parameters(bool commonInfPresentFlag, int8u maxNumSubLayersMinus1, seq_parameter_set_struct::vui_parameters_struct::xxl_common* &xxL_Common, seq_parameter_set_struct::vui_parameters_struct::xxl* &NAL, seq_parameter_set_struct::vui_parameters_struct::xxl* &VCL) { //Parsing int8u bit_rate_scale=0, cpb_size_scale=0, du_cpb_removal_delay_increment_length_minus1=0, dpb_output_delay_du_length_minus1=0, initial_cpb_removal_delay_length_minus1=0, au_cpb_removal_delay_length_minus1=0, dpb_output_delay_length_minus1=0; bool nal_hrd_parameters_present_flag=false, vcl_hrd_parameters_present_flag=false, sub_pic_hrd_params_present_flag=false; if (commonInfPresentFlag) { Get_SB (nal_hrd_parameters_present_flag, "nal_hrd_parameters_present_flag"); Get_SB (vcl_hrd_parameters_present_flag, "vcl_hrd_parameters_present_flag"); if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) { TEST_SB_GET (sub_pic_hrd_params_present_flag, "sub_pic_hrd_params_present_flag"); Skip_S1(8, "tick_divisor_minus2"); Get_S1 (5, du_cpb_removal_delay_increment_length_minus1, "du_cpb_removal_delay_increment_length_minus1"); Skip_SB( "sub_pic_cpb_params_in_pic_timing_sei_flag"); Get_S1 (5, dpb_output_delay_du_length_minus1, "dpb_output_delay_du_length_minus1"); TEST_SB_END(); Get_S1 (4, bit_rate_scale, "bit_rate_scale"); Get_S1 (4, cpb_size_scale, "cpb_size_scale"); if (sub_pic_hrd_params_present_flag) Skip_S1(4, "cpb_size_du_scale"); Get_S1 (5, initial_cpb_removal_delay_length_minus1, "initial_cpb_removal_delay_length_minus1"); Get_S1 (5, au_cpb_removal_delay_length_minus1, "au_cpb_removal_delay_length_minus1"); Get_S1 (5, dpb_output_delay_length_minus1, "dpb_output_delay_length_minus1"); } } for (int8u NumSubLayer=0; NumSubLayer<=maxNumSubLayersMinus1; NumSubLayer++) { int32u cpb_cnt_minus1=0; bool fixed_pic_rate_general_flag, fixed_pic_rate_within_cvs_flag=true, low_delay_hrd_flag=false; Get_SB (fixed_pic_rate_general_flag, "fixed_pic_rate_general_flag"); if (!fixed_pic_rate_general_flag) Get_SB (fixed_pic_rate_within_cvs_flag, "fixed_pic_rate_within_cvs_flag"); if (fixed_pic_rate_within_cvs_flag) Skip_UE( "elemental_duration_in_tc_minus1"); else Get_SB (low_delay_hrd_flag, "low_delay_hrd_flag"); if (!low_delay_hrd_flag) { Get_UE (cpb_cnt_minus1, "cpb_cnt_minus1"); if (cpb_cnt_minus1>31) { Trusted_IsNot("cpb_cnt_minus1 too high"); cpb_cnt_minus1=0; return; } } if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) xxL_Common=new seq_parameter_set_struct::vui_parameters_struct::xxl_common( sub_pic_hrd_params_present_flag, du_cpb_removal_delay_increment_length_minus1, dpb_output_delay_du_length_minus1, initial_cpb_removal_delay_length_minus1, au_cpb_removal_delay_length_minus1, dpb_output_delay_length_minus1 ); if (nal_hrd_parameters_present_flag) sub_layer_hrd_parameters(xxL_Common, bit_rate_scale, cpb_size_scale, cpb_cnt_minus1, NAL); //TODO: save HRD per NumSubLayer if (vcl_hrd_parameters_present_flag) sub_layer_hrd_parameters(xxL_Common, bit_rate_scale, cpb_size_scale, cpb_cnt_minus1, VCL); //TODO: save HRD per NumSubLayer } } //--------------------------------------------------------------------------- void File_Hevc::sub_layer_hrd_parameters(seq_parameter_set_struct::vui_parameters_struct::xxl_common* xxL_Common, int8u bit_rate_scale, int8u cpb_size_scale, int32u cpb_cnt_minus1, seq_parameter_set_struct::vui_parameters_struct::xxl* &hrd_parameters_Item_) { //Parsing vector SchedSel; SchedSel.reserve(cpb_cnt_minus1 + 1); for (int8u SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; ++SchedSelIdx) { Element_Begin1("ShedSel"); int64u bit_rate_value, cpb_size_value; int32u bit_rate_value_minus1, cpb_size_value_minus1; bool cbr_flag; Get_UE (bit_rate_value_minus1, "bit_rate_value_minus1"); bit_rate_value = (int64u)((bit_rate_value_minus1 + 1)*pow(2.0, 6 + bit_rate_scale)); Param_Info2(bit_rate_value, " bps"); Get_UE (cpb_size_value_minus1, "cpb_size_value_minus1"); cpb_size_value = (int64u)((cpb_size_value_minus1 + 1)*pow(2.0, 4 + cpb_size_scale)); Param_Info2(cpb_size_value, " bits"); if (xxL_Common->sub_pic_hrd_params_present_flag) { Skip_UE( "cpb_size_du_value_minus1"); Skip_UE( "bit_rate_du_value_minus1"); } Get_SB (cbr_flag, "cbr_flag"); Element_End0(); FILLING_BEGIN(); SchedSel.push_back(seq_parameter_set_struct::vui_parameters_struct::xxl::xxl_data( bit_rate_value, cpb_size_value, cbr_flag )); FILLING_END(); } //Validity test if (!Element_IsOK() || (SchedSel.size() == 1 && SchedSel[0].bit_rate_value == 64)) { return; //We do not trust this kind of data } //Filling hrd_parameters_Item_=new seq_parameter_set_struct::vui_parameters_struct::xxl( SchedSel ); } //--------------------------------------------------------------------------- void File_Hevc::scaling_list_data() { for(int8u sizeId=0; sizeId<4; sizeId++) for (int8u matrixId = 0; matrixId<((sizeId == 3) ? 2 : 6); matrixId++) { bool scaling_list_pred_mode_flag; Get_SB (scaling_list_pred_mode_flag, "scaling_list_pred_mode_flag"); if(!scaling_list_pred_mode_flag) Skip_UE( "scaling_list_pred_matrix_id_delta"); else { //nextCoef = 8 size_t coefNum=std::min(64, (1<<(4+(sizeId<<1)))); if( sizeId > 1 ) { Skip_SE( "scaling_list_dc_coef_minus8"); //[ sizeId ? 2 ][ matrixId ] se(v) //nextCoef = scaling_list_dc_coef_minus8[ sizeId ? 2 ][ matrixId ] + 8 } for(size_t i=0; i=5 && Buffer[Buffer_Offset ]==0x01 && Buffer[Buffer_Offset+1]==0x00 && Buffer[Buffer_Offset+2]==0x00 && Buffer[Buffer_Offset+3]==0x00 && Buffer[Buffer_Offset+4]==0xFF) //Trying to detect old proposal of the form of Matroska implementation return VPS_SPS_PPS_FromMatroska(); MustParse_VPS_SPS_PPS_FromMatroska=false; MustParse_VPS_SPS_PPS_FromFlv=false; } //Parsing int64u general_constraint_indicator_flags; int32u general_profile_compatibility_flags; int8u configurationVersion; int8u chromaFormat, bitDepthLumaMinus8, bitDepthChromaMinus8; int8u general_profile_space, general_profile_idc, general_level_idc; int8u numOfArrays, constantFrameRate, numTemporalLayers; bool general_tier_flag, temporalIdNested; Get_B1 (configurationVersion, "configurationVersion"); BS_Begin(); Get_S1 (2, general_profile_space, "general_profile_space"); Get_SB ( general_tier_flag, "general_tier_flag"); Get_S1 (5, general_profile_idc, "general_profile_idc"); BS_End(); Get_B4 (general_profile_compatibility_flags, "general_profile_compatibility_flags"); Get_B6 (general_constraint_indicator_flags, "general_constraint_indicator_flags"); Get_B1 (general_level_idc, "general_level_idc"); BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Skip_S2(12, "min_spatial_segmentation_idc"); BS_End(); BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Skip_S1(2, "parallelismType"); BS_End(); BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Get_S1 (2, chromaFormat, "chromaFormat"); BS_End(); BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Get_S1 (3, bitDepthLumaMinus8, "bitDepthLumaMinus8"); BS_End(); BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Get_S1 (3, bitDepthChromaMinus8, "bitDepthChromaMinus8"); BS_End(); Skip_B2( "avgFrameRate"); BS_Begin(); Get_S1 (2, constantFrameRate, "constantFrameRate"); Get_S1 (3, numTemporalLayers, "numTemporalLayers"); Get_SB ( temporalIdNested, "temporalIdNested"); Get_S1 (2, lengthSizeMinusOne, "lengthSizeMinusOne"); BS_End(); Get_B1 (numOfArrays, "numOfArrays"); for (size_t ArrayPos=0; ArrayPosElement_Size) { Trusted_IsNot("Size is wrong"); break; //There is an error } //Header int8u nal_unit_type, nuh_temporal_id_plus1; BS_Begin(); Mark_0 (); Get_S1 (6, nal_unit_type, "nal_unit_type"); Get_S1 (6, nuh_layer_id, "nuh_layer_id"); Get_S1 (3, nuh_temporal_id_plus1, "nuh_temporal_id_plus1"); if (nuh_temporal_id_plus1==0) Trusted_IsNot("nuh_temporal_id_plus1 is invalid"); BS_End(); //Data int64u Element_Offset_Save=Element_Offset; int64u Element_Size_Save=Element_Size; Buffer_Offset+=(size_t)Element_Offset_Save; Element_Offset=0; Element_Size=nalUnitLength-2; Element_Code=nal_unit_type; Data_Parse(); Buffer_Offset-=(size_t)Element_Offset_Save; Element_Offset=Element_Offset_Save+nalUnitLength-2; Element_Size=Element_Size_Save; Element_End0(); } Element_End0(); } MustParse_VPS_SPS_PPS=false; FILLING_BEGIN_PRECISE(); Accept("HEVC"); FILLING_END(); } //--------------------------------------------------------------------------- void File_Hevc::VPS_SPS_PPS_FromMatroska() { //Parsing int8u Profile, Level, vid_parameter_set_count, 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, lengthSizeMinusOne, "Size of NALU length minus 1"); Skip_S1(3, "Reserved"); Get_S1 (5, vid_parameter_set_count, MustParse_VPS_SPS_PPS_FromFlv?"vid_parameter_set+seq_parameter_set count":"vid_parameter_set count"); BS_End(); for (int8u Pos=0; PosElement_Size) { Trusted_IsNot("Size is wrong"); break; //There is an error } //Header int8u nal_unit_type, nuh_temporal_id_plus1; BS_Begin(); Mark_0 (); Get_S1 (6, nal_unit_type, "nal_unit_type"); Get_S1 (6, nuh_layer_id, "nuh_layer_id"); Get_S1 (3, nuh_temporal_id_plus1, "nuh_temporal_id_plus1"); if (nuh_temporal_id_plus1==0) Trusted_IsNot("nuh_temporal_id_plus1 is invalid"); BS_End(); //Data int64u Element_Offset_Save=Element_Offset; int64u Element_Size_Save=Element_Size; Buffer_Offset+=(size_t)Element_Offset_Save; Element_Offset=0; Element_Size=nalUnitLength-2; Element_Code=nal_unit_type; Data_Parse(); Buffer_Offset-=(size_t)Element_Offset_Save; Element_Offset=Element_Offset_Save+nalUnitLength-2; Element_Size=Element_Size_Save; Element_End0(); } if (MustParse_VPS_SPS_PPS_FromFlv) seq_parameter_set_count=0; else { BS_Begin(); Skip_S1(3, "Reserved"); Get_S1 (5, seq_parameter_set_count, "seq_parameter_set count"); BS_End(); } for (int8u Pos=0; PosElement_Size) { Trusted_IsNot("Size is wrong"); break; //There is an error } //Header int8u nal_unit_type, nuh_temporal_id_plus1; BS_Begin(); Mark_0 (); Get_S1 (6, nal_unit_type, "nal_unit_type"); Get_S1 (6, nuh_layer_id, "nuh_layer_id"); Get_S1 (3, nuh_temporal_id_plus1, "nuh_temporal_id_plus1"); if (nuh_temporal_id_plus1==0) Trusted_IsNot("nuh_temporal_id_plus1 is invalid"); BS_End(); //Data int64u Element_Offset_Save=Element_Offset; int64u Element_Size_Save=Element_Size; Buffer_Offset+=(size_t)Element_Offset_Save; Element_Offset=0; Element_Size=nalUnitLength-2; Element_Code=nal_unit_type; Data_Parse(); Buffer_Offset-=(size_t)Element_Offset_Save; Element_Offset=Element_Offset_Save+nalUnitLength-2; Element_Size=Element_Size_Save; Element_End0(); } Get_B1 (pic_parameter_set_count, "pic_parameter_set count"); for (int8u Pos=0; PosElement_Size) { Trusted_IsNot("Size is wrong"); break; //There is an error } //Header int8u nal_unit_type, nuh_temporal_id_plus1; BS_Begin(); Mark_0 (); Get_S1 (6, nal_unit_type, "nal_unit_type"); Get_S1 (6, nuh_layer_id, "nuh_layer_id"); Get_S1 (3, nuh_temporal_id_plus1, "nuh_temporal_id_plus1"); if (nuh_temporal_id_plus1==0) Trusted_IsNot("nuh_temporal_id_plus1 is invalid"); BS_End(); //Data int64u Element_Offset_Save=Element_Offset; int64u Element_Size_Save=Element_Size; Buffer_Offset+=(size_t)Element_Offset_Save; Element_Offset=0; Element_Size=nalUnitLength-2; Element_Code=nal_unit_type; Data_Parse(); Buffer_Offset-=(size_t)Element_Offset_Save; Element_Offset=Element_Offset_Save+nalUnitLength-2; Element_Size=Element_Size_Save; Element_End0(); } if (Element_Offset8) //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 MediaInfoLib/Source/MediaInfo/Video/File_Ffv1.cpp0000664000000000000000000012252512652076434020466 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // http://www.ffmpeg.org/~michael/ffv1.html // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_FFV1_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Video/File_Ffv1.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "ZenLib/BitStream.h" //--------------------------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Const //*************************************************************************** extern int32u Psi_CRC_32_Table[256]; const int32u Slice::Context::N0 = 128; const int32s Slice::Context::Cmax = 127; const int32s Slice::Context::Cmin = -128; //*************************************************************************** // RangeCoder //*************************************************************************** //--------------------------------------------------------------------------- RangeCoder::RangeCoder (const int8u* Buffer, size_t Buffer_Size, const state_transitions default_state_transition) { //Assign buffer Buffer_Cur=Buffer; Buffer_End=Buffer+Buffer_Size; //Init if (Buffer_Size>=2) { Current=BigEndian2int16u(Buffer_Cur); Buffer_Cur+=2; Mask=0xFF00; } else { Current=0; Mask=0; } AssignStateTransitions(default_state_transition); } void RangeCoder::AssignStateTransitions (const state_transitions new_state_transition) { //Assign StateTransitions std::memcpy (one_state, new_state_transition, state_transitions_size); zero_state[0]=0; for (size_t i=1; i> 8); Mask-=Mask2; bool Value; if (Current= plane_count) { contexts[i] = NULL; continue; } int32u idx = quant_table_index[i]; contexts[i] = new Context [context_count[idx]]; for (size_t j = 0; j < context_count[idx]; j++) { Context *c = &contexts[i][j]; c->N = 1; //c->A = (alpha + 32) / 64; // alpha == alphabet size (256) //if (c->A < 2) // c->A = 2; c->A = 4; c->C = 0; c->B = c->C; } } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Ffv1::File_Ffv1() :File__Analyze() { //Configuration ParserName=__T("FFV1"); IsRawStream=true; //use Ffv1_default_state_transition by default memcpy(state_transitions_table, Ffv1_default_state_transition, sizeof(Ffv1_default_state_transition)); //Input Width = (int32u)-1; Height = (int32u)-1; //Temp for (size_t i=0; i < MAX_QUANT_TABLES; ++i) plane_states[i] = NULL; ConfigurationRecordIsPresent=false; RC=NULL; version=0; num_h_slices = 1; num_v_slices = 1; slices = NULL; } //--------------------------------------------------------------------------- File_Ffv1::~File_Ffv1() { //Temp if (slices) { for (size_t y = 0; y < num_v_slices; ++y) for (size_t x = 0; x < num_h_slices; ++x) plane_states_clean(slices[x + y * num_h_slices].plane_states); delete[] slices; } for (size_t i = 0; i < MAX_QUANT_TABLES; ++i) { if (!plane_states[i]) continue; for (size_t j = 0; j < context_count[i]; ++j) delete[] plane_states[i][j]; delete[] plane_states[i]; plane_states[i] = NULL; } delete RC; //RC=NULL } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Ffv1::Streams_Accept() { Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Format, "FFV1"); } //*************************************************************************** // RangeCoder //*************************************************************************** #if MEDIAINFO_TRACE //--------------------------------------------------------------------------- void File_Ffv1::Get_RB (states &States, bool &Info, const char* Name) { Info=RC->get_rac(States); Element_Offset=RC->Buffer_Cur-Buffer; if (Trace_Activated) Param(Name, Info); } //--------------------------------------------------------------------------- void File_Ffv1::Get_RU (states &States, int32u &Info, const char* Name) { Info=RC->get_symbol_u(States); if (Trace_Activated) Param(Name, Info); } //--------------------------------------------------------------------------- void File_Ffv1::Get_RS (states &States, int32s &Info, const char* Name) { Info=RC->get_symbol_s(States); if (Trace_Activated) Param(Name, Info); } //--------------------------------------------------------------------------- void File_Ffv1::Get_RS (int8u* &States, int32s &Info, const char* Name) { Info=RC->get_symbol_s(States); Element_Offset=RC->Buffer_Cur-Buffer; if (Trace_Activated) Param(Name, Info); } //--------------------------------------------------------------------------- void File_Ffv1::Skip_RC (states &States, const char* Name) { int8u Info=RC->get_rac(States); Element_Offset=RC->Buffer_Cur-Buffer; if (Trace_Activated) Param(Name, Info); } //--------------------------------------------------------------------------- void File_Ffv1::Skip_RU (states &States, const char* Name) { if (Trace_Activated) Param(Name, RC->get_symbol_u(States)); else RC->get_symbol_u(States); } //--------------------------------------------------------------------------- void File_Ffv1::Skip_RS (states &States, const char* Name) { if (Trace_Activated) Param(Name, RC->get_symbol_s(States)); else RC->get_symbol_s(States); } #else //MEDIAINFO_TRACE //--------------------------------------------------------------------------- void File_Ffv1::Get_RB_ (states &States, bool &Info) { Info=RC->get_rac(States); } //--------------------------------------------------------------------------- void File_Ffv1::Get_RU_ (states &States, int32u &Info) { Info=RC->get_symbol_u(States); } //--------------------------------------------------------------------------- void File_Ffv1::Get_RS_ (states &States, int32s &Info) { Info=RC->get_symbol_s(States); } //--------------------------------------------------------------------------- void File_Ffv1::Get_RS_ (int8u* &States, int32s &Info) { Info=RC->get_symbol_s(States); } //--------------------------------------------------------------------------- void File_Ffv1::Skip_RC_ (states &States) { RC->get_rac(States); } //--------------------------------------------------------------------------- void File_Ffv1::Skip_RU_ (states &States) { RC->get_symbol_u(States); } //--------------------------------------------------------------------------- void File_Ffv1::Skip_RS_ (states &States) { RC->get_symbol_s(States); } #endif //MEDIAINFO_TRACE //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Ffv1::Read_Buffer_OutOfBand() { ConfigurationRecordIsPresent=true; int32u CRC_32=CRC_Compute((size_t)Element_Size); if (Buffer_Size < 4 || CRC_32) { Reject(); return; } if (!RC) RC = new RangeCoder(Buffer, Buffer_Size-4, Ffv1_default_state_transition); FrameHeader(); if (RC->Buffer_End!=RC->Buffer_Cur) Skip_XX(RC->Buffer_Cur - RC->Buffer_End, "Reserved"); Skip_B4( "CRC-32"); delete RC; RC=NULL; } //--------------------------------------------------------------------------- void File_Ffv1::Read_Buffer_Continue() { if (!Status[IsAccepted]) Accept(); if (!RC) RC = new RangeCoder(Buffer, Buffer_Size, Ffv1_default_state_transition); states States; memset(States, 128, states_size); Get_RB (States, keyframe, "keyframe"); if (!ConfigurationRecordIsPresent) FrameHeader(); if (version>2) { int32u tail = 3; tail += error_correction == 1 ? 5 : 0; int64u Slices_BufferPos=Element_Size; vector Slices_BufferSizes; while (Slices_BufferPos) { int32u Size = BigEndian2int24u(Buffer + Buffer_Offset + (size_t)Slices_BufferPos - tail); Size += tail; if (Slices_BufferPos < Size) Slices_BufferPos = Size; Slices_BufferPos-=Size; Slices_BufferSizes.insert(Slices_BufferSizes.begin(), Size); } Element_Offset=0; for (size_t Pos = 0; Pos < Slices_BufferSizes.size(); Pos++) { Element_Begin1("Slice"); int64u End=Element_Offset+Slices_BufferSizes[Pos]-tail; int32u crc_left=0; if (error_correction == 1) crc_left=CRC_Compute(Slices_BufferSizes[Pos]); if (Pos) { delete RC; RC = new RangeCoder(Buffer+Buffer_Offset+(size_t)Element_Offset, Slices_BufferSizes[Pos], state_transitions_table); } else // ac=2 RC->AssignStateTransitions(state_transitions_table); #if MEDIAINFO_TRACE if (Trace_Activated) // Parse slice only if trace feature is activated { int64u Start=Element_Offset; Trace_Activated=false; slice(States); Trace_Activated=true; int64u SliceRealSize=Element_Offset-Start; Element_Offset=Start; Skip_XX(SliceRealSize, "slice_data"); if (Trusted_Get()) Param_Info1("OK"); else Param_Info1("NOK"); } #endif //MEDIAINFO_TRACE if (Element_Offset!=End) Skip_XX(End-Element_Offset, "Other data"); Skip_B3( "slice_size"); if (error_correction == 1) { Skip_B1( "error_status"); Skip_B4( "crc_parity"); if (!crc_left) Param_Info1("OK"); else Param_Info1("NOK"); } Element_End0(); } } FILLING_BEGIN(); Frame_Count++; FILLING_END(); delete RC; RC = NULL; Fill(); if (Config->ParseSpeed<1.0) Finish(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Ffv1::FrameHeader() { //Parsing states States; memset(States, 128, states_size); int32u coder_type, colorspace_type, bits_per_raw_sample=8, num_h_slices_minus1=0, num_v_slices_minus1=0, intra; micro_version = 0; Get_RU (States, version, "version"); if (( ConfigurationRecordIsPresent && version<=1) || (!ConfigurationRecordIsPresent && version> 1)) { Trusted_IsNot("Invalid version in global header"); return; } if (version>2) Get_RU (States, micro_version, "micro_version"); Get_RU (States, coder_type, "coder_type"); this->coder_type = coder_type; if (coder_type == 2) //Range coder with custom state transition table { Element_Begin1("state_transition_deltas"); for (int16u i = 1; i < state_transitions_size; i++) { int32s state_transition_delta; Get_RS (States, state_transition_delta, "state_transition_delta"); state_transitions_table[i]=state_transition_delta+RC->one_state[i]; Param_Info1(state_transitions_table[i]); } Element_End0(); } Get_RU (States, colorspace_type, "colorspace_type"); this->colorspace_type = colorspace_type; if (version) { Get_RU (States, bits_per_raw_sample, "bits_per_raw_sample"); if (bits_per_raw_sample==0) bits_per_raw_sample=8; //I don't know the reason, 8-bit is coded 0 and 10-bit coded 10 (not 2?). this->bits_per_sample = bits_per_raw_sample; } Get_RB (States, chroma_planes, "chroma_planes"); Get_RU (States, chroma_h_shift, "log2(h_chroma_subsample)"); Get_RU (States, chroma_v_shift, "log2(v_chroma_subsample)"); Get_RB (States, alpha_plane, "alpha_plane"); if (version>1) { Get_RU (States, num_h_slices_minus1, "num_h_slices_minus1"); Get_RU (States, num_v_slices_minus1, "num_v_slices_minus1"); num_h_slices = num_h_slices_minus1 + 1; num_v_slices = num_v_slices_minus1 + 1; Get_RU (States, quant_table_count, "quant_table_count"); } else quant_table_count=1; if (!slices) { size_t nb_slices = (num_h_slices_minus1 + 1) * (num_v_slices_minus1 + 1); slices = new Slice[nb_slices]; current_slice = &slices[0]; } for (size_t i = 0; i < quant_table_count; i++) read_quant_tables(i); memset(quant_tables+quant_table_count, 0x00, (MAX_QUANT_TABLES-quant_table_count)*MAX_CONTEXT_INPUTS*256*sizeof(int16s)); for (size_t i = 0; i < quant_table_count; i++) { Element_Begin1("initial_state"); bool present; Get_RB (States, present, "present"); if (coder_type) plane_states[i] = new int8u* [context_count[i]]; for (size_t j = 0; j < context_count[i]; j++) { if (coder_type) plane_states[i][j] = new int8u [states_size]; if (present) { Element_Begin1("initial_state"); for (size_t k = 0; k < states_size; k++) { int32s value; Get_RS (States, value, "value"); if (coder_type) plane_states[i][j][k] = value; } Element_End0(); } else if (coder_type) { for (size_t k = 0; k < states_size; k++) plane_states[i][j][k] = 128; } } Element_End0(); } if (version > 2) { Get_RU (States, error_correction, "ec"); if (micro_version) Get_RU (States, intra, "intra"); } FILLING_BEGIN(); if (Frame_Count==0) { Accept(); Ztring Version=__T("Version ")+Ztring::ToZtring(version); if (version>2) { Version+=__T('.'); Version+=Ztring::ToZtring(micro_version); } Fill(Stream_Video, 0, "coder_type", Ffv1_coder_type(coder_type)); Fill(Stream_Video, 0, Video_Format_Version, Version); Fill(Stream_Video, 0, Video_BitDepth, bits_per_raw_sample); if (version > 1) { Fill(Stream_Video, 0, "MaxSlicesCount", (num_h_slices_minus1+1)*(num_v_slices_minus1+1)); } if (version > 2) { if (error_correction) Fill(Stream_Video, 0, "ErrorDetectionType", "Per slice"); if (micro_version && intra) Fill(Stream_Video, 0, Video_Format_Settings_GOP, "N=1"); } Fill(Stream_Video, 0, Video_ColorSpace, Ffv1_colorspace_type(colorspace_type, chroma_planes, alpha_plane)); if (colorspace_type==0 && chroma_planes) { string ChromaSubsampling; switch (chroma_h_shift) { case 0 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:4:4"; break; default: ; } break; case 1 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:2:2"; break; case 1 : ChromaSubsampling="4:2:0"; break; default: ; } break; case 2 : switch (chroma_v_shift) { case 0 : ChromaSubsampling="4:1:1"; break; case 1 : ChromaSubsampling="4:1:0"; break; case 2 : ChromaSubsampling="4:1:0 (4x4)"; break; default: ; } break; default: ; } if (!ChromaSubsampling.empty() && alpha_plane) ChromaSubsampling+=":4"; Fill(Stream_Video, 0, Video_ChromaSubsampling, ChromaSubsampling); } } FILLING_END(); } //--------------------------------------------------------------------------- void File_Ffv1::slice(states &States) { if (version>2) { slice_header(States); } if (!coder_type) { if ((version == 3 && micro_version > 1) || version > 3) { states States; memset(States, 129, states_size); Skip_RC(States, "?"); if ((version > 2 || (!current_slice->x && !current_slice->y))) Element_Offset--; else Element_Offset=0; BS_Begin(); } } if (keyframe) { int8u plane_count=1+(alpha_plane?1:0); if (version < 4 || chroma_planes) // Warning: chroma is considered as 1 plane plane_count+=1; if (!coder_type) current_slice->contexts_init(plane_count, quant_table_index, context_count); else copy_plane_states_to_slice(plane_count); } current_slice->sample_buffer_new((current_slice->w + 6) * 3 * MAX_PLANES); if (colorspace_type == 0) { // YCbCr plane(0); // Y if (chroma_planes) { int32u w = current_slice->w; int32u h = current_slice->h; current_slice->w = current_slice->w >> chroma_h_shift; current_slice->h = current_slice->h >> chroma_v_shift; plane(1); // Cb plane(1); // Cr current_slice->w = w; current_slice->h = h; } if (alpha_plane) plane(2); // Alpha } else if (colorspace_type == 1) rgb(); if (!coder_type && ((version == 3 && micro_version > 1) || version > 3)) BS_End(); if (coder_type && version > 2) { int8u s = 129; RC->get_rac(&s); Element_Offset=RC->Buffer_Cur-Buffer; Element_Offset--; } } //--------------------------------------------------------------------------- void File_Ffv1::slice_header(states &States) { memset(States, 128, states_size); int32u slice_x, slice_y, slice_width, slice_height; Get_RU (States, slice_x, "slice_x"); Get_RU (States, slice_y, "slice_y"); Get_RU (States, slice_width, "slice_width_minus1"); Get_RU (States, slice_height, "slice_height_minus1"); current_slice = &slices[slice_x + slice_y * num_h_slices]; current_slice->w = (slice_width + 1) * (Width / num_h_slices); current_slice->h = (slice_height + 1) * (Height / num_v_slices); current_slice->x = slice_x * current_slice->w; current_slice->y = slice_y * current_slice->h; int8u plane_count=1+(alpha_plane?1:0); if (version < 4 || chroma_planes) // Warning: chroma is considered as 1 plane plane_count += 1; for (int8u i = 0; i < plane_count; i++) Get_RU (States, quant_table_index[i], "quant_table_index"); Skip_RU(States, "picture_structure"); Skip_RU(States, "sample_aspect_ratio num"); Skip_RU(States, "sample_aspect_ratio den"); if (version > 3) { //TODO } RC->AssignStateTransitions(state_transitions_table); } //--------------------------------------------------------------------------- void File_Ffv1::plane(int32u pos) { Element_Begin1("Plane"); int16s *sample[2]; sample[0] = current_slice->sample_buffer + 3; sample[1] = current_slice->sample_buffer + current_slice->w + 6 + 3; memset(current_slice->sample_buffer, 0, 2 * (current_slice->w + 6) * sizeof(*current_slice->sample_buffer)); current_slice->run_index = 0; for (size_t y = 0; y < current_slice->h; y++) { Element_Begin1("Line"); Element_Info1(y); int16s *temp = sample[0]; sample[0] = sample[1]; sample[1] = temp; sample[1][-1] = sample[0][0]; sample[0][current_slice->w] = sample[0][current_slice->w - 1]; if (bits_per_sample <= 8) bits_max = 8; else bits_max = bits_per_sample; line(pos, sample); Element_End0(); } Element_End0(); } //--------------------------------------------------------------------------- void File_Ffv1::rgb() { Element_Begin1("rgb"); int16s *sample[4][2]; current_slice->run_index = 0; for (int x = 0; x < 4; x++) { sample[x][0] = current_slice->sample_buffer + x * 2 * (current_slice->w + 6) + 3; sample[x][1] = current_slice->sample_buffer + (x * 2 + 1) * (current_slice->w + 6) + 3; } memset(current_slice->sample_buffer, 0, 8 * (current_slice->w + 6) * sizeof(*current_slice->sample_buffer)); for (size_t y = 0; y < current_slice->h; y++) { Element_Begin1("Line"); Element_Info1(y); for (size_t c = 0; c < (unsigned)(3 + alpha_plane); c++) { // Copy for next lines: 4.3 context int16s *temp = sample[c][0]; sample[c][0] = sample[c][1]; sample[c][1] = temp; sample[c][1][-1]= sample[c][0][0 ]; sample[c][0][current_slice->w]= sample[c][0][current_slice->w - 1]; bits_max = bits_per_sample + 1; line((c + 1) / 2, sample[c]); } Element_End0(); } Element_End0(); } static inline int get_context(int16s quant_table[MAX_CONTEXT_INPUTS][256], int16s *src, int16s *last, int16s *last2) { const int LT = last[-1]; const int T = last[0]; const int RT = last[1]; const int L = src[-1]; if (quant_table[3][127]) { const int TT = last2[0]; const int LL = src[-2]; return quant_table[0][(L - LT) & 0xFF] + quant_table[1][(LT - T) & 0xFF] + quant_table[2][(T - RT) & 0xFF] + quant_table[3][(LL - L) & 0xFF] + quant_table[4][(TT - T) & 0xFF]; } else return quant_table[0][(L - LT) & 0xFF] + quant_table[1][(LT - T) & 0xFF] + quant_table[2][(T - RT) & 0xFF]; } //--------------------------------------------------------------------------- int32s File_Ffv1::line_range_coder(int32s pos, int32s context) { int32s u; Get_RS(current_slice->plane_states[pos][context], u, "symbol"); return u; } //--------------------------------------------------------------------------- int32s File_Ffv1::line_adaptive_symbol_by_symbol(size_t x, int32s pos, int32s context) { int32s u; // New symbol, go to "run mode" if (context == 0 && current_slice->run_mode == RUN_MODE_STOP) current_slice->run_mode = RUN_MODE_PROCESSING; // If not running, get the symbol if (current_slice->run_mode == RUN_MODE_STOP) { u = get_symbol_with_bias_correlation(¤t_slice->contexts[pos][context]); #if MEDIAINFO_TRACE Param("symbol", u); #endif //MEDIAINFO_TRACE return u; } if (current_slice->run_segment_length == 0 && current_slice->run_mode == RUN_MODE_PROCESSING) // Same symbol length { bool hits; Get_SB (hits, "hits/miss"); //if (bsf.GetB()) // "hits" if (hits) // "hits" { current_slice->run_segment_length = 1 << log2_run[current_slice->run_index]; if (x + current_slice->run_segment_length <= current_slice->w) //Do not go further as the end of line ++current_slice->run_index; } else // "miss" { //current_slice->run_segment_length = bsf.Get4(log2_run[current_slice->run_index]); int32u run_segment_length; Get_S4 (log2_run[current_slice->run_index], run_segment_length, "run_segment_length"); current_slice->run_segment_length=(int32s)run_segment_length; if (current_slice->run_index) --current_slice->run_index; current_slice->run_mode = RUN_MODE_INTERRUPTED; } } current_slice->run_segment_length--; if (current_slice->run_segment_length < 0) // we passed the length of same symbol, time to get the new symbol { u = get_symbol_with_bias_correlation(¤t_slice->contexts[pos][context]); #if MEDIAINFO_TRACE Param("symbol", u); #endif //MEDIAINFO_TRACE if (u >= 0) // GR(u - 1, ...) u++; // Time for the new symbol length run current_slice->run_mode_init(); current_slice->run_segment_length = 0; } else // same symbol as previous pixel, no difference, waiting u = 0; return u; } //--------------------------------------------------------------------------- void File_Ffv1::line(int pos, int16s *sample[2]) { // TODO: slice_coding_mode (version 4) if (!coder_type) { current_slice->run_segment_length = 0; current_slice->run_mode_init(); } for (size_t x = 0; x < current_slice->w; x++) { int32s context; context = get_context(quant_tables[quant_table_index[pos]], sample[1] + x, sample[0] + x, sample[1] + x); bool negative = false; // Step 7 if (context < 0) { context = -context; negative = true; } int32s u; if (coder_type) u = line_range_coder(pos, context); else u = line_adaptive_symbol_by_symbol(x, pos, context); // Step 7 if (negative) u = -u; sample[1][x] = (predict(sample[1] + x, sample[0] + x) + u) & ((1 << bits_max) -1); } } //--------------------------------------------------------------------------- void File_Ffv1::read_quant_tables(int i) { Element_Begin1("quant_table"); int32u scale = 1; for (int j = 0; j < 5; j++) { read_quant_table(i, j, scale); scale *= 2 * len_count[i][j] - 1; if (scale > 32768U) { Element_End0(); return; } context_count[i] = (scale + 1) / 2; } Element_End0(); } //--------------------------------------------------------------------------- void File_Ffv1::read_quant_table(int i, int j, size_t scale) { Element_Begin1("per context"); ; int8u States[states_size]; memset(States, 128, sizeof(States)); int v = 0; for (int k=0; k < 128;) { int32u len_minus1; Get_RU (States, len_minus1, "len_minus1"); if (k+len_minus1 >= 128) { Element_End0(); return; } for (size_t a=0; a<=len_minus1; a++) { quant_tables[i][j][k] = scale * v; k++; } v++; } for (int k = 1; k < 128; k++) quant_tables[i][j][256 - k] = -quant_tables[i][j][k]; quant_tables[i][j][128] = -quant_tables[i][j][127]; len_count[i][j]=v; Element_End0(); } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- int32u File_Ffv1::CRC_Compute(size_t Size) { int32u CRC_32=0; const int8u* CRC_32_Buffer=Buffer+Buffer_Offset+(size_t)Element_Offset; const int8u* CRC_32_Buffer_End=CRC_32_Buffer+Size; while(CRC_32_Buffer>24)^(*CRC_32_Buffer)]; CRC_32_Buffer++; } return CRC_32; } //--------------------------------------------------------------------------- int32s File_Ffv1::get_median_number(int32s one, int32s two, int32s three) { if (one > two) { // one > two > three if (two > three) return two; // three > one > two if (three > one) return one; // one > three > two return three; } // three > two > one if (three > two) return two; // two > one && two > three // two > three > one if (three > one) return three; return one; } //--------------------------------------------------------------------------- int32s File_Ffv1::predict(int16s *current, int16s *current_top) { int32s LeftTop = current_top[-1]; int32s Top = current_top[0]; int32s Left = current[-1]; return get_median_number(Left, Left + Top - LeftTop, Top); } //--------------------------------------------------------------------------- int32s File_Ffv1::golomb_rice_decode(int k) { int32u q = 0; int32u v; //while (bsf.Remain() > 0 && q < PREFIX_MAX && !bsf.GetB()) while (Data_BS_Remain() > 0 && q < PREFIX_MAX) { bool Temp; Get_SB(Temp, "golomb_rice_prefix_0"); if (Temp) break; ++q; } if (q == PREFIX_MAX) // ESC { //v = bsf.Get4(bits_max) + 11; Get_S4(bits_max, v, "escaped_value_minus_11"); v+=11; } else { //int32u remain = bsf.Get8(k); // Read k bits int32u remain; Get_S4(k, remain, "golomb_rice_remain"); int32u mul = q << k; // q * pow(2, k) v = mul | remain; } // unsigned to signed int32s code = (v >> 1) ^ -(v & 1); return code; } //--------------------------------------------------------------------------- int32s File_Ffv1::get_symbol_with_bias_correlation(Slice::Context *context) { int k = 0; // Step 8: compute the Golomb parameter k for (k = 0; (context->N << k) < context->A; ++k); // Step 10: Decode Golomb code (using limitation PREFIX_MAX == 12) int32s code = golomb_rice_decode(k); // Step 9: Mapping int32s M = 2 * context->B + context->N; code = code ^ (M >> 31); // Step 11 context->B += code; context->A += code >= 0 ? code : -code; code += context->C; update_correlation_value_and_shift(context); // Step 7 (TODO better way) bool neg = code & (1 << (bits_max - 1)); // check if the number is negative code = code & ((1 << (bits_max - 1)) - 1); // Keep only the n bits if (neg) code = - 1 - (~code & ((1 << (bits_max - 1)) - 1)); // 0xFFFFFFFF - positive value on n bits return code; } //--------------------------------------------------------------------------- void File_Ffv1::update_correlation_value_and_shift(Slice::Context *c) { if (!c) return; // Step 11: Resets if (c->N == c->N0) { // divide by 2, if >= 0 : ROUND, otherwise, CEIL c->N >>= 1; c->A >>= 1; c->B >>= 1; } ++c->N; // context meets // Step 12: Bias computation procedure // Keep B in (-N;0] if (c->B <= -c->N) { if (c->C > c->Cmin) --c->C; c->B = c->B + c->N; if (c->B <= -c->N) c->B = -c->N + 1; } else if (c->B > 0) { if (c->C < c->Cmax) ++c->C; c->B = c->B - c->N; if (c->B > 0) c->B = 0; } } //--------------------------------------------------------------------------- void File_Ffv1::copy_plane_states_to_slice(int8u plane_count) { if (!coder_type) return; for (size_t i = 0; i < plane_count; i++) { int32u idx = quant_table_index[i]; if (!current_slice->plane_states[i]) { current_slice->plane_states[i] = new int8u* [context_count[idx] + 1]; memset(current_slice->plane_states[i], 0, (context_count[idx] + 1) * sizeof(int8u*)); } for (size_t j = 0; j < context_count[idx]; j++) { if (!current_slice->plane_states[i][j]) current_slice->plane_states[i][j] = new int8u [states_size]; for (size_t k = 0; k < states_size; k++) { current_slice->plane_states[i][j][k] = plane_states[idx][j][k]; } } } } //--------------------------------------------------------------------------- void File_Ffv1::plane_states_clean(states_context_plane states[MAX_QUANT_TABLES]) { if (!coder_type) return; for (size_t i = 0; i < MAX_QUANT_TABLES && states[i]; ++i) { for (size_t j = 0; states[i][j]; ++j) delete[] states[i][j]; delete[] states[i]; states[i] = NULL; } } } //NameSpace #endif //MEDIAINFO_FFV1_YES MediaInfoLib/Source/MediaInfo/Video/File_Fraps.h0000664000000000000000000000255612652076434020405 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_HuffYuv.h0000664000000000000000000000263612652076434020725 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about HUFFYUV files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_HuffYUVH #define MediaInfo_HuffYUVH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_HuffYuv //*************************************************************************** class File_HuffYuv : public File__Analyze { public : //In bool IsOutOfBandData; int16u BitCount; int32u Height; //Constructor/Destructor File_HuffYuv(); private : //Streams management void Streams_Accept(); //Buffer - Global void Read_Buffer_Continue(); //Elements void FrameHeader(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_AfdBarData.cpp0000664000000000000000000003057112652076434021574 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Video/File_Avc.h0000664000000000000000000006036412652076434020044 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef MediaInfo_AvcH #define MediaInfo_AvcH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include "MediaInfo/File__Duplicate.h" #include //--------------------------------------------------------------------------- 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 : File_Avc(const File_Avc &File_Avc); //No copy //Structures - seq_parameter_set struct seq_parameter_set_struct { struct vui_parameters_struct { struct xxl { struct xxl_data { //HRD configuration int64u bit_rate_value; int64u cpb_size_value; bool cbr_flag; //sei_message_buffering_period //int32u initial_cpb_removal_delay; //int32u initial_cpb_removal_delay_offset; xxl_data(int64u bit_rate_value_, int64u cpb_size_value_, bool cbr_flag_) //int32u initial_cpb_removal_delay_, int32u initial_cpb_removal_delay_offset_) : bit_rate_value(bit_rate_value_), cpb_size_value(cpb_size_value_), cbr_flag(cbr_flag_) //initial_cpb_removal_delay(initial_cpb_removal_delay_), //initial_cpb_removal_delay_offset(initial_cpb_removal_delay_offset_) { } xxl_data &operator=(const xxl_data &x) { bit_rate_value=x.bit_rate_value; cpb_size_value=x.cpb_size_value; cbr_flag=x.cbr_flag; //initial_cpb_removal_delay=x.initial_cpb_removal_delay; //initial_cpb_removal_delay_offset=x.initial_cpb_removal_delay_offset; return *this; } private: xxl_data(); }; vector SchedSel; int8u initial_cpb_removal_delay_length_minus1; int8u cpb_removal_delay_length_minus1; int8u dpb_output_delay_length_minus1; int8u time_offset_length; xxl(const vector &SchedSel_, int8u initial_cpb_removal_delay_length_minus1_, int8u cpb_removal_delay_length_minus1_, int8u dpb_output_delay_length_minus1_, int8u time_offset_length_) : SchedSel(SchedSel_), initial_cpb_removal_delay_length_minus1(initial_cpb_removal_delay_length_minus1_), cpb_removal_delay_length_minus1(cpb_removal_delay_length_minus1_), dpb_output_delay_length_minus1(dpb_output_delay_length_minus1_), time_offset_length(time_offset_length_) { } xxl &operator=(const xxl &x) { SchedSel=x.SchedSel; initial_cpb_removal_delay_length_minus1=x.initial_cpb_removal_delay_length_minus1; cpb_removal_delay_length_minus1=x.cpb_removal_delay_length_minus1; dpb_output_delay_length_minus1=x.dpb_output_delay_length_minus1; time_offset_length=x.time_offset_length; return *this; } private: xxl(); }; struct bitstream_restriction_struct { int8u max_num_reorder_frames; bitstream_restriction_struct(int8u max_num_reorder_frames_) : max_num_reorder_frames(max_num_reorder_frames_) { } bitstream_restriction_struct &operator=(const bitstream_restriction_struct &b) { max_num_reorder_frames=b.max_num_reorder_frames; return *this; } private: bitstream_restriction_struct(); }; 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 video_full_range_flag; 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(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 video_full_range_flag_, 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_) : NAL(NAL_), VCL(VCL_), bitstream_restriction(bitstream_restriction_), num_units_in_tick(num_units_in_tick_), time_scale(time_scale_), sar_width(sar_width_), sar_height(sar_height_), aspect_ratio_idc(aspect_ratio_idc_), video_format(video_format_), video_full_range_flag(video_full_range_flag_), colour_primaries(colour_primaries_), transfer_characteristics(transfer_characteristics_), matrix_coefficients(matrix_coefficients_), aspect_ratio_info_present_flag(aspect_ratio_info_present_flag_), video_signal_type_present_flag(video_signal_type_present_flag_), colour_description_present_flag(colour_description_present_flag_), timing_info_present_flag(timing_info_present_flag_), fixed_frame_rate_flag(fixed_frame_rate_flag_), pic_struct_present_flag(pic_struct_present_flag_) { } ~vui_parameters_struct() { delete NAL; //NAL=NULL; delete VCL; //VCL=NULL; delete bitstream_restriction; //bitstream_restriction=NULL; } private: vui_parameters_struct &operator=(const vui_parameters_struct &v); vui_parameters_struct(); }; vui_parameters_struct* vui_parameters; #if MEDIAINFO_DEMUX int8u* Iso14496_10_Buffer; size_t Iso14496_10_Buffer_Size; #endif //MEDIAINFO_DEMUX 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; //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(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_, 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_, 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_) : vui_parameters(vui_parameters_), #if MEDIAINFO_DEMUX Iso14496_10_Buffer(NULL), Iso14496_10_Buffer_Size(0), #endif //MEDIAINFO_DEMUX pic_width_in_mbs_minus1(pic_width_in_mbs_minus1_), pic_height_in_map_units_minus1(pic_height_in_map_units_minus1_), frame_crop_left_offset(frame_crop_left_offset_), frame_crop_right_offset(frame_crop_right_offset_), frame_crop_top_offset(frame_crop_top_offset_), frame_crop_bottom_offset(frame_crop_bottom_offset_), num_views_minus1(0), chroma_format_idc(chroma_format_idc_), profile_idc(profile_idc_), level_idc(level_idc_), bit_depth_luma_minus8(bit_depth_luma_minus8_), bit_depth_chroma_minus8(bit_depth_chroma_minus8_), log2_max_frame_num_minus4(log2_max_frame_num_minus4_), pic_order_cnt_type(pic_order_cnt_type_), log2_max_pic_order_cnt_lsb_minus4(log2_max_pic_order_cnt_lsb_minus4_), max_num_ref_frames(max_num_ref_frames_), pic_struct_FirstDetected((int8u)-1), //For stats only, init constraint_set3_flag(constraint_set3_flag_), separate_colour_plane_flag(separate_colour_plane_flag_), delta_pic_order_always_zero_flag(delta_pic_order_always_zero_flag_), frame_mbs_only_flag(frame_mbs_only_flag_), mb_adaptive_frame_field_flag(mb_adaptive_frame_field_flag_) { switch (pic_order_cnt_type) { case 0 : MaxPicOrderCntLsb = (int32u)std::pow(2.0, (int)(log2_max_pic_order_cnt_lsb_minus4 + 4)); MaxFrameNum = (int32u)-1; //Unused break; case 1 : case 2 : MaxPicOrderCntLsb = (int32u)-1; //Unused MaxFrameNum = (int32u)std::pow(2.0, (int)(log2_max_frame_num_minus4 + 4)); break; default: MaxFrameNum = (int32u)-1; //Unused MaxPicOrderCntLsb = (int32u)-1; //Unused } } ~seq_parameter_set_struct() { delete vui_parameters; //vui_parameters=NULL; #if MEDIAINFO_DEMUX delete[] Iso14496_10_Buffer; #endif //MEDIAINFO_DEMUX } private: seq_parameter_set_struct &operator=(const seq_parameter_set_struct &v); seq_parameter_set_struct(); }; typedef vector seq_parameter_set_structs; //Structures - pic_parameter_set struct pic_parameter_set_struct { #if MEDIAINFO_DEMUX int8u* Iso14496_10_Buffer; size_t Iso14496_10_Buffer_Size; #endif //MEDIAINFO_DEMUX 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; int32u num_slice_groups_minus1; int32u slice_group_map_type; 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 deblocking_filter_control_present_flag; //Constructor/Destructor 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_, int32u num_slice_groups_minus1_, int32u slice_group_map_type_, 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 deblocking_filter_control_present_flag_) : #if MEDIAINFO_DEMUX Iso14496_10_Buffer(NULL), Iso14496_10_Buffer_Size(0), #endif //MEDIAINFO_DEMUX seq_parameter_set_id(seq_parameter_set_id_), num_ref_idx_l0_default_active_minus1(num_ref_idx_l0_default_active_minus1_), num_ref_idx_l1_default_active_minus1(num_ref_idx_l1_default_active_minus1_), weighted_bipred_idc(weighted_bipred_idc_), num_slice_groups_minus1(num_slice_groups_minus1_), slice_group_map_type(slice_group_map_type_), entropy_coding_mode_flag(entropy_coding_mode_flag_), bottom_field_pic_order_in_frame_present_flag(bottom_field_pic_order_in_frame_present_flag_), weighted_pred_flag(weighted_pred_flag_), redundant_pic_cnt_present_flag(redundant_pic_cnt_present_flag_), deblocking_filter_control_present_flag(deblocking_filter_control_present_flag_) { } ~pic_parameter_set_struct() { #if MEDIAINFO_DEMUX delete[] Iso14496_10_Buffer; #endif //MEDIAINFO_DEMUX } private: pic_parameter_set_struct &operator=(const pic_parameter_set_struct &v); pic_parameter_set_struct(); }; typedef vector pic_parameter_set_structs; //Streams management void Streams_Fill(); void Streams_Fill(vector::iterator seq_parameter_set_Item); void Streams_Fill_subset(vector::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(); bool Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10; #endif //MEDIAINFO_DEMUX //Buffer - Global #if MEDIAINFO_ADVANCED2 void Read_Buffer_SegmentChange(); #endif //MEDIAINFO_ADVANCED2 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 slice_data (bool AllCategories); 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(seq_parameter_set_struct::vui_parameters_struct::xxl* 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_user_data_unregistered_bluray(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 seq_parameter_set_struct* seq_parameter_set_data(int32u &Data_id); void seq_parameter_set_data_Add(vector &Data, const int32u Data_id, seq_parameter_set_struct* Data_Item_New); void seq_parameter_set_svc_extension(); void seq_parameter_set_mvc_extension(seq_parameter_set_struct* Data_Item); void scaling_list(int32u ScalingList_Size); void vui_parameters(seq_parameter_set_struct::vui_parameters_struct* &vui_parameters_Item); void svc_vui_parameters_extension(); void mvc_vui_parameters_extension(); void hrd_parameters(seq_parameter_set_struct::vui_parameters_struct::xxl* &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 &memory_management_control_operations); //Packets - Specific void SPS_PPS(); //Streams struct stream { bool Searching_Payload; bool ShouldDuplicate; stream() : Searching_Payload(false), ShouldDuplicate(false) { } }; vector 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_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 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; #if MEDIAINFO_ADVANCED2 std::vector Dump_SPS; std::vector Dump_PPS; #endif //MEDIAINFO_ADVANCED2 //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 MediaInfoLib/Source/MediaInfo/Video/File_Vc3.h0000664000000000000000000000446412652076434017765 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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; float64 FrameRate; //constructor/Destructor File_Vc3(); ~File_Vc3(); private : //Streams management void Streams_Fill(); void Streams_Finish(); //Buffer - Synchro bool Synchronize(); bool Synched_Test(); //Buffer - Demux #if MEDIAINFO_DEMUX bool Demux_UnpacketizeContainer_Test(); #endif //MEDIAINFO_DEMUX //Buffer - Global void Read_Buffer_Unsynched(); //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 UserData_8(); void MacroblockScanIndices(); //Parsers #if defined(MEDIAINFO_CDP_YES) File__Analyze* Cdp_Parser; #endif //defined(MEDIAINFO_CDP_YES) //Temp int32u CID; bool CRCF; int16u ALPF; int16u SPL; int8u SBD; int8u FFC_FirstFrame; int8u HVN; int8u CLR; bool SST; bool SSC; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Vc1.h0000664000000000000000000001021412652076434017751 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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(); ~File_Vc1(); private : //Streams management void Streams_Accept(); 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 PictureFormat_Count; //From SequenceHeader std::vector 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 Streams; //Temporal reference struct temporalreference { bool top_field_first; bool repeat_first_field; }; std::map TemporalReference; //int32u is the reference std::vector 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; float64 FrameRate; size_t RefFramesCount; //Error controls std::vector Frame_ShouldBe; #if MEDIAINFO_DEMUX int8u* InitData_Buffer; size_t InitData_Buffer_Size; #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_H263.cpp0000664000000000000000000003466312652076434020313 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 "MediaInfo/MediaInfo_Config_MediaInfo.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=MediaInfoLib::Config.ParseSpeed_Get()>=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_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-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 MediaInfoLib/Source/MediaInfo/Video/File_Vp8.cpp0000664000000000000000000000755412652076434020345 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 "MediaInfo/MediaInfo_Config_MediaInfo.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=MediaInfoLib::Config.ParseSpeed_Get()>=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_T4(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 MediaInfoLib/Source/MediaInfo/Video/File_AvsV.cpp0000664000000000000000000007314312652076434020544 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_Offset0) //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()) { UnSynched_IsNotJunk=true; 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-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<=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_Offset0) 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=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_* MediaInfoLib/Source/MediaInfo/Video/File_AfdBarData.h0000664000000000000000000000511212652076434021232 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_Canopus.h0000664000000000000000000000245112652076434020734 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Canopus streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_CanopusH #define MediaInfo_File_CanopusH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Theora //*************************************************************************** class File_Canopus : public File__Analyze { public : //Constructor/Destructor File_Canopus(); private : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue (); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Avc.cpp0000664000000000000000000054276612652076434020412 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 138 : return "Multiview Depth High"; case 144 : return "High 4:4:4"; case 244 : return "High 4:4:4 Predictive"; default : return ""; } } //--------------------------------------------------------------------------- } //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_ADVANCED2 #include "base64.h" #endif //MEDIAINFO_ADVANCED2 #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #include #include using namespace std; using namespace ZenLib; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- const size_t Avc_Errors_MaxCount=32; //--------------------------------------------------------------------------- extern const int8u Avc_PixelAspectRatio_Size=17; extern const float32 Avc_PixelAspectRatio[Avc_PixelAspectRatio_Size]= { (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_video_full_range[]= { "Limited", "Full", }; //--------------------------------------------------------------------------- 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* Mpegv_colour_primaries(int8u colour_primaries); const char* Mpegv_transfer_characteristics(int8u transfer_characteristics); const char* Mpegv_matrix_coefficients(int8u matrix_coefficients); //--------------------------------------------------------------------------- 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; //Temporal references TemporalReferences_DelayedElement=NULL; //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::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::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); } #if MEDIAINFO_ADVANCED2 for (size_t Pos = 0; Pos::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_info_present_flag) { if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idcvui_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->timing_info_present_flag && (*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]); Fill(Stream_Video, 0, Video_colour_range, Avc_video_full_range[(*seq_parameter_set_Item)->vui_parameters->video_full_range_flag]); if ((*seq_parameter_set_Item)->vui_parameters->colour_description_present_flag) { Fill(Stream_Video, 0, Video_colour_description_present, "Yes"); Fill(Stream_Video, 0, Video_colour_primaries, Mpegv_colour_primaries((*seq_parameter_set_Item)->vui_parameters->colour_primaries)); Fill(Stream_Video, 0, Video_transfer_characteristics, Mpegv_transfer_characteristics((*seq_parameter_set_Item)->vui_parameters->transfer_characteristics)); Fill(Stream_Video, 0, Video_matrix_coefficients, Mpegv_matrix_coefficients((*seq_parameter_set_Item)->vui_parameters->matrix_coefficients)); } } //hrd_parameter_sets int64u bit_rate_value=(int64u)-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; PosSchedSel.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!=(int64u)-1 && bit_rate_value!=NAL->SchedSel[Pos].bit_rate_value) bit_rate_value_IsValid=false; if (bit_rate_value==(int64u)-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; PosSchedSel.size(); Pos++) { Fill(Stream_Video, 0, Video_BufferSize, VCL->SchedSel[Pos].cpb_size_value); if (bit_rate_value!=(int64u)-1 && bit_rate_value!=VCL->SchedSel[Pos].bit_rate_value) bit_rate_value_IsValid=false; if (bit_rate_value==(int64u)-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!=(int64u)-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)); switch ((*seq_parameter_set_Item)->profile_idc) { case 44 : // CAVLC 4:4:4 Intra case 100 : // High case 110 : // High 10 case 122 : // High 4:2:2" case 244 : // High 4:4:4 Predictive if ((*seq_parameter_set_Item)->constraint_set3_flag) Profile+=__T(" Intra"); } Profile+=__T("@L")+Ztring().From_Number(((float)(*seq_parameter_set_Item)->level_idc)/10, ((*seq_parameter_set_Item)->level_idc%10)?1:0); 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); if ((*seq_parameter_set_Item)->frame_crop_left_offset || (*seq_parameter_set_Item)->frame_crop_right_offset) Fill(Stream_Video, StreamPos_Last, Video_Stored_Width, ((*seq_parameter_set_Item)->pic_width_in_mbs_minus1 +1)*16); if ((*seq_parameter_set_Item)->frame_crop_top_offset || (*seq_parameter_set_Item)->frame_crop_bottom_offset) Fill(Stream_Video, StreamPos_Last, Video_Stored_Height, ((*seq_parameter_set_Item)->pic_height_in_map_units_minus1+1)*16*(2-(*seq_parameter_set_Item)->frame_mbs_only_flag)); 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_Frame>0 && Structure_Field==0)) //No interlaced frame { switch ((*seq_parameter_set_Item)->pic_struct_FirstDetected) { case 3 : Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); Fill(Stream_Video, 0, Video_Interlacement, "TFF"); Fill(Stream_Video, 0, Video_Format_Settings_PictureStructure, "Frame"); Fill(Stream_Video, 0, Video_ScanType_StoreMethod, "InterleavedFields"); break; case 4 : Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); Fill(Stream_Video, 0, Video_Interlacement, "BFF"); Fill(Stream_Video, 0, Video_Format_Settings_PictureStructure, "Frame"); Fill(Stream_Video, 0, Video_ScanType_StoreMethod, "InterleavedFields"); break; default : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); Fill(Stream_Video, 0, Video_Interlacement, "PPF"); } } else if (Structure_Field>0) { 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; PosIsTop?'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_ScanType_StoreMethod, "SeparatedFields", Unlimited, true, true); } else { switch ((*seq_parameter_set_Item)->pic_struct_FirstDetected) { case 1 : Fill(Stream_Video, 0, Video_ScanOrder, (string) "TFF"); Fill(Stream_Video, 0, Video_ScanType_StoreMethod, "SeparatedFields", Unlimited, true, true); break; case 2 : Fill(Stream_Video, 0, Video_ScanOrder, (string) "BFF"); Fill(Stream_Video, 0, Video_ScanType_StoreMethod, "SeparatedFields", Unlimited, true, true); break; case 3 : Fill(Stream_Video, 0, Video_ScanOrder, (string) "TFF"); Fill(Stream_Video, 0, Video_ScanType_StoreMethod, "InterleavedFields", Unlimited, true, true); break; case 4 : Fill(Stream_Video, 0, Video_ScanOrder, (string) "BFF"); Fill(Stream_Video, 0, Video_ScanType_StoreMethod, "InterleavedFields", Unlimited, true, true); break; default : ; } } } Fill(Stream_Video, 0, Video_Format_Settings_GOP, GOP_Detect(PictureTypes)); Fill(Stream_General, 0, General_Encoded_Library, Encoded_Library); Fill(Stream_General, 0, General_Encoded_Library_Name, Encoded_Library_Name); Fill(Stream_General, 0, General_Encoded_Library_Version, Encoded_Library_Version); Fill(Stream_General, 0, General_Encoded_Library_Settings, Encoded_Library_Settings); 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::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); } if ((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->matrix_coefficients == 0) Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); else 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(const std::vector::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]) { Clear(Stream_Text); Finish(GA94_03_Parser); Merge(*GA94_03_Parser); Ztring LawRating=GA94_03_Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=GA94_03_Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); for (size_t Pos=0; Posvui_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_IBIUSAGE } //*************************************************************************** // 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 size_t Buffer_Offset_Min=Buffer_Offset; 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-1]==0x00) Buffer_Offset--; } if (Buffer_Offset>Buffer_Offset_Min && 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 (Buffer[Buffer_Offset ]!=0x00 || Buffer[Buffer_Offset+1]!=0x00 || (Buffer[Buffer_Offset+2]!=0x01 && (Buffer[Buffer_Offset+2]!=0x00 || Buffer[Buffer_Offset+3]!=0x01))) { Synched=false; return true; } //Quick search if (!Header_Parser_QuickSearch()) return false; #if MEDIAINFO_IBIUSAGE 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_IBIUSAGE //We continue return true; } //*************************************************************************** // Buffer - Demux //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX bool File_Avc::Demux_UnpacketizeContainer_Test() { const int8u* Buffer_Temp=NULL; size_t Buffer_Temp_Size=0; bool RandomAccess=true; //Default, in case of problem if ((MustParse_SPS_PPS || SizedBlocks) && Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10) { if (MustParse_SPS_PPS) return true; //Wait for SPS and PPS //Random access check RandomAccess=false; //Computing final size size_t TranscodedBuffer_Size=0; while (Buffer_Offset+SizeOfNALU_Minus1+1+1<=Buffer_Size) { size_t Size; switch (SizeOfNALU_Minus1) { case 0: Size=Buffer[Buffer_Offset]; TranscodedBuffer_Size+=2; break; case 1: Size=BigEndian2int16u(Buffer+Buffer_Offset); TranscodedBuffer_Size++; break; case 2: Size=BigEndian2int24u(Buffer+Buffer_Offset); break; case 3: Size=BigEndian2int32u(Buffer+Buffer_Offset); TranscodedBuffer_Size--; break; default: return true; //Problem } Size+=SizeOfNALU_Minus1+1; //Coherency checking if (Size==0 || Buffer_Offset+Size>Buffer_Size || (Buffer_Offset+Size!=Buffer_Size && Buffer_Offset+Size+SizeOfNALU_Minus1+1>Buffer_Size)) Size=Buffer_Size-Buffer_Offset; //Random access check if (!RandomAccess && Buffer_Offset+SizeOfNALU_Minus1+1Iso14496_10_Buffer_Size; for (seq_parameter_set_structs::iterator Data_Item=subset_seq_parameter_sets.begin(); Data_Item!=subset_seq_parameter_sets.end(); ++Data_Item) TranscodedBuffer_Size+=(*Data_Item)->Iso14496_10_Buffer_Size; for (pic_parameter_set_structs::iterator Data_Item=pic_parameter_sets.begin(); Data_Item!=pic_parameter_sets.end(); ++Data_Item) TranscodedBuffer_Size+=(*Data_Item)->Iso14496_10_Buffer_Size; } //Copying int8u* TranscodedBuffer=new int8u[TranscodedBuffer_Size+100]; size_t TranscodedBuffer_Pos=0; if (RandomAccess) { for (seq_parameter_set_structs::iterator Data_Item=seq_parameter_sets.begin(); Data_Item!=seq_parameter_sets.end(); ++Data_Item) { std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, (*Data_Item)->Iso14496_10_Buffer, (*Data_Item)->Iso14496_10_Buffer_Size); TranscodedBuffer_Pos+=(*Data_Item)->Iso14496_10_Buffer_Size; } for (seq_parameter_set_structs::iterator Data_Item=subset_seq_parameter_sets.begin(); Data_Item!=subset_seq_parameter_sets.end(); ++Data_Item) { std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, (*Data_Item)->Iso14496_10_Buffer, (*Data_Item)->Iso14496_10_Buffer_Size); TranscodedBuffer_Pos+=(*Data_Item)->Iso14496_10_Buffer_Size; } for (pic_parameter_set_structs::iterator Data_Item=pic_parameter_sets.begin(); Data_Item!=pic_parameter_sets.end(); ++Data_Item) { std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, (*Data_Item)->Iso14496_10_Buffer, (*Data_Item)->Iso14496_10_Buffer_Size); TranscodedBuffer_Pos+=(*Data_Item)->Iso14496_10_Buffer_Size; } } while (Buffer_OffsetBuffer_Size || (Buffer_Offset+Size!=Buffer_Size && Buffer_Offset+Size+SizeOfNALU_Minus1+1>Buffer_Size)) Size=Buffer_Size-Buffer_Offset; std::memcpy(TranscodedBuffer+TranscodedBuffer_Pos, Buffer+Buffer_Offset, Size); TranscodedBuffer_Pos+=Size; Buffer_Offset+=Size; } Buffer_Offset=0; Buffer_Temp=Buffer; Buffer=TranscodedBuffer; Buffer_Temp_Size=Buffer_Size; Buffer_Size=TranscodedBuffer_Size; Demux_Offset=Buffer_Size; } else { 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[Demux_Offset-1]==0x00) Demux_Offset--; } if (Demux_Offset+6>Buffer_Size) { if (File_Offset+Buffer_Size==File_Size) Demux_Offset=Buffer_Size; break; } 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_SizeDemux_EventWasSent) return false; File_Avc* MI=new File_Avc; Element_Code=(int64u)-1; Open_Buffer_Init(MI); Open_Buffer_Continue(MI, Buffer, Buffer_Size); bool IsOk=MI->Status[IsAccepted]; delete MI; if (!IsOk) 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(); if (Buffer_Temp) { Demux_TotalBytes-=Buffer_Size; Demux_TotalBytes+=Buffer_Temp_Size; delete[] Buffer; Buffer=Buffer_Temp; Buffer_Size=Buffer_Temp_Size; } 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 #if MEDIAINFO_DEMUX Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10=Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get(); #endif //MEDIAINFO_DEMUX } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED2 void File_Avc::Read_Buffer_SegmentChange() { } #endif //MEDIAINFO_ADVANCED2 //--------------------------------------------------------------------------- void File_Avc::Read_Buffer_Unsynched() { //Temporal references for (size_t Pos=0; PosOpen_Buffer_Unsynch(); #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES) //parameter_sets if (SizedBlocks) //If sized blocks, it is not a broadcasted stream so SPS/PPS are only in container header, we must not disable them. { //Rebuilding immediatly TemporalReferences for (std::vector::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)) { size_t MaxNumber; switch ((*seq_parameter_set_Item)->pic_order_cnt_type) { case 0 : MaxNumber=(*seq_parameter_set_Item)->MaxPicOrderCntLsb; break; case 2 : MaxNumber=(*seq_parameter_set_Item)->MaxFrameNum*2; break; default: Trusted_IsNot("Not supported"); return; } TemporalReferences.resize(4*MaxNumber); TemporalReferences_Reserved=MaxNumber; } } else { seq_parameter_sets.clear(); subset_seq_parameter_sets.clear(); pic_parameter_sets.clear(); } //Status 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_BEGIN(); Header_Fill_Size(Size?(Element_Offset-1+Size):(Buffer_Size-Buffer_Offset)); //If Size is 0, it is not normal, we skip the complete frame FILLING_END(); } //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-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 start if (Streams[start_code].Searching_Payload || Streams[start_code].ShouldDuplicate) return true; //Synchronizing Buffer_Offset+=4; Synched=false; if (!Synchronize()) { UnSynched_IsNotJunk=true; return false; } if (Buffer_Offset+6>Buffer_Size) { UnSynched_IsNotJunk=true; 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--; } //Dump of the SPS/PPS - Init #if MEDIAINFO_ADVANCED2 size_t spspps_Size=0; if (true) //TODO: add an option for activating this extra piece of information in the output { switch (Element_Code) { case 0x07 : //seq_parameter_set(); spspps_Size = seq_parameter_sets.size(); break; case 0x08 : //pic_parameter_set(); spspps_Size = pic_parameter_sets.size(); break; default: ; } } #endif //MEDIAINFO_ADVANCED2 //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 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-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 #if MEDIAINFO_DEMUX if (Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10) { if (Element_Code==0x07) { std::vector::iterator Data_Item=seq_parameter_sets.begin(); if (Data_Item!=seq_parameter_sets.end() && (*Data_Item)) { delete[] (*Data_Item)->Iso14496_10_Buffer; (*Data_Item)->Iso14496_10_Buffer_Size=(size_t)(Element_Size+4); (*Data_Item)->Iso14496_10_Buffer=new int8u[(*Data_Item)->Iso14496_10_Buffer_Size]; (*Data_Item)->Iso14496_10_Buffer[0]=0x00; (*Data_Item)->Iso14496_10_Buffer[1]=0x00; (*Data_Item)->Iso14496_10_Buffer[2]=0x01; (*Data_Item)->Iso14496_10_Buffer[3]=0x67; std::memcpy((*Data_Item)->Iso14496_10_Buffer+4, Buffer+Buffer_Offset, (size_t)Element_Size); } } if (Element_Code==0x08) { std::vector::iterator Data_Item=pic_parameter_sets.begin(); if (Data_Item!=pic_parameter_sets.end() && (*Data_Item)) { delete[] (*Data_Item)->Iso14496_10_Buffer; (*Data_Item)->Iso14496_10_Buffer_Size=(size_t)(Element_Size+4); (*Data_Item)->Iso14496_10_Buffer=new int8u[(*Data_Item)->Iso14496_10_Buffer_Size]; (*Data_Item)->Iso14496_10_Buffer[0]=0x00; (*Data_Item)->Iso14496_10_Buffer[1]=0x00; (*Data_Item)->Iso14496_10_Buffer[2]=0x01; (*Data_Item)->Iso14496_10_Buffer[3]=0x68; std::memcpy((*Data_Item)->Iso14496_10_Buffer+4, Buffer+Buffer_Offset, (size_t)Element_Size); } } if (Element_Code==0x0F) { std::vector::iterator Data_Item=subset_seq_parameter_sets.begin(); if (Data_Item!=subset_seq_parameter_sets.end() && (*Data_Item)) { SizeOfNALU_Minus1=0; delete[] (*Data_Item)->Iso14496_10_Buffer; (*Data_Item)->Iso14496_10_Buffer_Size=(size_t)(Element_Size+4); (*Data_Item)->Iso14496_10_Buffer=new int8u[(*Data_Item)->Iso14496_10_Buffer_Size]; (*Data_Item)->Iso14496_10_Buffer[0]=0x00; (*Data_Item)->Iso14496_10_Buffer[1]=0x00; (*Data_Item)->Iso14496_10_Buffer[2]=0x01; (*Data_Item)->Iso14496_10_Buffer[3]=0x6F; std::memcpy((*Data_Item)->Iso14496_10_Buffer+4, Buffer+Buffer_Offset, (size_t)Element_Size); } } } #endif //MEDIAINFO_DEMUX //Dump of the SPS/PPS - Fill #if MEDIAINFO_ADVANCED2 if (false) //TODO: add an option for activating this extra piece of information in the output { switch (Element_Code) { case 0x07 : //seq_parameter_set(); if (spspps_Size != seq_parameter_sets.size() && !Status[IsFilled]) { std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset-1)), (size_t)(Element_Size+1)); //Including the last byte in the header Dump_SPS.push_back(Base64::encode(Data_Raw)); } break; case 0x08 : //pic_parameter_set(); if (spspps_Size != pic_parameter_sets.size() && !Status[IsFilled]) { std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset-1)), (size_t)(Element_Size+1)); //Including the last byte in the header Dump_PPS.push_back(Base64::encode(Data_Raw)); } break; default: ; } } #endif //MEDIAINFO_ADVANCED2 //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 BS_Begin(); slice_header(); slice_data(true); BS_End(); } //--------------------------------------------------------------------------- // Packet "05" void File_Avc::slice_layer_without_partitioning_IDR() { Element_Name("slice_layer_without_partitioning (IDR)"); //Parsing BS_Begin(); slice_header(); slice_data(true); BS_End(); FILLING_BEGIN_PRECISE(); //NextCode for (int8u Pos=0x01; Pos<=0x05; Pos++) NextCode_Add(Pos); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Avc::slice_header() { //Encryption management if (CA_system_ID_MustSkipSlices) { //Is not decodable Skip_BS(Data_BS_Remain(), "Data"); Finish("AVC"); return; } Element_Begin1("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, disable_deblocking_filter_idc, num_slice_groups_minus1, slice_group_map_type; int32s delta_pic_order_cnt_bottom=0; bool field_pic_flag=false, bottom_field_flag=false; 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 { EVENT_BEGIN (Video, SliceInfo, 0) 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; EVENT_END () } #endif //MEDIAINFO_EVENTS if (slice_type>=10) { Skip_BS(Data_BS_Remain(), "Data"); Element_End0(); return; } Get_UE (pic_parameter_set_id, "pic_parameter_set_id"); std::vector::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) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (pic_parameter_set is missing)"); Element_End0(); return; } std::vector::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) { 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) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)"); Element_End0(); return; } } if ((*seq_parameter_set_Item)->separate_colour_plane_flag==1) Skip_S1(2, "color_plane_id"); 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) //IdrPicFlag 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 memory_management_control_operations; if (nal_ref_idc) dec_ref_pic_marking(memory_management_control_operations); if ((*pic_parameter_set_Item)->entropy_coding_mode_flag && (slice_type!=2 && slice_type!=7 && //I-Frames slice_type!=4 && slice_type!=9)) //SI-Frames Skip_UE( "cabac_init_idc"); Skip_SE( "slice_qp_delta"); switch (slice_type) { case 3 : //SP-Frame case 4 : //SI-Frame case 8 : //SP-Frame case 9 : //SI-Frame switch (slice_type) { case 3 : //SP-Frame case 8 : //SP-Frame Skip_SB( "sp_for_switch_flag"); break; default: ; } Skip_SE ( "slice_qs_delta"); break; default: ; } if ((*pic_parameter_set_Item)->deblocking_filter_control_present_flag) { Get_UE(disable_deblocking_filter_idc, "disable_deblocking_filter_idc"); if (disable_deblocking_filter_idc!=1) { Skip_SE( "slice_alpha_c0_offset_div2"); Skip_SE( "slice_beta_offset_div2"); } } num_slice_groups_minus1=(*pic_parameter_set_Item)->num_slice_groups_minus1; //Default slice_group_map_type=(*pic_parameter_set_Item)->slice_group_map_type; //Default //if (num_slice_groups_minus1 > 0 && slice_group_map_type >=3 && slice_group_map_type <=5) // Get_BS ((*seq_parameter_set_Item)->log2_max_slice_group_change_cycle_minus4+4, slice_group_change_cycle, "slice_group_change_cycle"); Element_End0(); FILLING_BEGIN(); //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 || seq_parameter_sets.empty())) //Not slice_layer_extension except if MVC only { 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::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))max_num_ref_frames+3); } else if (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::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 { tempPicOrderCnt=2*(FrameNumOffset+frame_num); if (!nal_ref_idc && tempPicOrderCnt) //Note: if nal_ref_idc is 0, tempPicOrderCnt is not expected to be 0 but it may be the case with invalid streams tempPicOrderCnt--; } pic_order_cnt=tempPicOrderCnt; prevFrameNum=frame_num; prevFrameNumOffset=FrameNumOffset; pic_order_cnt_lsb=frame_num; } break; default: ; } if (pic_order_cnt=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 (pic_order_cnt<0 && TemporalReferences_Offset<(size_t)(-pic_order_cnt)) //Found in playreadyEncryptedBlowUp.ts without encryption test { Trusted_IsNot("Problem in temporal references"); return; } if ((size_t)(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; Posslice_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_Reservedframe_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->timing_info_present_flag && (*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 MEDIAINFO_ADVANCED2 if (PTS_Begin_Segment==(int64u)-1 && File_Offset>=Config->File_Current_Offset) { PTS_Begin_Segment=FrameInfo.PTS; } #endif //MEDIAINFO_ADVANCED2 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 && (Element_Code!=0x14 || seq_parameter_sets.empty())) //Not slice_layer_extension except if MVC only { 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; Posslice_type]; } else if (!PictureTypes.empty()) //Only if stream already started { if ((Pos%2)==0) PictureTypes+=' '; } #if defined(MEDIAINFO_DTVCCTRANSPORT_YES) if (!GOP_Detect(PictureTypes).empty() && !GA94_03_IsPresent) Frame_Count_Valid=Frame_Count; //We have enough frames #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES) } } } #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 && (FrameInfo.PTS>PTS_End || (PTS_End>1000000000 && FrameInfo.PTS<=PTS_End-1000000000))) //More than current PTS_End or less than current PTS_End minus 1 second (there is a problem?) 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 defined(MEDIAINFO_DTVCCTRANSPORT_YES) if (!GA94_03_IsPresent && IFrame_Count>=8) Frame_Count_Valid=Frame_Count; //We have enough frames #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES) if (Frame_Count>=Frame_Count_Valid) { Fill("AVC"); if (!IsSub && !Streams[(size_t)Element_Code].ShouldDuplicate && MediaInfoLib::Config.ParseSpeed_Get()<1.0) Finish("AVC"); } } FILLING_END(); } //--------------------------------------------------------------------------- // void File_Avc::slice_data(bool AllCategories) { Element_Begin1("slice_data"); Skip_BS(Data_BS_Remain(), "(ToDo)"); Element_End0(); } //--------------------------------------------------------------------------- // 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 &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+1Element_Size) { Trusted_IsNot("Wrong size"); Skip_XX(Element_Size-Element_Offset, "unknown"); return; } 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 if (Element_Offset==Element_Size) return; //Nothing to do BS_Begin(); Get_UE (seq_parameter_set_id, "seq_parameter_set_id"); std::vector::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) { //Not yet present Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)"); BS_End(); 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(seq_parameter_set_struct::vui_parameters_struct::xxl* xxl) { if (xxl==NULL) return; for (int32u SchedSelIdx=0; SchedSelIdxSchedSel.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"); Info_S4 (xxl->initial_cpb_removal_delay_length_minus1+1, initial_cpb_removal_delay, "initial_cpb_removal_delay"); Param_Info2(initial_cpb_removal_delay/90, " ms"); Info_S4 (xxl->initial_cpb_removal_delay_length_minus1+1, initial_cpb_removal_delay_offset, "initial_cpb_removal_delay_offset"); Param_Info2(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::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) { //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; iCpbDpbDelaysPresentFlag()) { 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->timing_info_present_flag && (*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); } Element_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_framesFormat=File_DtvccTransport::Format_A53_4_GA94_03; } if (((File_DtvccTransport*)GA94_03_Parser)->AspectRatio==0) { float64 PixelAspectRatio=1; std::vector::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_info_present_flag) { if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idcvui_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) { int8u Demux_Level_Save=Demux_Level; Demux_Level=8; //Ancillary Demux(TemporalReferences[TemporalReferences_Min]->GA94_03->Data, TemporalReferences[TemporalReferences_Min]->GA94_03->Size, ContentType_MainStream); Demux_Level=Demux_Level_Save; } Element_Code=Element_Code_Old; #endif //MEDIAINFO_DEMUX if (TemporalReferences[TemporalReferences_Min]->GA94_03) { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) GA94_03_Parser->ServiceDescriptors=ServiceDescriptors; #endif 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 | !TemporalReferences[TemporalReferences_Min]->IsField)?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; case 0xD9114Df8608CEE17LL : Element_Info1("Blu-ray"); sei_message_user_data_unregistered_bluray(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_Before=0; size_t Loop=0; do { size_t 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_Before=Data_Pos_Before; Encoded_Library_Settings.clear(); do { size_t 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 - 5 - x264 void File_Avc::sei_message_user_data_unregistered_bluray(int32u payloadSize) { if (payloadSize<4) { Skip_XX(payloadSize, "Unknown"); return; } int32u Identifier; Get_B4 (Identifier, "Identifier"); switch (Identifier) { case 0x47413934 : sei_message_user_data_registered_itu_t_t35_GA94_03(); return; default : Skip_XX(Element_Size-Element_Offset, "Unknown"); } } //--------------------------------------------------------------------------- // 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; seq_parameter_set_struct* Data_Item_New=seq_parameter_set_data(seq_parameter_set_id); if (!Data_Item_New) 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 &Data, const int32u Data_id, seq_parameter_set_struct* Data_Item_New) { //Creating Data if (Data_id>=Data.size()) Data.resize(Data_id+1); std::vector::iterator Data_Item=Data.begin()+Data_id; delete *Data_Item; *Data_Item=Data_Item_New; //Computing values (for speed) size_t MaxNumber; switch (Data_Item_New->pic_order_cnt_type) { case 0 : MaxNumber=Data_Item_New->MaxPicOrderCntLsb; break; case 1 : case 2 : MaxNumber=Data_Item_New->MaxFrameNum*2; break; default: MaxNumber = 0; } if (MaxNumber>TemporalReferences_Reserved) { TemporalReferences.resize(4*MaxNumber); TemporalReferences_Reserved=MaxNumber; } } //--------------------------------------------------------------------------- // 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, slice_group_map_type=0; int8u weighted_bipred_idc=0; bool entropy_coding_mode_flag,bottom_field_pic_order_in_frame_present_flag, redundant_pic_cnt_present_flag, weighted_pred_flag, deblocking_filter_control_present_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::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) { if (seq_parameter_set_id>=subset_seq_parameter_sets.size() || (*(seq_parameter_set_Item=subset_seq_parameter_sets.begin()+seq_parameter_set_id))==NULL) { //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) { 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((*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"); Get_SB (deblocking_filter_control_present_flag, "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 (Bit_Pos && !(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?((*seq_parameter_set_Item)->chroma_format_idc!=3?2:6):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=256) { Trusted_IsNot("pic_parameter_set_id not valid"); return; //Problem, not valid } if (seq_parameter_set_id>=32) { 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::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( (int8u)seq_parameter_set_id, (int8u)num_ref_idx_l0_default_active_minus1, (int8u)num_ref_idx_l1_default_active_minus1, weighted_bipred_idc, num_slice_groups_minus1, slice_group_map_type, entropy_coding_mode_flag, bottom_field_pic_order_in_frame_present_flag, weighted_pred_flag, redundant_pic_cnt_present_flag, deblocking_filter_control_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_Offsetprofile_idc==83 || Data_Item_New->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 (Data_Item_New->profile_idc==118 || Data_Item_New->profile_idc==128) { //bool mvc_vui_parameters_present_flag, additional_extension2_flag; Mark_1(); seq_parameter_set_mvc_extension(Data_Item_New); /* 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); //Add seq_parameter_set_data_Add(subset_seq_parameter_sets, subset_seq_parameter_set_id, Data_Item_New); //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 { BS_Begin(); slice_header(); slice_data(true); BS_End(); } } //*************************************************************************** // SubElements //*************************************************************************** //--------------------------------------------------------------------------- File_Avc::seq_parameter_set_struct* File_Avc::seq_parameter_set_data(int32u &Data_id) { //Parsing seq_parameter_set_struct::vui_parameters_struct* 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( "constraint_set4_flag"); Skip_SB( "constraint_set5_flag"); Skip_BS(2, "reserved_zero_2bits"); 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 case 138 : 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<(int32u)((chroma_format_idc!=3) ? 8 : 12); 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 NULL; } for(int32u Pos=0; Pos 2) { Trusted_IsNot("pic_order_cnt_type not supported"); return NULL; } 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 NULL; //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 NULL; //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 NULL; //Problem, not valid } //Creating Data return new seq_parameter_set_struct( vui_parameters_Item, pic_width_in_mbs_minus1, pic_height_in_map_units_minus1, frame_crop_left_offset, frame_crop_right_offset, frame_crop_top_offset, frame_crop_bottom_offset, (int8u)chroma_format_idc, profile_idc, 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, constraint_set3_flag, separate_colour_plane_flag, delta_pic_order_always_zero_flag, frame_mbs_only_flag, mb_adaptive_frame_field_flag ); FILLING_ELSE(); delete vui_parameters_Item; //vui_parameters_Item=NULL; return NULL; FILLING_END(); } //--------------------------------------------------------------------------- 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; Pos31) { Trusted_IsNot("cpb_cnt_minus1 too high"); cpb_cnt_minus1=0; } vector SchedSel; SchedSel.reserve(cpb_cnt_minus1+1); for (int8u SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; ++SchedSelIdx) { Element_Begin1("ShedSel"); int64u bit_rate_value, cpb_size_value; int32u bit_rate_value_minus1, cpb_size_value_minus1; bool cbr_flag; Get_UE (bit_rate_value_minus1, "bit_rate_value_minus1"); bit_rate_value=(int64u)((bit_rate_value_minus1+1)*pow(2.0, 6+bit_rate_scale)); Param_Info2(bit_rate_value, " bps"); Get_UE (cpb_size_value_minus1, "cpb_size_value_minus1"); cpb_size_value=(int64u)((cpb_size_value_minus1+1)*pow(2.0, 4+cpb_size_scale)); Param_Info2(cpb_size_value, " bits"); Get_SB (cbr_flag, "cbr_flag"); Element_End0(); FILLING_BEGIN(); SchedSel.push_back(seq_parameter_set_struct::vui_parameters_struct::xxl::xxl_data( bit_rate_value, cpb_size_value, cbr_flag )); FILLING_END(); } 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() || (SchedSel.size() == 1 && SchedSel[0].bit_rate_value == 64)) { return; //We do not trust this kind of data } //Filling hrd_parameters_Item_=new seq_parameter_set_struct::vui_parameters_struct::xxl( SchedSel, initial_cpb_removal_delay_length_minus1, cpb_removal_delay_length_minus1, dpb_output_delay_length_minus1, 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(seq_parameter_set_struct* Data_Item) { //Parsing Element_Begin1("seq_parameter_set_mvc_extension"); int32u num_views_minus1; Get_UE (num_views_minus1, "num_views_minus1"); //(Not implemented) Element_End0(); FILLING_BEGIN(); Data_Item->num_views_minus1 = (int16u)num_views_minus1; 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; PosElement_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; PosElement_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_Offsetprofile_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; PosMaxLength) { MaxLength=List[Pos].size(); MaxLength_Pos=Pos; } PictureTypes=List[MaxLength_Pos].To_Local(); } } //Creating all GOP values std::vector 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 P_Positions; size_t P_Position=I_Pos1; do { P_Position=PictureTypes.find('P', P_Position+1); if (P_Position1 && 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; PosGOP_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; PosScanOrders.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; PosMaxLength) { 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 MediaInfoLib/Source/MediaInfo/Video/File_Aic.h0000664000000000000000000000251112652076434020015 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Apple Intermediate Codec video streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_AicH #define MediaInfo_AicH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Aic //*************************************************************************** class File_Aic : public File__Analyze { private : //Streams management void Streams_Fill(); //Buffer - Per element void Header_Parse (); void Data_Parse (); //Temp int16u Width; int16u Height; int8u FieldFrame; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Video/File_Mpeg4v.h0000664000000000000000000001242612652076434020471 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about MPEG-4 Visual files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Mpeg4vH #define MediaInfo_Mpeg4vH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 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; int8u colour_primaries; int8u transfer_characteristics; int8u matrix_coefficients; 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; bool colour_description; //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 MediaInfoLib/Source/MediaInfo/Video/File_H263.h0000664000000000000000000000350012652076434017742 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Video/File_ProRes.h0000664000000000000000000000244212652076434020536 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about ProRes files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_ProResH #define MediaInfo_File_ProResH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Lagarith //*************************************************************************** class File_ProRes : public File__Analyze { public : //Constructor/Destructor File_ProRes(); private : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue (); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/0000775000000000000000000000000012652076434016205 5ustar rootrootMediaInfoLib/Source/MediaInfo/Audio/File_Midi.h0000664000000000000000000000224412652076434020201 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Ps2Audio.cpp0000664000000000000000000001031412652076434021275 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 //--------------------------------------------------------------------------- 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(); void audio_data_Layer3(); //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 BitRate_Count; std::map sampling_frequency_Count; std::map 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(); #if MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED int8u sampling_frequency_Frame0; int8u mode_Frame0; bool File_Demux_Unpacketize_StreamLayoutChange_Skip; #endif //MEDIAINFO_ADVANCED #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Amr.cpp0000664000000000000000000002027712652076434020377 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Vorbis.h0000664000000000000000000000240112652076434020556 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Ps2Audio.h0000664000000000000000000000206712652076434020750 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_SmpteSt0337.h0000664000000000000000000000453012652076434021233 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Non-PCM Audio and Data in an AES3 // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_SmpteSt0337H #define MediaInfo_File_SmpteSt0337H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_SmpteSt0337 //*************************************************************************** class File_SmpteSt0337 : public File__Analyze { public : // In int8u Container_Bits; int8u Endianness; bool Aligned; // Constructor/Destructor File_SmpteSt0337(); ~File_SmpteSt0337(); private : // Streams management void Streams_Accept(); void Streams_Fill(); // Buffer - Global #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 float64 FrameRate; int8u Stream_Bits; int8u data_type; std::map FrameSizes; int64u GuardBand_Before; int64u GuardBand_After; size_t NullPadding_Size; // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Tta.h0000664000000000000000000000304212652076434020044 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about TTA files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_TtaH #define MediaInfo_File_TtaH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_Module.h0000664000000000000000000000236412652076434020547 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Pcm_M2ts.cpp0000664000000000000000000001512512652076434021300 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PCMM2TS_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_Pcm_M2ts.h" #if MEDIAINFO_DEMUX #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- 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, }; //--------------------------------------------------------------------------- extern const char* Pcm_VOB_ChannelsPositions(int8u channel_assignment); extern const char* Pcm_VOB_ChannelsPositions2(int8u channel_assignment); //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Pcm_M2ts::File_Pcm_M2ts() { //Configuration ParserName=__T("PCM M2TS"); IsRawStream=true; PTS_DTS_Needed=true; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Pcm_M2ts::Streams_Fill() { Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "PCM"); Fill(Stream_Audio, 0, Audio_Codec, "PCM"); Fill(Stream_Audio, 0, Audio_Codec_Family, "PCM"); Fill(Stream_Audio, 0, Audio_MuxingMode, "Blu-ray"); Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR"); int8u Channels=Pcm_M2TS_channel_assignment[channel_assignment]; 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]); } } Fill(Stream_Audio, 0, Audio_Format_Settings, "Big"); Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Big"); Fill(Stream_Audio, 0, Audio_Codec_Settings, "Big"); Fill(Stream_Audio, 0, Audio_Codec_Settings_Endianness, "Big"); Fill(Stream_Audio, 0, Audio_Format_Settings, "Signed"); Fill(Stream_Audio, 0, Audio_Format_Settings_Sign, "Signed"); Fill(Stream_Audio, 0, Audio_Codec_Settings, "Signed"); Fill(Stream_Audio, 0, Audio_Codec_Settings_Sign, "Signed"); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Pcm_M2ts::Read_Buffer_Continue() { if (Buffer_Size==0) return; //Parsing int16u audio_data_payload_size; 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(); if (!Status[IsAccepted]) { Accept(); Finish(); } FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_PCMM2TS_YES MediaInfoLib/Source/MediaInfo/Audio/File_Mpc.h0000664000000000000000000000310312652076434020031 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Musepack files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_MpcH #define MediaInfo_File_MpcH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_Aac_GeneralAudio.cpp0000664000000000000000000015502212652076434022760 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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(); bool front1_element_is_cpe=false; if (!num_side_channel_elements && num_back_channel_elements && num_back_channel_elements<3) // Hack: e.g. in case of 5.1, { num_side_channel_elements=num_back_channel_elements; num_back_channel_elements=0; } for (int8u Pos=0; Pos24) // TODO: full_2023548870.mp4 is buggy { Trusted_IsNot("sampling frequency / channels"); 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; Infos["ChannelLayout"]=ChannelLayout; 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)?(Frequency_b*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)?(Frequency_b*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 (sampling_frequency_index>=13) { Trusted_IsNot("(Problem)"); Skip_BS(Data_BS_Remain(), "(Problem)"); return; } if (audioObjectType!=2) { Skip_BS(Data_BS_Remain(), "Data"); return; //We test only AAC LC } //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]); #if MEDIAINFO_TRACE bool Trace_Activated_Save=Trace_Activated; Trace_Activated=false; //It is too big, disabling trace for now for full AAC parsing #endif //MEDIAINFO_TRACE 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 } #if MEDIAINFO_TRACE Trace_Activated=Trace_Activated_Save; #endif //MEDIAINFO_TRACE 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(); } //--------------------------------------------------------------------------- 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; gAac_PRED_SFB_MAX[sampling_frequency_index]) PRED_SFB_MAX=Aac_PRED_SFB_MAX[sampling_frequency_index]; for (int8u sfb=0; sfbnum_swb; for (int8u i=0; iswb_offset[i]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; iswb_offset[i]; swb_offset[num_swb] = frame_length/8; for (int8u i=0; iswb_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=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; wd1) Element_Begin1("windows"); int8u k=0; int8u i=0; while (k11 && 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 (int16u sfb=k; sfb64) { Trusted_IsNot("Increment is wrong"); if (num_window_groups>1) Element_End0(); Element_End0(); return; //Error } } 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; g1) Element_Begin1("windows"); for (int8u i=0; 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]]; k1) 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: ; } break; case 0 : //EXT_FILL default: Skip_BS(Data_BS_Remain()-End, "other_bits"); } Element_End0(); if (EndEnd) 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=hcb_table_size[CodeBook]) { Skip_BS(Data_BS_Remain(), "Error"); return; } for (int8u Pos=0; Pos24) 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 MediaInfoLib/Source/MediaInfo/Audio/File_ChannelGrouping.cpp0000664000000000000000000004510212652076434022735 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_SMPTEST0337_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_ChannelGrouping.h" #if defined(MEDIAINFO_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.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 "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 BitDepth=0; SamplingRate=0; Endianness=0; Aligned=false; CanBePcm=false; Common=NULL; Channel_Pos=0; Channel_Total=1; } File_ChannelGrouping::~File_ChannelGrouping() { Common->Instances--; if (Common->Instances==0) { for (size_t Pos=0; PosChannels.size(); Pos++) delete Common->Channels[Pos]; //Common->Channels[Pos]=NULL; delete Common; //Common=NULL; } } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_ChannelGrouping::Streams_Fill() { Fill(Stream_General, 0, General_Format, "ChannelGrouping"); if (Channel_Pos!=Common->Channels.size()-1) return; if (Common->Parsers.size()!=1 && CanBePcm) // Last parser is PCM, impossible to detect with another method if htere is only one block { for (size_t Pos=0; PosParsers.size()-1; Pos++) delete Common->Parsers[Pos]; Common->Parsers.erase(Common->Parsers.begin(), Common->Parsers.begin()+Common->Parsers.size()-1); Common->Parsers[0]->Accept(); Common->Parsers[0]->Fill(); } if (Common->Parsers.size()!=1) return; Fill(Common->Parsers[0]); Merge(*Common->Parsers[0]); } //--------------------------------------------------------------------------- void File_ChannelGrouping::Streams_Finish() { if (Channel_Pos!=Common->Channels.size()-1 || Common->Parsers.size()!=1) return; Finish(Common->Parsers[0]); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_ChannelGrouping::Read_Buffer_Init() { if (Common==NULL) { //Common Common=new common; Common->Channels.resize(Channel_Total); for (size_t Pos=0; PosChannels.size(); Pos++) Common->Channels[Pos]=new common::channel; Element_Code=(int64u)-1; //SMPTE ST 337 { File_SmpteSt0337* Parser=new File_SmpteSt0337; Parser->Container_Bits=BitDepth; Parser->Endianness=Endianness; Parser->Aligned=Aligned; Common->Parsers.push_back(Parser); } //PCM if (CanBePcm) { File_Pcm* Parser=new File_Pcm; Parser->BitDepth=BitDepth; Parser->Channels=Channel_Total; Parser->SamplingRate=SamplingRate; Parser->Endianness=Endianness; Common->Parsers.push_back(Parser); } //for all parsers for (size_t Pos=0; PosParsers.size(); Pos++) { #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) { Common->Parsers[Pos]->Demux_UnpacketizeContainer=true; Common->Parsers[Pos]->Demux_Level=2; //Container Demux_Level=4; //Intermediate } #endif //MEDIAINFO_DEMUX Open_Buffer_Init(Common->Parsers[Pos]); } } Common->Instances++; Common->Instances_Max++; } //--------------------------------------------------------------------------- void File_ChannelGrouping::Read_Buffer_Continue() { //Verifying that all instances are still present if (Common->Instances!=Common->Instances_Max) { Reject(); return; } //Handling of multiple frames in one block if (Buffer_Size==0) { Offsets_Stream.clear(); Offsets_Buffer.clear(); for (size_t Pos=0; PosParsers.size(); Pos++) Open_Buffer_Continue(Common->Parsers[Pos], Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, 0, false); return; } //Demux #if MEDIAINFO_DEMUX 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>Common->Channels[Channel_Pos]->Buffer_Size_Max) Common->Channels[Channel_Pos]->resize(Common->Channels[Channel_Pos]->Buffer_Size+Buffer_Size); memcpy(Common->Channels[Channel_Pos]->Buffer+Common->Channels[Channel_Pos]->Buffer_Size, Buffer, Buffer_Size); Common->Channels[Channel_Pos]->Buffer_Size+=Buffer_Size; Common->Channels[Channel_Pos]->Offsets_Stream.insert(Common->Channels[Channel_Pos]->Offsets_Stream.begin(), Offsets_Stream.begin(), Offsets_Stream.end()); Offsets_Stream.clear(); Common->Channels[Channel_Pos]->Offsets_Buffer.insert(Common->Channels[Channel_Pos]->Offsets_Buffer.begin(), Offsets_Buffer.begin(), Offsets_Buffer.end()); Offsets_Buffer.clear(); Skip_XX(Buffer_Size, "Channel grouping data"); 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; PosChannels.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; if (Minimum*8>=BitDepth) { for (size_t Pos=0; PosChannels.size(); Pos++) { Common->MergedChannel.Offsets_Stream.insert(Common->MergedChannel.Offsets_Stream.end(), Common->Channels[Pos]->Offsets_Stream.begin(), Common->Channels[Pos]->Offsets_Stream.end()); Common->Channels[Pos]->Offsets_Stream.clear(); Common->MergedChannel.Offsets_Buffer.insert(Common->MergedChannel.Offsets_Buffer.end(), Common->Channels[Pos]->Offsets_Buffer.begin(), Common->Channels[Pos]->Offsets_Buffer.end()); Common->Channels[Pos]->Offsets_Buffer.clear(); } while (Minimum*8>=BitDepth) { switch (BitDepth) { case 16: // Source: 16XE / L3L2 L1L0 + R3R2 R1R0 // Dest : 16XE / L3L2 L1L0 R3R2 R1R0 for (size_t Pos=0; PosChannels.size(); Pos++) { if (Common->MergedChannel.Buffer_Size+Minimum>Common->MergedChannel.Buffer_Size_Max) Common->MergedChannel.resize(Common->MergedChannel.Buffer_Size+Minimum); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Common->Channels[Pos]->Buffer[Common->Channels[Pos]->Buffer_Offset++]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Common->Channels[Pos]->Buffer[Common->Channels[Pos]->Buffer_Offset++]; } Minimum-=2; break; case 20: // Source: 20BE / L4L3 L2L1 L0L4 L3L2 L1L0 + R4R3 R2R1 R0R4 R3R2 R1R0 // Dest : 20BE / L4L3 L2L1 L0R4 R3R2 R1R0 L4L3 L2L1 L0R4 R2R1 R1R0 if (Endianness=='B') for (size_t Pos=0; Pos+1Channels.size(); Pos+=2) { if (Common->MergedChannel.Buffer_Size+Minimum*2>Common->MergedChannel.Buffer_Size_Max) Common->MergedChannel.resize(Common->MergedChannel.Buffer_Size+Minimum*2); int8u* Channel1=Common->Channels[Pos]->Buffer+Common->Channels[Pos]->Buffer_Offset; int8u* Channel2=Common->Channels[Pos]->Buffer+Common->Channels[Pos]->Buffer_Offset; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel1[0]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel1[1]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel1[0]&0xF0) | (Channel2[0]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel2[0]<<4 ) | (Channel2[1]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel2[1]<<4 ) | (Channel2[2]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel1[2]<<4 ) | (Channel1[3]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel1[3]<<4 ) | (Channel1[4]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel1[4]<<4 ) | (Channel2[2]&0x0F); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel2[3]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel2[4]; Common->Channels[Pos]->Buffer_Offset+=5; Common->Channels[Pos+1]->Buffer_Offset+=5; } // Source: 20LE / L1L0 L3L2 L0L4 L2L1 L4L3 + R1R0 R3R2 R0R4 R2R1 R4R3 // Dest : 20LE / L1L0 L3L2 R0L4 R2R1 R4R3 L1L0 L3L2 R0L4 R2R1 R4R3 else for (size_t Pos=0; Pos+1Channels.size(); Pos+=2) { if (Common->MergedChannel.Buffer_Size+Minimum*2>Common->MergedChannel.Buffer_Size_Max) Common->MergedChannel.resize(Common->MergedChannel.Buffer_Size+Minimum*2); int8u* Channel1=Common->Channels[Pos]->Buffer+Common->Channels[Pos]->Buffer_Offset; int8u* Channel2=Common->Channels[Pos]->Buffer+Common->Channels[Pos]->Buffer_Offset; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel1[0]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel1[1]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel2[0]<<4 ) | (Channel1[2]&0x0F); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel2[1]<<4 ) | (Channel2[0]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel2[2]<<4 ) | (Channel2[1]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel1[3]<<4 ) | (Channel1[2]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel1[4]<<4 ) | (Channel1[3]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]=(Channel2[2]&0xF0) | (Channel1[4]>>4 ); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel2[3]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Channel2[4]; Common->Channels[Pos]->Buffer_Offset+=5; Common->Channels[Pos+1]->Buffer_Offset+=5; } Minimum-=5; //2.5 twice break; case 24: // Source: 24XE / L5L4 L3L2 L1L0 + R5R4 R3R2 R1R0 // Dest : 24XE / L5L4 L3L2 L1L0 R5R4 R3R2 R1R0 for (size_t Pos=0; PosChannels.size(); Pos++) { if (Common->MergedChannel.Buffer_Size+Minimum>Common->MergedChannel.Buffer_Size_Max) Common->MergedChannel.resize(Common->MergedChannel.Buffer_Size+Minimum); Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Common->Channels[Pos]->Buffer[Common->Channels[Pos]->Buffer_Offset++]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Common->Channels[Pos]->Buffer[Common->Channels[Pos]->Buffer_Offset++]; Common->MergedChannel.Buffer[Common->MergedChannel.Buffer_Size++]= Common->Channels[Pos]->Buffer[Common->Channels[Pos]->Buffer_Offset++]; } Minimum-=3; break; default: ; // Not supported Reject(); return; } } } if (Common->MergedChannel.Buffer_Size>Common->MergedChannel.Buffer_Offset) { for (size_t Pos=0; PosParsers.size(); Pos++) { if (FrameInfo_Next.DTS!=(int64u)-1) Common->Parsers[Pos]->FrameInfo=FrameInfo_Next; //AES3 parse has its own buffer management else if (FrameInfo.DTS!=(int64u)-1) { Common->Parsers[Pos]->FrameInfo=FrameInfo; FrameInfo=frame_info(); } Common->Parsers[Pos]->Offsets_Stream.insert(Common->Parsers[Pos]->Offsets_Stream.end(), Common->MergedChannel.Offsets_Stream.begin(), Common->MergedChannel.Offsets_Stream.end()); Common->Parsers[Pos]->Offsets_Buffer.insert(Common->Parsers[Pos]->Offsets_Buffer.end(), Common->MergedChannel.Offsets_Buffer.begin(), Common->MergedChannel.Offsets_Buffer.end()); for (size_t Offsets_Pos_Temp=Common->Parsers[Pos]->Offsets_Buffer.size()-Common->MergedChannel.Offsets_Buffer.size(); Offsets_Pos_TempParsers[Pos]->Offsets_Buffer.size(); Offsets_Pos_Temp++) Common->Parsers[Pos]->Offsets_Buffer[Offsets_Pos_Temp]+=Common->Parsers[Pos]->Buffer_Size/Common->Channels.size(); Open_Buffer_Continue(Common->Parsers[Pos], Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset, false); //Multiple parsers if (Common->Parsers.size()>1) { if (!Common->Parsers[Pos]->Status[IsAccepted] && Common->Parsers[Pos]->Status[IsFinished]) { delete *(Common->Parsers.begin()+Pos); Common->Parsers.erase(Common->Parsers.begin()+Pos); Pos--; } else if (Common->Parsers.size()>1 && Common->Parsers[Pos]->Status[IsAccepted]) { File__Analyze* Parser=Common->Parsers[Pos]; for (size_t Pos2=0; Pos2Parsers.size(); Pos2++) { if (Pos2!=Pos) delete *(Common->Parsers.begin()+Pos2); } Common->Parsers.clear(); Common->Parsers.push_back(Parser); } } } Common->MergedChannel.Buffer_Offset=Common->MergedChannel.Buffer_Size; Common->MergedChannel.Offsets_Stream.clear(); Common->MergedChannel.Offsets_Buffer.clear(); } if (!Status[IsAccepted] && Common->Parsers.size()==1 && Common->Parsers[0]->Status[IsAccepted]) Accept(); if (!Status[IsFilled] && Common->Parsers.size()==1 && Common->Parsers[0]->Status[IsFilled]) Fill(); if (!Status[IsFinished] && Common->Parsers.size()==1 && Common->Parsers[0]->Status[IsFinished]) Finish(); //Optimize buffer for (size_t Pos=0; PosChannels.size(); Pos++) Common->Channels[Pos]->optimize(); Common->MergedChannel.optimize(); } //--------------------------------------------------------------------------- void File_ChannelGrouping::Read_Buffer_Unsynched() { for (size_t Pos=0; PosParsers.size(); Pos++) if (Common->Parsers[Pos]) Common->Parsers[Pos]->Open_Buffer_Unsynch(); Common->MergedChannel.Buffer_Offset=0; Common->MergedChannel.Buffer_Size=0; for (size_t Pos=0; PosChannels.size(); Pos++) { Common->Channels[Pos]->Buffer_Offset=0; Common->Channels[Pos]->Buffer_Size=0; } } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_SMPTEST0337_YES MediaInfoLib/Source/MediaInfo/Audio/File_Adpcm.cpp0000664000000000000000000000565612652076434020710 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Audio/File_OpenMG.cpp0000664000000000000000000002017112652076434020776 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about OpenMG (OMA) files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_OPENMG_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_OpenMG.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** //--------------------------------------------------------------------------- const char* OpenMG_CodecID_Format (int8u CodecID) { switch (CodecID) { case 0 : case 1 : return "Atrac3"; case 3 : return "MPEG Audio"; case 4 : return "PCM"; case 5 : return "WMA"; default : return ""; } } //--------------------------------------------------------------------------- const char* OpenMG_CodecID_Encryption (int8u CodecID) { switch (CodecID) { case 1 : return "SDMI"; default : return ""; } } //--------------------------------------------------------------------------- int32u OpenMG_SamplingRate (int8u SamplingRate_Code) { switch (SamplingRate_Code) { case 0 : return 32000; case 1 : return 44100; case 2 : return 44800; case 3 : return 88200; case 4 : return 96000; default : return 0; } } //--------------------------------------------------------------------------- int8u OpenMG_Channels (int8u Channels_Code) { if (Channels_Code<=4) return Channels_Code; else return Channels_Code+1; //+LFE } //--------------------------------------------------------------------------- const char* OpenMG_ChannelPositions (int8u Channels_Code) { switch (Channels_Code) { case 1 : return "Front: C"; case 2 : return "Front: L R"; case 3 : return "Front: L R, Side: C"; case 4 : return "Front: L R, Back: L R"; case 5 : return "Front: L C R, Side: L R, LFE"; case 6 : return "Front: L C R, Side: L R, Back: C, LFE"; case 7 : return "Front: L C R, Side: L R, Back: L R, LFE"; default : return ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_OpenMG::File_OpenMG() { //File__Tags_Helper Base=this; //Config #if MEDIAINFO_TRACE Trace_Layers_Update(8); //Stream #endif //MEDIAINFO_TRACE IsRawStream=true; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_OpenMG::Streams_Fill() { Fill(Stream_General, 0, General_Format, "OpenMG"); File__Tags_Helper::Stream_Prepare(Stream_Audio); File__Tags_Helper::Streams_Fill(); } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_OpenMG::FileHeader_Begin() { if (!File__Tags_Helper::FileHeader_Begin()) return false; //Synchro if (Buffer_Offset+3>Buffer_Size) return false; // Testing if (Buffer[Buffer_Offset ]!=0x45 // "EA3" || Buffer[Buffer_Offset+1]!=0x41 || Buffer[Buffer_Offset+2]!=0x33) { File__Tags_Helper::Reject(); return false; } return true; } //--------------------------------------------------------------------------- void File_OpenMG::FileHeader_Parse() { //Parsing int16u Size, FrameSize=0; int8u Flags, CodecID, SamplingRate_Code=0, Channels_Code=0; bool JointStereo=false; Skip_C3( "Code"); Get_B1 (Flags, "Flags"); Get_B2 (Size, "Size"); Skip_XX(26, "Unknown"); Get_B1 (CodecID, "Coded ID"); Param_Info1(OpenMG_CodecID_Format(CodecID)); if (CodecID<=1) //Atrac3 { BS_Begin(); Skip_S1(7, "Unknown"); Get_SB ( JointStereo, "Joint Stereo"); Get_S1 (3, SamplingRate_Code, "Sampling Rate"); Param_Info2(OpenMG_SamplingRate(SamplingRate_Code), " Hz"); Get_S1 (3, Channels_Code, "Channels"); Param_Info2(OpenMG_Channels(Channels_Code), " channel(s)"); Get_S2 (10, FrameSize, "Frame size"); BS_End(); } Skip_XX(Size-Element_Offset, "Unknown"); FILLING_BEGIN(); if (!Status[IsAccepted]) { File__Tags_Helper::Accept(); Fill(Stream_Audio, 0, Audio_Format, OpenMG_CodecID_Format(CodecID)); Fill(Stream_Audio, 0, Audio_Encryption, OpenMG_CodecID_Encryption(CodecID)); int64u StreamSize=(int64u)-1; if (File_Size!=(int64u)-1) { StreamSize=File_Size-(Buffer_Offset+Element_Size); Fill(Stream_Audio, 0, Audio_StreamSize, StreamSize); } if (CodecID<=1) // Atrac3 { Fill(Stream_Audio, 0, Audio_Channel_s_, OpenMG_Channels(Channels_Code)); Fill(Stream_Audio, 0, Audio_ChannelPositions, OpenMG_ChannelPositions(Channels_Code)); if (Channels_Code==1 && JointStereo) Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, "Joint Stereo"); Fill(Stream_Audio, 0, Audio_SamplingRate, OpenMG_SamplingRate(SamplingRate_Code)); if (CodecID==1) //Protected FrameSize++; //Not sure FrameSize<<=3; //8-byte blocks int64u BitRate=OpenMG_SamplingRate(SamplingRate_Code)*FrameSize/256; Fill(Stream_Audio, 0, Audio_BitRate, BitRate); if (StreamSize!=(int64u)-1 && BitRate) Fill(Stream_Audio, 0, Audio_Duration, StreamSize*8*1000/BitRate); } } FILLING_END(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_OpenMG::Read_Buffer_Continue() { //Parsing Skip_XX(File_Size-Buffer_Offset, "Data"); File__Analyze::Finish(); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Aac.cpp0000664000000000000000000006322112652076434020340 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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/MediaInfo_Config_MediaInfo.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:8); FrameIsAlwaysComplete=false; Mode=Mode_Unknown; audioObjectType=(int8u)-1; extensionAudioObjectType=(int8u)-1; channelConfiguration=(int8u)-1; frame_length=1024; sampling_frequency_index=(int8u)-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; adts_buffer_fullness_Is7FF=false; #if MEDIAINFO_ADVANCED aac_frame_length_Total=0; #endif //MEDIAINFO_ADVANCED //Temp - Main muxConfigPresent=true; audioMuxVersionA=false; //Temp - General Audio sbr=NULL; ps=NULL; //Temp CanFill=true; } //--------------------------------------------------------------------------- File_Aac::~File_Aac() { delete sbr; delete ps; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Aac::Streams_Accept() { switch (Mode) { case Mode_ADTS : if (!IsSub) TestContinuousFileNames(); default : ; } } //--------------------------------------------------------------------------- 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::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::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 : ; } Fill(Stream_Audio, StreamPos_Last, Audio_SamplesPerFrame, frame_length); } //--------------------------------------------------------------------------- void File_Aac::Streams_Update() { if (Frame_Count) { if (Mode==Mode_ADTS) Infos["BitRate_Mode"].From_Local(adts_buffer_fullness_Is7FF?"VBR":"CBR"); #if MEDIAINFO_ADVANCED switch(Mode) { case Mode_ADTS : case Mode_LATM : if (Config->File_RiskyBitRateEstimation_Get() && !adts_buffer_fullness_Is7FF) { int64u BitRate=(Frequency_b/1024); BitRate*=aac_frame_length_Total*8; BitRate/=Frame_Count; Fill(Stream_Audio, 0, Audio_BitRate, BitRate, 10, true); } break; default : ; } #endif //MEDIAINFO_ADVANCED } } //--------------------------------------------------------------------------- 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); if (Config->ParseSpeed>=1.0) { 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_Size<4) return false; if (Buffer[0]==0x41 //"ADIF" && Buffer[1]==0x44 && Buffer[2]==0x49 && Buffer[3]==0x46) { 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; if (Frame_Count==0) PTS_Begin=FrameInfo.PTS; 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=Frame_Count_Valid) { //No more need data if (Mode==Mode_LATM) File__Analyze::Accept(); 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) { //Padding while (Buffer_Offset+aac_frame_length+2<=Buffer_Size && Buffer[Buffer_Offset+aac_frame_length]==0x00) aac_frame_length++; if (IsSub && Buffer_Offset+aac_frame_length==Buffer_Size) break; //while() 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 if (Buffer_Offset+aac_frame_length+3+3>Buffer_Size) return false; //Need more data 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) { //Padding while (Buffer_Offset+aac_frame_length+aac_frame_length2+2<=Buffer_Size && Buffer[Buffer_Offset+aac_frame_length+aac_frame_length2]==0x00) aac_frame_length2++; if (IsSub && Buffer_Offset+aac_frame_length+aac_frame_length2==Buffer_Size) break; //while() 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 if (Buffer_Offset+aac_frame_length+aac_frame_length2+3+3>Buffer_Size) return false; //Need more data 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) { //Padding while (Buffer_Offset+aac_frame_length+aac_frame_length2+aac_frame_length3+2<=Buffer_Size && Buffer[Buffer_Offset+aac_frame_length+aac_frame_length2+aac_frame_length3]==0x00) aac_frame_length3++; if (IsSub && Buffer_Offset+aac_frame_length+aac_frame_length2+aac_frame_length3==Buffer_Size) break; //while() 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; 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; 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; //Null padding while (Buffer_Offset+2<=Buffer_Size && Buffer[Buffer_Offset]==0x00) Buffer_Offset++; //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=Frame_Count_Valid && Config->ParseSpeed<1.0) { //No more need data switch (Mode) { case Mode_ADTS : case Mode_LATM : if (!Status[IsFilled]) { Fill(); if (!IsSub) File__Tags_Helper::Finish(); } break; default : ; //No header } } TS_Add(frame_length); 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 MediaInfoLib/Source/MediaInfo/Audio/File_Amv.cpp0000664000000000000000000000313212652076434020372 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Audio/File_ExtendedModule.cpp0000664000000000000000000001113112652076434022553 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Flac.h0000664000000000000000000000500712652076434020164 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Flac files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_FlacH #define MediaInfo_File_FlacH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_Rkau.h0000664000000000000000000000314112652076434020216 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about RKAU files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_RkauH #define MediaInfo_File_RkauH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_Flac.cpp0000664000000000000000000002760512652076434020527 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 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_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_Size4) 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); //Specific case: bit depth if (!VorbisCom.Retrieve(Stream_Audio, 0, Audio_BitDepth).empty() && VorbisCom.Retrieve(Stream_Audio, 0, Audio_BitDepth).To_int64u()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 MediaInfoLib/Source/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.h0000664000000000000000000000706212652076434023675 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_Aac_GeneralAudio_Sbr_PsH #define MediaInfo_File_Aac_GeneralAudio_Sbr_PsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_Aac.h" //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Audio/File_Opus.h0000664000000000000000000000257412652076434020253 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about OPUS files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_OpusH #define MediaInfo_File_OpusH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Opus //*************************************************************************** class File_Opus : public File__Analyze { public : File_Opus(); private : //Buffer - Per element void Header_Parse(); void Data_Parse(); //Elements void Identification(); void Stream(); //Temp bool Identification_Done; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_SmpteSt0302.cpp0000664000000000000000000002751412652076434021565 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_SMPTEST0302_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_SmpteSt0302.h" #if defined(MEDIAINFO_PCM_YES) #include "MediaInfo/Audio/File_Pcm.h" #endif #if defined(MEDIAINFO_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.h" #endif #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #endif //MEDIAINFO_EVENTS //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_SmpteSt0302::File_SmpteSt0302() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Aes3; #endif //MEDIAINFO_EVENTS PTS_DTS_Needed=true; IsRawStream=true; } //--------------------------------------------------------------------------- File_SmpteSt0302::~File_SmpteSt0302() { for (size_t Pos=0; PosContainer_Bits=(4+bits_per_sample)*4; SmpteSt0337->Endianness='L'; SmpteSt0337->Aligned=true; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) { Demux_Level=4; //Intermediate SmpteSt0337->Demux_Level=2; //Container SmpteSt0337->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Parsers.push_back(SmpteSt0337); } // Raw PCM { File_Pcm* Pcm=new File_Pcm(); Pcm->Codec.From_Local("SMPTE ST 302"); Pcm->BitDepth=(4+bits_per_sample)*4; Pcm->Channels=(1+number_channels)*2; Pcm->SamplingRate=48000; Pcm->Endianness='L'; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) { Demux_Level=4; //Intermediate Pcm->Demux_Level=2; //Container Pcm->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Parsers.push_back(Pcm); } // Init for (size_t Pos=0; PosStatus[IsAccepted]) { Fill(Parsers[0]); Merge(*Parsers[0]); } for (size_t Pos=0; Pos>1)&0x55) | ((n<<1) & 0xaa); n=((n>>2)&0x33) | ((n<<2) & 0xcc); n=((n>>4)&0x0f) | ((n<<4) & 0xf0); return (int8u)n; } //--------------------------------------------------------------------------- void File_SmpteSt0302::Read_Buffer_Continue() { //Parsing Get_B2 (audio_packet_size, "audio_packet_size"); BS_Begin(); Get_S1 (2, number_channels, "number_channels"); Param_Info2((1+number_channels)*2, " channels"); Info_S1(8, channel_identification, "channel_identification"); Get_S1 (2, bits_per_sample, "bits_per_sample"); Param_Info2((4+bits_per_sample)*4, " bits"); Info_S1(4, alignment_bits, "alignment_bits"); BS_End(); //Enough data if (Element_Size<4+(int64u)audio_packet_size) { Element_Offset=0; Element_WaitForMoreData(); return; } //Cohenrancy test if (Element_Size!=4+(int64u)audio_packet_size || bits_per_sample==3 || audio_packet_size%((1+number_channels)*(5+bits_per_sample))) { Trusted_IsNot("Wrong size"); Skip_XX(Element_Size-4, "Problem?"); return; } if (!Status[IsAccepted]) Accept("SMPTE ST 302"); //Decyphering size_t PcmSize=0; float64 Ratio=0; switch (bits_per_sample) { case 0 : PcmSize=audio_packet_size*4/5; Ratio=4.0/5.0; break; case 1 : PcmSize=audio_packet_size*5/6; Ratio=5.0/6.0; break; case 2 : PcmSize=audio_packet_size*6/7; Ratio=6.0/7.0; break; case 3 : Reject(); return; default: ; } int8u* Info=new int8u[PcmSize]; size_t Info_Offset=0; while (Element_Offset>4 ); Info[Info_Offset+3]=(Reverse8(Buffer[Buffer_Pos+4])<<4 ) | (Reverse8(Buffer[Buffer_Pos+3])>>4 ); Info_Offset+=4; Element_Offset+=5; break; case 1 : //20 bits // Source: L1L0 L3L2 XXL4 R1R0 R3R2 XXR4 // Dest : 20LE / L1L0 L3L2 R0L4 R2R1 R4R3 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+3])<<4 ) | (Reverse8(Buffer[Buffer_Pos+2])&0x0F); Info[Info_Offset+3]=(Reverse8(Buffer[Buffer_Pos+4])<<4 ) | (Reverse8(Buffer[Buffer_Pos+3])>>4 ); Info[Info_Offset+4]=(Reverse8(Buffer[Buffer_Pos+5])<<4 ) | (Reverse8(Buffer[Buffer_Pos+4])>>4 ); Info_Offset+=5; Element_Offset+=6; break; case 2 : //24 bits // Source: L1L0 L3L2 L5L4 R0XX R2R1 R4R3 XXR5 // Dest : 16LE / L1L0 L3L2 L5L4 R1R0 R3R2 R5R4 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]) ; Info[Info_Offset+3] =(Reverse8(Buffer[Buffer_Pos+4])<<4 ) | (Reverse8(Buffer[Buffer_Pos+3])>>4 ); Info[Info_Offset+4] =(Reverse8(Buffer[Buffer_Pos+5])<<4 ) | (Reverse8(Buffer[Buffer_Pos+4])>>4 ); Info[Info_Offset+5] =(Reverse8(Buffer[Buffer_Pos+6])<<4 ) | (Reverse8(Buffer[Buffer_Pos+5])>>4 ); Info_Offset+=6; Element_Offset+=7; break; default : ; } } Element_Offset=4; FrameInfo.PTS=FrameInfo.DTS; FrameInfo.DUR=((int64u)audio_packet_size)*1000000000/((1+number_channels)*(5+bits_per_sample)*48000); #if MEDIAINFO_DEMUX Demux_random_access=true; Demux(Info, Info_Offset, ContentType_MainStream); #endif //MEDIAINFO_DEMUX //Parsers for (size_t Pos=0; PosFrameInfo=FrameInfo; Open_Buffer_Continue(Parsers[Pos], Info, Info_Offset, true, Ratio); if (Parsers.size()>1 && Parsers[Pos]->Status[IsAccepted]) { for (size_t Pos2=0; Pos21 && Frame_Count>=2) { for (size_t Pos=0; PosStatus[IsFinished]) { //Filling Finish("SMPTE ST 302"); } } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_SMPTEST0302_YES MediaInfoLib/Source/MediaInfo/Audio/File_Mpc.cpp0000664000000000000000000001757412652076434020405 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Speex.cpp0000664000000000000000000001312712652076434020740 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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_sizeBuffer_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 = ((int64u)Channels) * ((int64u)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 MediaInfoLib/Source/MediaInfo/Audio/File_Dts.cpp0000664000000000000000000017031612652076434020412 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- 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, Back: C", "Front: L C R, Back: C", "Front: L R, Side: L R", "Front: L C R, Side: L R", "Front: L C C 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, 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", "4/2/0", "3/2/0", "2/2/2", "3/2/2", "2/2/4", "3/2/3", }; //--------------------------------------------------------------------------- const char* DTS_ChannelLayout[16]= { "C", "1+1", "L R", "L R", "Lt Rt", "C L R", "L R Cs", "C L R Cs", "L R Ls Rs", "C L R Ls Rs", "Cl Cr L R Ls Rs", "C L R Ls Rs", "C L R Ls Rs Rls Rrs", "C L R Ls Rs Rls Rrs", "L R Ls Rs Rls Cs Cs Rrs", "C L R Ls Rs Rls Cs Rrs", }; //--------------------------------------------------------------------------- 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, bool AddCs=false, bool AddLrsRrs=false) { 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 || AddCs) Text+=", Back: C"; if ((SpeakerActivityMask&0x00A0)==0x00A0) Text+=", High: L C R"; else { if (SpeakerActivityMask&0x0020 || AddLrsRrs) 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)==0x0C000) 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, bool AddCs=false, bool AddLrsRrs=false) { 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 || AddCs) Text+="/1"; else if ((SpeakerActivityMask&0x0840)==0x0000) Text+="/0"; if ((SpeakerActivityMask&0x00A0)==0x00A0) Text+=".3"; else { if (SpeakerActivityMask&0x0020 || AddLrsRrs) 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)==0x0C000) 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; //Buffer Save_Buffer=NULL; //Temp HD_size=0; Primary_Frame_Byte_Size=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; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Dts::Streams_Fill_Extension() { bool AddCs=false; //bool AddLrsRrs=false; //bool AddX=false; if (HD_TotalNumberChannels!=(int8u)-1) { int8u i=HD_TotalNumberChannels; int8u Core_Core_Channels=DTS_Channels[Core_Core_AMODE]; if (Presence[presence_Core_Core] && Core_Core_LFF) Core_Core_Channels++; if (Presence[presence_Core_XXCh] && i1) { bool IsNotSame=false; for (size_t i=1; iPTS_Begin) { Fill(Stream_Audio, 0, Audio_Duration, ((float64)(FrameInfo.PTS-PTS_Begin))/1000000, 0, true); Fill(Stream_Audio, 0, Audio_FrameCount, ((float64)(FrameInfo.PTS-PTS_Begin))/1000000/32, 0, true); } } //*************************************************************************** // 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) { if (!FrameSynchPoint_Test()) return false; //Need more data if (Synched) 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; } //Synched return true; } //--------------------------------------------------------------------------- bool File_Dts::Synched_Test() { //Padding while (Buffer_OffsetBuffer_Size) return false; //Quick test of synchro if (!FrameSynchPoint_Test()) return false; //Need more data if (!Synched) return true; //We continue return true; } //--------------------------------------------------------------------------- void File_Dts::Read_Buffer_Unsynched() { FrameInfo=frame_info(); } //*************************************************************************** // 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 - Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_Dts::Header_Parse() { Header_Fill_Size(Original_Size); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Dts::Data_Parse() { if (Save_Buffer) { File_Offset+=Buffer_Offset; swap(Buffer, Save_Buffer); swap(Buffer_Offset, Save_Buffer_Offset); swap(Buffer_Size, Save_Buffer_Size); if (!Word) Element_Size=Element_Size*14/16; } //Parsing int32u Sync; Get_B4 (Sync, "Sync"); if (Sync==0x64582025) { //HD Element_Name("HD"); Element_Code=1; 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 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; Pos2) 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=2) //TODO: find a better way to accept stream in short files so with only few frames Accept("DTS"); if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) { 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; Presence.set(presence_Core_XCh); Core_XCh_AMODE=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 (6, "nuHeaderSizeXXCh minus 1"); Skip_S1 (1, "bCRCPresent4ChSetHeaderXXCh minus 1"); Skip_S1 (5, "nuBits4SpkrMaskXXCh minus 1"); Get_S1 (2, ChannelsAdded, "nuNumChSetsInXXCh minus 1"); Skip_S1 (2, "?"); BS_End(); Skip_XX(Size-2, "Data"); FILLING_BEGIN(); channel_arrangement_XCh=ChannelsAdded+1; Core_XXCh_nuNumChSetsInXXCh=ChannelsAdded+1; Presence.set(presence_Core_XXCh); 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"; Presence.set(presence_Core_X96); FILLING_END(); } //--------------------------------------------------------------------------- void File_Dts::HD() { //Parsing while (Element_OffsetElement_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"; Presence.set(presence_Extended_XXCh); 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"; Presence.set(presence_Extended_X96); FILLING_END(); } //--------------------------------------------------------------------------- void File_Dts::HD_XLL(int64u Size) { Element_Name("XLL (LossLess)"); // Quick and dirty search of DTS:X pattern if (!Presence[presence_Extended_XLL]) { Extension_XLL_X_No=0; Extension_XLL_X_Yes=0; } if (!Presence[presence_Extended_XLL_X] && (!Extension_XLL_X_No || !Extension_XLL_X_Yes) && (Extension_XLL_X_No<8 || Extension_XLL_X_Yes<8)) //Limiting the parsing to a couple of frames for performance reasons and stop if there is a risk of false positive { bool IsX=false; const int8u* cur = Buffer + Buffer_Offset + (size_t)Element_Offset; const int8u* end = cur + (size_t)Size-3; for (; cur=8 && !Extension_XLL_X_No) Presence.set(presence_Extended_XLL_X); } else Extension_XLL_X_No++; } // Parsing Skip_XX(Size, "Data"); FILLING_BEGIN(); Profile="MA"; Presence.set(presence_Extended_XLL); FILLING_END(); } //--------------------------------------------------------------------------- void File_Dts::HD_XBR(int64u Size) { Element_Name("XBR (BitRate extension)"); Skip_XX(Size, "Data"); FILLING_BEGIN(); Profile="HRA"; Presence.set(presence_Extended_XBR); FILLING_END(); } //--------------------------------------------------------------------------- void File_Dts::HD_XSA(int64u Size) { Element_Name("XSA (low bitrate)"); Skip_XX(Size, "Data"); FILLING_BEGIN(); Profile="Express"; Presence.set(presence_Extended_LBR); 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 if (DTS_SamplingRate[sample_frequency]) BitRate=((float64)Primary_Frame_Byte_Size)*8/(Number_Of_PCM_Sample_Blocks*32)*DTS_SamplingRate[sample_frequency]; //(float64)DTS_BitRate[bit_rate]; else BitRate=0; //Problem 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+=((float64)HD_size)*8*DTS_HD_MaximumSampleRate[HD_MaximumSampleRate]/SamplePerFrames; } //if (Primary_Frame_Byte_Size && Profile==__T("HRA")) // BitRate*=1+((float64)HD_size)/Primary_Frame_Byte_Size; //HD block are not in the nominal bitrate return BitRate; } else return 0; } //--------------------------------------------------------------------------- bool File_Dts::FrameSynchPoint_Test() { if (Save_Buffer) return true; //Test already made by Synchronize() 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 { //Configuration - 14 bits or Little Endian switch (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 } int32u Size; if (Buffer[Buffer_Offset]==0x64) //HD { if (Buffer_Offset+10>Buffer_Size) return false; //Need more data bool isBlownUpHeader=(Buffer[Buffer_Offset+5]&0x20)?true:false; if (isBlownUpHeader) Size=((Buffer[Buffer_Offset+6]&0x01)<<19) | ( Buffer[Buffer_Offset+7] <<11) | ( Buffer[Buffer_Offset+8] << 3) | ( Buffer[Buffer_Offset+9] >> 5); else Size=((Buffer[Buffer_Offset+6]&0x1F)<<11) | ( Buffer[Buffer_Offset+7] << 3) | ( Buffer[Buffer_Offset+8] >> 5); Size++; Original_Size=Size; } else { if (Word) { if (BigEndian) Size=((Buffer[Buffer_Offset+5]&0x03)<<12) | ( Buffer[Buffer_Offset+6] << 4) | ( Buffer[Buffer_Offset+7] >> 4); else Size=((Buffer[Buffer_Offset+4]&0x03)<<12) | ( Buffer[Buffer_Offset+7] << 4) | ( Buffer[Buffer_Offset+6] >> 4); Size++; Original_Size=Size; } else { if (BigEndian) Size=((Buffer[Buffer_Offset+6]&0x03)<<12) | ( Buffer[Buffer_Offset+7] << 4) | ((Buffer[Buffer_Offset+8]&0x3C)>> 2); else Size=((Buffer[Buffer_Offset+7]&0x03)<<12) | ( Buffer[Buffer_Offset+6] << 4) | ((Buffer[Buffer_Offset+9]&0x3C)>> 2); Size++; Original_Size=Size*16/14; } } if (Buffer_Offset+Size>Buffer_Size) return false; //Need more data if (!Word || !BigEndian) { Save_Buffer=Buffer; Save_Buffer_Offset=Buffer_Offset; Save_Buffer_Size=Buffer_Size; //Preparing new buffer if (Word) { int8u* Buffer_Little=new int8u[Size]; for (size_t Pos=0; Pos+1Status[IsAccepted]) { Fill(Parser); 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)); } if (Parser->Count_Get(Stream_Audio)) FrameRate=Retrieve(Stream_Audio, 0, Audio_FrameRate).To_float64(); } else if (data_type!=(int8u)-1) { if (Retrieve(Stream_Audio, 0, Audio_Format).empty() && Smpte_St0337_data_type_StreamKind[data_type]!=Stream_Max) { Stream_Prepare(Smpte_St0337_data_type_StreamKind[data_type]); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), Smpte_St0337_data_type[data_type]); Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), Smpte_St0337_data_type[data_type]); } } // Guard band if (GuardBand_Before) // With guard band, there is big chances that AES3 bit rate is respected { Fill(Stream_General, 0, General_OverallBitRate, Container_Bits*2*48000); if (!IsSub && File_Size!=(int64u)-1) Fill(Stream_General, 0, General_Duration, ((float64)File_Size)*8/(Container_Bits*2*48000)*1000); } if (FrameRate && FrameSizes.size()==1) { Fill(Stream_General, 0, General_OverallBitRate, FrameSizes.begin()->first*Container_Bits*FrameRate, 0); } for (size_t Pos=0; Posfirst); if (Retrieve(StreamKind_Last, Pos, Fill_Parameter(StreamKind_Last, Generic_Duration)).empty()) Fill(StreamKind_Last, Pos, Fill_Parameter(StreamKind_Last, Generic_Duration), Retrieve(Stream_General, 0, General_Duration)); } } //*************************************************************************** // Buffer - Global //*************************************************************************** #if MEDIAINFO_SEEK //--------------------------------------------------------------------------- void File_SmpteSt0337::Read_Buffer_Unsynched() { if (Frame_Count_NotParsedIncluded!=(int64u)-1 && FrameRate) { Frame_Count_NotParsedIncluded=float64_int64s(File_GoTo/FrameRate); FrameInfo.DTS=Frame_Count_NotParsedIncluded*1000000000/48000; } } #endif // MEDIAINFO_SEEK //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_SmpteSt0337::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) return 0; FrameRate=MI.Get(Stream_Audio, 0, __T("FrameRate")).To_float64(); Duration_Detected=true; } // Parsing switch (Method) { case 0 : if (FrameRate) { float64 FrameSize=3072000/FrameRate; int64u FrameCount=float64_int64s(Value/FrameSize); Value=float64_int64s(FrameCount*FrameSize); } GoTo(Value); Open_Buffer_Unsynch(); return 1; case 1 : return Read_Buffer_Seek(0, File_Size*Value/10000, ID); case 2 : // Timestamp { if (FrameRate) return (size_t)-1; // Not supported { float64 FrameSize=3072000/FrameRate; Unsynch_Frame_Count=float64_int64s(((float64)Value)/1000000000*FrameRate); GoTo(float64_int64s(Unsynch_Frame_Count*FrameSize)); Open_Buffer_Unsynch(); return 1; } } case 3 : // FrameNumber { if (FrameRate) return (size_t)-1; // Not supported { float64 FrameSize=3072000/FrameRate; Unsynch_Frame_Count=Value; GoTo(float64_int64s(Unsynch_Frame_Count*FrameSize)); Open_Buffer_Unsynch(); return 1; } } default : return (size_t)-1; // Not supported } } #endif // MEDIAINFO_SEEK //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_SmpteSt0337::Synchronize() { // Guard band size_t Buffer_Offset_Base=Buffer_Offset; // Synchronizing while (Buffer_Offset+16<=Buffer_Size) { if (!Status[IsAccepted] && !IsSub && File_Offset_FirstSynched==(int64u)-1 && Buffer_TotalBytes+Buffer_Offset>=Buffer_TotalBytes_FirstSynched_Max) { Reject(); return false; } if ((Container_Bits==0 || Container_Bits==16) && (!Aligned || ((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) // 16-bit, BE { 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) // 16-bit, LE { Container_Bits=16; Stream_Bits=16; Endianness='L'; // LE break; // while() } } if ((Container_Bits==0 || Container_Bits==20) && (!Aligned || ((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) // 20-bit, BE { Container_Bits=20; Stream_Bits=20; Endianness='B'; // BE break; // while() } } if ((Container_Bits==0 || Container_Bits==20) && (!Aligned || ((Buffer_TotalBytes+Buffer_Offset)%5)==0)) { if (Buffer[Buffer_Offset ]==0x72 && Buffer[Buffer_Offset+1]==0xF8 && Buffer[Buffer_Offset+2]==0xF6 && Buffer[Buffer_Offset+3]==0xE1 && Buffer[Buffer_Offset+4]==0x54) // 20-bit, LE { Container_Bits=20; Stream_Bits=20; Endianness='L'; // BE break; // while() } } if ((Container_Bits==0 || Container_Bits==24) && (!Aligned || ((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) // 24-bit, BE { 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]==0xA5) // 24-bit, LE { 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 { Container_Bits=24; Stream_Bits=16; Endianness='B'; // BE NullPadding_Size=1; 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 { Container_Bits=24; Stream_Bits=16; Endianness='L'; // LE NullPadding_Size=1; 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 { 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 { Container_Bits=24; Stream_Bits=20; Endianness='L'; // LE break; // while() } } if ((Container_Bits==0 || Container_Bits==32) && (!Aligned || ((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 { Container_Bits=32; Stream_Bits=16; Endianness='B'; // BE NullPadding_Size=2; 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 { Container_Bits=32; Stream_Bits=16; Endianness='L'; // LE NullPadding_Size=2; 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 { Container_Bits=32; Stream_Bits=20; Endianness='B'; // BE NullPadding_Size=1; 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 { Container_Bits=32; Stream_Bits=20; Endianness='L'; // LE NullPadding_Size=1; 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 { Container_Bits=32; Stream_Bits=24; Endianness='B'; // BE NullPadding_Size=1; 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 { Container_Bits=32; Stream_Bits=24; Endianness='L'; // LE NullPadding_Size=1; break; // while() } } if (Container_Bits>=4 && Aligned) Buffer_Offset+=Container_Bits/4; else Buffer_Offset++; } // Guard band GuardBand_Before+=Buffer_Offset-Buffer_Offset_Base; // Parsing last bytes if needed if (Buffer_Offset+16>Buffer_Size) { return false; } if (!Status[IsAccepted]) Accept("SMPTE ST 337"); // Synched return true; } //--------------------------------------------------------------------------- bool File_SmpteSt0337::Synched_Test() { // Skip NULL padding size_t Buffer_Offset_Temp=Buffer_Offset; if (Aligned) { if (Container_Bits==16) { 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 (Container_Bits==20) { while ((Buffer_TotalBytes+Buffer_Offset_Temp)%5) // 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+5<=Buffer_Size && CC5(Buffer+Buffer_Offset_Temp)==0x0000000000LL) Buffer_Offset_Temp+=5; if (Buffer_Offset_Temp+5>Buffer_Size) { Element_WaitForMoreData(); return false; } } if (Container_Bits==24) { 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 (Container_Bits==32) { 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; } } } else { while(Buffer_Offset_Temp+NullPadding_Size=Buffer_Size) { Element_WaitForMoreData(); return false; } } #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"); GuardBand_Before+=Buffer_Offset_Temp-Buffer_Offset; } #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)!=0x00F872004E1FLL) {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 (CC8(Buffer+Buffer_Offset)!=0x0000F87200004E1FLL) {Synched=false; return true;} break; case 20 : if (CC8(Buffer+Buffer_Offset)!=0x006F87200054E1F0LL) {Synched=false; return true;} break; case 24 : if (CC8(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 20 : if (CC5(Buffer+Buffer_Offset)!=0x72F8F6E154LL) {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_SmpteSt0337::Synched_Init() { if (Frame_Count_NotParsedIncluded==(int64u)-1) Frame_Count_NotParsedIncluded=0; if (FrameInfo.DTS==(int64u)-1) FrameInfo.DTS=0; } //*************************************************************************** // Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_SmpteSt0337::Header_Parse() { // 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+0xE) ; break; case 20 : Size=BigEndian2int24u(Buffer+Buffer_Offset+0xD)>>4; break; case 24 : Size=BigEndian2int24u(Buffer+Buffer_Offset+0xD) ; break; default : ; } break; default : ; } break; case 'L' : switch (Container_Bits) { case 16 : Size=LittleEndian2int16u(Buffer+Buffer_Offset+6) ; break; case 20 : Size=LittleEndian2int24u(Buffer+Buffer_Offset+7)>>4; 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; GuardBand_Before*=Container_Bits; GuardBand_Before/=Stream_Bits; } // Coherency test if (!IsSub && !Status[IsAccepted]) { size_t Offset=Buffer_Offset+(size_t)(Container_Bits*4/8+Size/8); while (OffsetBuffer_Size) { Element_WaitForMoreData(); return; } Offset/=Container_Bits/4; Offset*=Container_Bits/4; bool IsOK=true; for (int8u Pos=0; Pos>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+1]<<4 ) | (Buffer[Buffer_Pos+0]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+0]<<4 ) | (Buffer[Buffer_Pos+4]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+4]<<4 ) | (Buffer[Buffer_Pos+3]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+3]<<4 ) | (Buffer[Buffer_Pos+2]>>4 ); Element_Offset+=5; } } if (Endianness=='L' && Container_Bits==24 && Stream_Bits==16) { // Source: XXXX L1L0 L3L2 XXXX R1R0 R3R2 // Dest : 16BE / L3L2 L1L0 R3R2 R1R0 while (Element_Offset+6<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos+2] ; *(Info_Temp++)= Buffer[Buffer_Pos+1] ; *(Info_Temp++)= Buffer[Buffer_Pos+5] ; *(Info_Temp++)= Buffer[Buffer_Pos+4] ; Element_Offset+=6; } } if (Endianness=='L' && Container_Bits==24 && Stream_Bits==20) { // Source: L0XX L2L1 L4L3 R0XX R2R1 R4R3 // Dest : 20BE / L4L3 L2L1 L0R4 R3R2 R1R0 while (Element_Offset+6<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos+2] ; *(Info_Temp++)= Buffer[Buffer_Pos+1] ; *(Info_Temp++)=(Buffer[Buffer_Pos ]&0xF0) | (Buffer[Buffer_Pos+5]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+5]<<4 ) | (Buffer[Buffer_Pos+4]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+4]<<4 ) | (Buffer[Buffer_Pos+3]>>4 ); Element_Offset+=6; } } if (Endianness=='L' && Container_Bits==24 && Stream_Bits==24) { // Source: 24LE / L1L0 L3L2 L5L3 R1R0 R3R2 R5R4 // Dest : 24BE / L5L3 L3L2 L1L0 R5R4 R3R2 R1R0 while (Element_Offset+6<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos+2] ; *(Info_Temp++)= Buffer[Buffer_Pos+1] ; *(Info_Temp++)= Buffer[Buffer_Pos ] ; *(Info_Temp++)= Buffer[Buffer_Pos+5] ; *(Info_Temp++)= Buffer[Buffer_Pos+4] ; *(Info_Temp++)= Buffer[Buffer_Pos+3] ; Element_Offset+=6; } } if (Endianness=='L' && Container_Bits==32 && Stream_Bits==16) { // Source: XXXX XXXX L1L0 L3L2 XXXX XXXX R1R0 R3R2 // Dest : 16BE / L3L2 L1L0 R3R2 R1R0 while (Element_Offset+8<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos+3] ; *(Info_Temp++)= Buffer[Buffer_Pos+2] ; *(Info_Temp++)= Buffer[Buffer_Pos+7] ; *(Info_Temp++)= Buffer[Buffer_Pos+6] ; Element_Offset+=8; } } if (Endianness=='L' && Container_Bits==32 && Stream_Bits==20) { // Source: XXXX L0XX L2L1 L4L3 XXXX R0XX R2R1 R4R3 // Dest : 20BE / L4L3 L2L1 L0R4 R3R2 R1R0 while (Element_Offset+8<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos+3] ; *(Info_Temp++)= Buffer[Buffer_Pos+2] ; *(Info_Temp++)=(Buffer[Buffer_Pos+1]&0xF0) | (Buffer[Buffer_Pos+7]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+7]<<4 ) | (Buffer[Buffer_Pos+6]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+6]<<4 ) | (Buffer[Buffer_Pos+5]>>4 ); Element_Offset+=8; } } if (Endianness=='L' && Container_Bits==32 && Stream_Bits==24) { // Source: XXXX L1L0 L3L2 L5L3 XXXX R1R0 R3R2 R5R4 // Dest : 24BE / L5L3 L3L2 L1L0 R5R4 R3R2 R1R0 while (Element_Offset+8<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos+3] ; *(Info_Temp++)= Buffer[Buffer_Pos+2] ; *(Info_Temp++)= Buffer[Buffer_Pos+1] ; *(Info_Temp++)= Buffer[Buffer_Pos+7] ; *(Info_Temp++)= Buffer[Buffer_Pos+6] ; *(Info_Temp++)= Buffer[Buffer_Pos+5] ; Element_Offset+=8; } } if (Endianness=='B' && Container_Bits==24 && Stream_Bits==20) { // Source: L4L3 L2L1 L0XX R4R3 R2R1 R0XX // Dest : 20BE / L4L3 L2L1 L0R4 R3R2 R1R0 while (Element_Offset+6<=Element_Size) { size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset; *(Info_Temp++)= Buffer[Buffer_Pos ] ; *(Info_Temp++)= Buffer[Buffer_Pos+1] ; *(Info_Temp++)=(Buffer[Buffer_Pos+2]&0xF0) | (Buffer[Buffer_Pos+3]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+3]<<4 ) | (Buffer[Buffer_Pos+4]>>4 ); *(Info_Temp++)=(Buffer[Buffer_Pos+4]<<4 ) | (Buffer[Buffer_Pos+5]>>4 ); Element_Offset+=6; } } Save_Buffer=Buffer; Save_Buffer_Offset=Buffer_Offset; Save_Buffer_Size=Buffer_Size; Save_Element_Size=Element_Size; File_Offset+=Buffer_Offset; Buffer=Info; Buffer_Offset=0; Buffer_Size=Info_Temp-Info; Element_Offset=0; Element_Size=Buffer_Size; } // 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(Smpte_St0337_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; #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 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 #if defined(MEDIAINFO_AAC_YES) Parser=new File_Aac(); ((File_Aac*)Parser)->Mode=File_Aac::Mode_ADTS; #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_MuxingMode, "ADTS"); } #endif //defined(MEDIAINFO_AAC_YES) break; case 10 : // MPEG-4 AAC in ADTS or LATM case 11 : // MPEG-4 AAC in ADTS or LATM #if defined(MEDIAINFO_AAC_YES) 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 //defined(MEDIAINFO_AAC_YES) break; case 28 : // Dolby E Parser=new File_DolbyE(); break; default : ; } if (Parser) { Open_Buffer_Init(Parser); } } #if MEDIAINFO_DEMUX if (Save_Buffer) { std::swap(Buffer, Save_Buffer); std::swap(Buffer_Offset, Save_Buffer_Offset); std::swap(Buffer_Size, Save_Buffer_Size); std::swap(Element_Size, Save_Element_Size); File_Offset-=Buffer_Offset; } if (data_type==28) //If Dolby E, we must demux the SMPTE ST 337 header too (TODO: add an option for forcing SMPTE ST 337 header) { int64u Demux_Element_Offset=Element_Offset; Element_Offset=0; if (Container_Bits==20) { //We must pad to 24 bits int8u* Info2=new int8u[(size_t)Element_Size*6/5]; size_t Info2_Offset=0; const int8u* Demux_Buffer=Buffer+Buffer_Offset; size_t Demux_Buffer_Size=(size_t)Element_Size; size_t Demux_Buffer_Pos=0; // Source: 20LE L1L0 L3L2 R0L4 R2R1 R4R3 // Dest : L0XX L2L1 L4L3 R0XX R2R1 R4R3 while (Demux_Buffer_Pos+5<=Demux_Buffer_Size) { Info2[Info2_Offset+0]= Demux_Buffer[Demux_Buffer_Pos+0]<<4 ; Info2[Info2_Offset+1]=(Demux_Buffer[Demux_Buffer_Pos+1]<<4 ) | (Demux_Buffer[Demux_Buffer_Pos+0]>>4 ); Info2[Info2_Offset+2]=(Demux_Buffer[Demux_Buffer_Pos+2]<<4 ) | (Demux_Buffer[Demux_Buffer_Pos+1]>>4 ); Info2[Info2_Offset+3]= Demux_Buffer[Demux_Buffer_Pos+2]&0xF0 ; Info2[Info2_Offset+4]= Demux_Buffer[Demux_Buffer_Pos+3] ; Info2[Info2_Offset+5]= Demux_Buffer[Demux_Buffer_Pos+4] ; Info2_Offset+=6; Demux_Buffer_Pos+=5; } Demux(Info2, Info2_Offset, ContentType_MainStream); delete[] Info2; } else Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream); Element_Offset=Demux_Element_Offset; } else Demux(Buffer+Buffer_Offset+Container_Bits/2, (size_t)(Element_Size-Container_Bits/2), ContentType_MainStream); if (Save_Buffer) { File_Offset+=Buffer_Offset; std::swap(Buffer, Save_Buffer); std::swap(Buffer_Offset, Save_Buffer_Offset); std::swap(Buffer_Size, Save_Buffer_Size); std::swap(Element_Size, Save_Element_Size); } #endif //MEDIAINFO_DEMUX if (Parser && !Parser->Status[IsFinished]) { switch(data_type) { case 28 : ((File_DolbyE*)Parser)->GuardBand_Before+=GuardBand_Before; ((File_DolbyE*)Parser)->GuardBand_After+=GuardBand_After; break; default : ; } Parser->FrameInfo=FrameInfo; Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); Element_Offset=Element_Size; #if MEDIAINFO_DEMUX FrameInfo.DUR=Parser->FrameInfo.DUR; if (FrameInfo.DUR!=(int64u)-1) FrameInfo.DTS+=FrameInfo.DUR; else FrameInfo.DTS=(int64u)-1; FrameInfo.PTS=FrameInfo.DTS; #endif // MEDIAINFO_DEMUX } else { Skip_XX(Element_Size-Element_Offset, "Data"); } FILLING_BEGIN(); FrameSizes[IsSub?Buffer_Size:((GuardBand_Before+Element_Size)*Container_Bits/Stream_Bits)]++; Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (Parser==NULL || (Frame_Count>=2 && Parser->Status[IsFilled])) Fill("SMPTE ST 337"); if (Parser==NULL || (Frame_Count>=2 && Parser->Status[IsFinished])) Finish("SMPTE ST 337"); FILLING_END(); if (Save_Buffer) { delete[] Buffer; Buffer=Save_Buffer; Buffer_Offset=Save_Buffer_Offset; Buffer_Size=Save_Buffer_Size; File_Offset-=Buffer_Offset; } // Guard band GuardBand_Before=0; GuardBand_After=0; } //*************************************************************************** // C++ //*************************************************************************** } // NameSpace #endif // MEDIAINFO_SMPTEST0337_YES MediaInfoLib/Source/MediaInfo/Audio/File_Tta.cpp0000664000000000000000000001137612652076434020410 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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=((int64u)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 MediaInfoLib/Source/MediaInfo/Audio/File_Speex.h0000664000000000000000000000251212652076434020401 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 bool Identification_Done; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Pcm_M2ts.h0000664000000000000000000000264612652076434020751 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PCM (from Blu-ray) streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_Pcm_M2tsH #define MediaInfo_File_Pcm_M2tsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Pcm_M2ts //*************************************************************************** class File_Pcm_M2ts : public File__Analyze { public : //Constructor/Destructor File_Pcm_M2ts(); private : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue (); //Temp int8u channel_assignment; int8u sampling_frequency; int8u bits_per_sample; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_DolbyE.h0000664000000000000000000000363212652076434020477 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 : //In int64u GuardBand_Before; int64u GuardBand_After; //Constructor/Destructor File_DolbyE(); private : //Streams management void Streams_Fill(); //Buffer - Synchro bool Synchronize(); bool Synched_Test(); //Buffer - Per element void Header_Parse(); void Data_Parse(); //Elements void Block(); //Helpers bool Descramble_16bit(); bool Descramble_20bit(); bool Descramble_24bit(); //Temp int64u SMPTE_time_code_StartTimecode; int8u ProgramConfiguration; int8u FrameRate; int8u BitDepth; bool ScrambledBitStream; int8u* Descrambled_Buffer; //Used in case of scrambled bitstream int64u GuardBand_Before_Initial; int64u GuardBand_After_Initial; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Au.h0000664000000000000000000000227112652076434017664 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Aac_GeneralAudio.h0000664000000000000000000017471612652076434022440 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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[13] = { 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 Aac_swb_short_window_8 //7350 }; //--------------------------------------------------------------------------- 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[13]= { 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 Aac_swb_long_window_8 //7350 }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Wvpk.cpp0000664000000000000000000006772112652076434020614 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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>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=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 MediaInfoLib/Source/MediaInfo/Audio/File_Ac3.cpp0000664000000000000000000027620712652076434020274 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Internal.h" using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- const int32u AC3_SamplingRate2[]= { 24000, 22050, 16000, 0,}; //--------------------------------------------------------------------------- const char* AC3_ChannelPositions[]= { "Dual mono", "Front: C", "Front: L R", "Front: L C R", "Front: L R, Back: C", "Front: L C R, Back: C", "Front: L R, Side: L R", "Front: L C R, Side: L R", }; //--------------------------------------------------------------------------- const char* AC3_ChannelPositions2[]= { "1+1", "1/0/0", "2/0/0", "3/0/0", "2/1/0", "3/1/0", "2/2/0", "3/2/0", }; //--------------------------------------------------------------------------- const char* AC3_ChannelLayout_lfeoff[]= { "1+1", "C", "L R", "L C R", "L R S", "L C R Cs", "L R Ls Rs", "L C R Ls Rs", }; //--------------------------------------------------------------------------- const char* AC3_ChannelLayout_lfeon[]= { "1+1 LFE", "C LFE", "L R LFE", "L C R LFE", "L R S LFE", "L C R LFE Cs", "L R LFE Ls Rs", "L C R LFE Ls Rs", }; //--------------------------------------------------------------------------- int16u AC3_acmod2chanmap[]= { 0xA000, 0x4000, 0xA000, 0xE000, 0xA100, 0xE100, 0xB900, 0xF800, }; //--------------------------------------------------------------------------- Ztring AC3_chanmap_ChannelPositions (int16u chanmap) { Ztring Front; Ztring Side; Ztring Back; Ztring More; for (int8u Pos=0; Pos<16; Pos++) { if (chanmap&(1<<(15-Pos))) { switch (Pos) { case 0 : Front+=__T(" L"); break; case 1 : Front+=__T(" C"); break; case 2 : Front+=__T(" R"); break; case 3 : Side+=__T(" L"); break; case 4 : Side+=__T(" R"); break; case 5 : { bool HasR=false; if (Front.find(__T(" R"))!=string::npos) { Front.resize(Front.size()-2); HasR=true; } Front+=__T(" C C"); if (HasR) Front+=__T(" R"); } break; case 6 : Back+=__T(" L R"); break; case 7 : if (Back.empty()) Back=__T(" C"); else Back=__T(" L C R"); break; case 15 : More+=__T(", LFE"); break; default: ; } } } Ztring ToReturn; if (!Front.empty()) { ToReturn+=__T("Front:")+Front; } if (!Side.empty()) { if (!ToReturn.empty()) ToReturn+=__T(", "); ToReturn+=__T("Side:")+Side; } if (!Back.empty()) { if (!ToReturn.empty()) ToReturn+=__T(", "); ToReturn+=__T("Back:")+Back; } ToReturn+=More; return ToReturn; } //--------------------------------------------------------------------------- int8u AC3_chanmap_Channels (int16u chanmap) { int8u Channels=0; for (int8u Pos=0; Pos<16; Pos++) { if (chanmap&(1<<(15-Pos))) { switch (Pos) { case 5 : case 6 : case 9 : case 10 : case 11 : Channels+=2; break; default: Channels++; break; } } } return Channels; } //--------------------------------------------------------------------------- Ztring AC3_chanmap_ChannelLayout (int16u chanmap, const Ztring &ChannelLayout0) { Ztring ToReturn=ChannelLayout0; for (int8u Pos=0; Pos<16; Pos++) { if (chanmap&(1<<(15-Pos))) { switch (Pos) { case 5 : ToReturn+=__T(" Lc Rc"); break; case 6 : ToReturn+=__T(" Lrs Rrs"); break; case 7 : ToReturn+=__T(" Cs"); default: ; } } } return ToReturn; } //--------------------------------------------------------------------------- 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 Frame_Count_HD=0; fscod=0; fscod2=0; frmsizecod=0; bsid_Max=(int8u)-1; for (int8u Pos=0; Pos<8; Pos++) for (int8u Pos2=0; Pos2<9; Pos2++) { frmsizplus1_Max[Pos][Pos2]=0; acmod_Max[Pos][Pos2]=(int8u)-1; lfeon_Max[Pos][Pos2]=false; bsmod_Max[Pos][Pos2]=0; dsurmod_Max[Pos][Pos2]=0; chanmape_Max[Pos][Pos2]=false; chanmap_Max[Pos][Pos2]=0; } numblkscod=0; substreamid_Independant_Current=0; substreams_Count=0; dxc3_Parsed=false; HD_MajorSync_Parsed=false; Core_IsPresent=false; HD_IsPresent=false; HD_HasAtmos=false; dynrnge_Exists=false; TimeStamp_IsPresent=false; TimeStamp_IsParsing=false; TimeStamp_Parsed=false; TimeStamp_DropFrame_IsValid=false; BigEndian=true; IgnoreCrc_Done=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 { if (HD_HasAtmos) { Fill(Stream_General, 0, General_Format, "Atmos"); Fill(Stream_Audio, 0, Audio_Format, "Atmos"); Fill(Stream_Audio, 0, Audio_Codec, "Atmos"); Fill(Stream_Audio, 0, Audio_Channel_s_, "Object Based"); Fill(Stream_Audio, 0, Audio_ChannelPositions, "Object Based"); Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, "Object Based"); } 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"); Ztring Sampling; Sampling.From_Number(AC3_HD_SamplingRate(HD_SamplingRate1)); if (HD_HasAtmos) Sampling.insert(0, __T(" / ")); Fill(Stream_Audio, 0, Audio_SamplingRate, Sampling); 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_Max<=0x09) { 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"); int32u Divider=bsid_Max==9?2:1; // Unofficial hack for low sample rate (e.g. 22.05 kHz) if (Ztring::ToZtring(AC3_SamplingRate[fscod]/Divider)!=Retrieve(Stream_Audio, 0, Audio_SamplingRate)) Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_SamplingRate[fscod]/Divider); if (frmsizecod/2<19) { if (Frame_Count_HD) Fill(Stream_Audio, 0, Audio_BitRate, "Unknown"); int32u BitRate=AC3_BitRate[frmsizecod/2]*1000; int32u Divider=bsid_Max==9?2:1; // Unofficial hack for low sample rate (e.g. 22.05 kHz) Fill(Stream_Audio, 0, Audio_BitRate, BitRate/Divider); 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"); } } Fill(Stream_Audio, 0, Audio_Format_Settings_ModeExtension, AC3_Mode[bsmod_Max[0][0]]); if (acmod_Max[0][0]==0) Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, "Dual Mono"); if (acmod_Max[0][0]!=(int8u)-1) { int8u Channels=AC3_Channels[acmod_Max[0][0]]; Ztring ChannelPositions; ChannelPositions.From_Local(AC3_ChannelPositions[acmod_Max[0][0]]); Ztring ChannelPositions2; ChannelPositions2.From_Local(AC3_ChannelPositions2[acmod_Max[0][0]]); Ztring ChannelLayout; ChannelLayout.From_Local(lfeon_Max[0][0]?AC3_ChannelLayout_lfeon[acmod_Max[0][0]]:AC3_ChannelLayout_lfeoff[acmod_Max[0][0]]); if (lfeon_Max[0][0]) { 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 (ChannelLayout!=Retrieve(Stream_Audio, 0, Audio_ChannelLayout)) Fill(Stream_Audio, 0, Audio_ChannelLayout, ChannelLayout); } if (dsurmod_Max[0][0]==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_Max<=0x10) { for (size_t Pos=0; Pos<8; Pos++) if (acmod_Max[Pos][0]!=(int8u)-1) { Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "E-AC-3"); Fill(Stream_Audio, 0, Audio_Codec, "AC3+"); if (acmod_Max[1][0]!=(int8u)-1) Fill(Stream_Audio, 0, Audio_ID, 1+Pos); Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR"); int8u numblks=numblkscod==3?6:numblkscod+1; int32u frmsiz_Total=0; for (size_t Pos2=0; Pos2<8; Pos2++) frmsiz_Total+=frmsizplus1_Max[Pos][Pos2]; if (numblks) { Fill(Stream_Audio, 0, Audio_BitRate, ((frmsiz_Total*2)*8*(750/((int32u)numblks)))/4); if (frmsizplus1_Max[Pos][1]) //If dependand substreams Fill(Stream_Audio, 0, Audio_BitRate, ((frmsizplus1_Max[Pos][0]*2)*8*(750/((int16u)numblks)))/4); } if (fscod!=3) Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_SamplingRate[fscod]); else Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_SamplingRate2[fscod2]); if (acmod_Max[Pos][1]!=(int8u)-1) { int16u chanmap_Final=0; for (int8u Pos2=0; Pos2<9; Pos2++) if (acmod_Max[Pos][Pos2]!=(int8u)-1) { if (chanmape_Max[Pos][Pos2]) chanmap_Final|=chanmap_Max[Pos][Pos2]; else { chanmap_Final|=AC3_acmod2chanmap[acmod_Max[Pos][Pos2]]; if (lfeon_Max[Pos][Pos2]) chanmap_Final|=1; // LFE position in chanmap is bit 0 } } Fill(Stream_Audio, 0, Audio_Channel_s_, AC3_chanmap_Channels(chanmap_Final)); Fill(Stream_Audio, 0, Audio_ChannelPositions, AC3_chanmap_ChannelPositions(chanmap_Final)); Ztring ChannelLayout; ChannelLayout.From_Local(lfeon_Max[0][0]?AC3_ChannelLayout_lfeon[acmod_Max[0][0]]:AC3_ChannelLayout_lfeoff[acmod_Max[0][0]]); Fill(Stream_Audio, 0, Audio_ChannelLayout, AC3_chanmap_ChannelLayout(chanmap_Final, ChannelLayout)); } if (acmod_Max[Pos][0]==0) { Fill(Stream_Audio, 0, Audio_Format_Profile, "Dual Mono"); Fill(Stream_Audio, 0, Audio_Codec_Profile, "Dual Mono"); } else if (acmod_Max[Pos][0]!=(int8u)-1) { int8u Channels=AC3_Channels[acmod_Max[Pos][0]]; Ztring ChannelPositions; ChannelPositions.From_Local(AC3_ChannelPositions[acmod_Max[Pos][0]]); if (lfeon_Max[Pos][0]) { Channels+=1; ChannelPositions+=__T(", LFE"); } Fill(Stream_Audio, 0, Audio_Channel_s_, Channels); Fill(Stream_Audio, 0, Audio_ChannelPositions, ChannelPositions); Fill(Stream_Audio, 0, Audio_ChannelLayout, lfeon_Max[0][0]?AC3_ChannelLayout_lfeon[acmod_Max[0][0]]:AC3_ChannelLayout_lfeoff[acmod_Max[0][0]]); } } } 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"); Fill(Stream_Audio, 0, "bsid", bsid_Max); 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"); } for (int8u Pos=0; Pos<8; Pos++) for (int8u Pos2=0; Pos2<9; Pos2++) { if (acmod_Max[Pos][Pos2]==(int8u)-1) break; if (acmod_Max[Pos][Pos2]!=(int8u)-1) { if (acmod_Max[Pos][Pos2]==2) { Fill(Stream_Audio, 0, "dsurmod", dsurmod_Max[Pos][Pos2]); (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dsurmod"), Info_Options)=__T("N NT"); Fill(Stream_Audio, 0, "dsurmod/String", AC3_Surround[dsurmod_Max[Pos][Pos2]]); (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dsurmod/String"), Info_Options)=__T("N NT"); } (*Stream_More)[Stream_Audio][0](Ztring().From_Local("bsid"), Info_Options)=__T("N NT"); Fill(Stream_Audio, 0, "acmod", acmod_Max[Pos][Pos2]); (*Stream_More)[Stream_Audio][0](Ztring().From_Local("acmod"), Info_Options)=__T("N NT"); Fill(Stream_Audio, 0, "lfeon", (lfeon_Max[Pos][Pos2])?1:0); (*Stream_More)[Stream_Audio][0](Ztring().From_Local("lfeon"), 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"); } //Samples per frame int16u SamplesPerFrame; if (bsid_Max<=0x08) SamplesPerFrame=1536; else if (bsid_Max<=0x09) SamplesPerFrame=768; // Unofficial hack for low sample rate (e.g. 22.05 kHz) else if (bsid_Max>0x0A && bsid_Max<=0x10) SamplesPerFrame=256; else if (HD_MajorSync_Parsed && (HD_StreamType==0xBA || HD_StreamType==0xBB)) // TrueHD or MLP SamplesPerFrame=40; else SamplesPerFrame=0; if (SamplesPerFrame) Fill(Stream_Audio, 0, Audio_SamplesPerFrame, SamplesPerFrame); } //--------------------------------------------------------------------------- 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(Pos==0?31:Pos)) Maximum_Raw=(Pos==0?31:Pos); Sum_Intensity+=dialnorms[Pos]*pow(10, -((float64)Pos)/10); Count+=dialnorms[Pos]; } if (Count) { 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>4]+20*std::log10(((float)(0x10+(Pos&0x0F)))/32); if (Minimum_dB>Value) Minimum_dB=Value; if (Maximum_dB>5]+20*std::log10(((float)(0x20+(Pos&0x1F)))/64); if (Minimum_dB>Value) Minimum_dB=Value; if (Maximum_dBfirst, fscods.begin()->first); if (Size) { 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 (Frame_Count_HD) { 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=Frame_Count_HD*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, Frame_Count_HD); } } if (Core_IsPresent) { Fill(Stream_Audio, 0, Audio_FrameCount, Frame_Count_ForDuration); if (AC3_SamplingRate[fscod]) { float64 FrameDuration; if (bsid_Max<=0x08) FrameDuration=32; else if (bsid_Max<=0x09) FrameDuration=16; // Unofficial hack for low sample rate (e.g. 22.05 kHz) else FrameDuration=0; if (FrameDuration) { FrameDuration*=((float64)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; int32u Divider=bsid_Max==9?2:1; // Unofficial hack for low sample rate (e.g. 22.05 kHz) Fill(Stream_Audio, 0, Audio_BitRate, BitRate/Divider); } } } } } else if (FrameInfo.PTS!=(int64u)-1 && FrameInfo.PTS>PTS_Begin) { Fill(Stream_Audio, 0, Audio_Duration, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000)); float64 FrameDuration; if (bsid_Max<=0x08) FrameDuration=32; else if (bsid_Max<=0x09) FrameDuration=16; // Unofficial hack for low sample rate (e.g. 22.05 kHz) else if (bsid_Max>0x0A && bsid_Max<=0x10) FrameDuration=((float64)32)/6; else FrameDuration=0; if (FrameDuration) Fill(Stream_Audio, 0, Audio_FrameCount, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000/FrameDuration)); } } //--------------------------------------------------------------------------- void File_Ac3::Read_Buffer_Unsynched() { 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 (!FileHeader_Begin_0x000001()) { 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+0x00]==0x01 //Magic value? Always 0x01 && Buffer[Buffer_Offset-0x10+0x01]==0x10 //Size? Always 0x10 && 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 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 } //--------------------------------------------------------------------------- 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+0x00]==0x01 //Magic value? Always 0x01 && Buffer[Buffer_Offset+0x01]==0x10 //Size? Always 0x10 && 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 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 && 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 (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); } if (Buffer[Buffer_Offset]==0x0B && Buffer[Buffer_Offset+1]==0x77) { int8u bsid=Buffer[Buffer_Offset+5]>>3; if (bsid<=0x08) FrameInfo.DUR=32000000; else if (bsid<=0x09) FrameInfo.DUR=16000000; // Unofficial hack for low sample rate (e.g. 22.05 kHz) else if (bsid>0x0A && bsid<=0x10) { numblkscod=(Buffer[Buffer_Offset+4]>>4)&0x3; int64u numblks=numblkscod==3?6:numblkscod+1; FrameInfo.DUR=32000000*numblks/6; } Demux_Offset=Buffer_Offset+Core_Size_Get(); //Core part if (HD_IsPresent) { if (TimeStamp_IsPresent) Buffer_Offset-=16; 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; } return true; //No AC-3 demux } } else { Demux_Offset=Buffer_Offset+HD_Size_Get(); } if (Demux_Offset>Buffer_Size && File_Offset+Buffer_Size!=File_Size) { if (TimeStamp_IsPresent) Buffer_Offset-=16; 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; } return false; //No complete frame } 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; } } //*************************************************************************** // 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 if (Save_Buffer) { File_Offset+=Buffer_Offset; swap(Buffer, Save_Buffer); swap(Buffer_Offset, Save_Buffer_Offset); swap(Buffer_Size, Save_Buffer_Size); } //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"); //Little Endian management if (Save_Buffer) { swap(Buffer, Save_Buffer); swap(Buffer_Offset, Save_Buffer_Offset); swap(Buffer_Size, Save_Buffer_Size); File_Offset-=Buffer_Offset; } return; } //MLP or TrueHD specific int16u Size; BS_Begin(); Skip_S1( 4, "CRC?"); Get_S2 (12, Size, "Size"); BS_End(); Skip_B2( "Timestamp?"); //Little Endian management if (Save_Buffer) { swap(Buffer, Save_Buffer); swap(Buffer_Offset, Save_Buffer_Offset); swap(Buffer_Size, Save_Buffer_Size); } //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) { File_Offset+=Buffer_Offset; swap(Buffer, Save_Buffer); swap(Buffer_Offset, Save_Buffer_Offset); swap(Buffer_Size, Save_Buffer_Size); } //Parsing switch (Element_Code) { case 0 : Core(); break; case 1 : Element_Info1C((FrameInfo.PTS!=(int64u)-1), __T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000))); Element_Info1(Frame_Count); HD(); 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; File_Offset-=Buffer_Offset; } } //--------------------------------------------------------------------------- void File_Ac3::Core() { while (Element_Offset0x10) return; //Not supported //Counting if (Frame_Count==0) { Core_IsPresent=true; PTS_Begin=FrameInfo.PTS; } if (bsid==0x09) Frequency_b=AC3_SamplingRate2[fscod]; // Unofficial hack for low sample rate (e.g. 22.05 kHz) else { if (fscod!=3) Frequency_b=AC3_SamplingRate[fscod]; else Frequency_b=AC3_SamplingRate2[fscod2]; } if (bsid>0x0A) { int64u numblks = numblkscod == 3 ? 6 : numblkscod + 1; TS_Add(numblks*256); } else TS_Add(1536); 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[IsAccepted]) Accept("AC-3"); 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::Core_Frame() { //Parsing int16u frmsiz=0, chanmap=0; int8u dialnorm=(int8u)-1, dialnorm2=(int8u)-1, compr=(int8u)-1, compr2=(int8u)-1, dynrng=(int8u)-1, dynrng2=(int8u)-1; int8u strmtyp=0, substreamid=0, acmod=0, bsmod=0, dsurmod=0; bool compre=false, compr2e=false, dynrnge=false, dynrng2e=false; bool lfeon=false, chanmape=false; if (bsid<=0x09) { 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"); //Note: if timecod is used, change the bitstream parsing for bsid==0x06 TEST_SB_END(); TEST_SB_SKIP( "timecod2e"); Skip_S1(14, "timecod2"); //Note: if timecod is used, change the bitstream parsing for bsid==0x06 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; Pos0x0A && bsid<=0x10) { Element_Begin1("synchinfo"); Skip_B2( "syncword"); Element_End0(); Element_Begin1("bsi"); BS_Begin(); size_t Bits_Begin=Data_BS_Remain(); Get_S1 ( 2, strmtyp, "strmtyp"); Get_S1 ( 3, substreamid, "substreamid"); Get_S2 (11, frmsiz, "frmsiz"); Get_S1 ( 2, fscod, "fscod"); Param_Info2(AC3_SamplingRate[fscod], " Hz"); if (fscod==3) { Get_S1 ( 2, fscod2, "fscod2"); Param_Info2(AC3_SamplingRate2[fscod2], " Hz"); 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_GET (chanmape, "chanmape"); Get_S2(16, chanmap, "chanmap"); Param_Info1(AC3_chanmap_ChannelPositions(chanmap)); TEST_SB_END(); } Element_End0(); if (Data_BS_Remain()<17) { BS_End(); Trusted_IsNot("Not enough data"); } else { Element_Begin1("errorcheck"); size_t BitsUpToEndOfFrame=(frmsiz*2)*8-(Bits_Begin-Data_BS_Remain()); Skip_BS(BitsUpToEndOfFrame-17, "bsi(continue)+audfrm+x*audblk+auxdata+errorcheck"); Skip_SB( "encinfo"); BS_End(); Skip_B2( "crc2"); Element_End0(); } } else Skip_XX(Element_Size-Element_Offset, "Unknown"); FILLING_BEGIN(); if (bsid>0x10) return; //Not supported //Information if (strmtyp>1) strmtyp=0; //TODO: check a file with strmtyp==2 if (strmtyp==0) substreamid_Independant_Current=substreamid; if (bsid_Max==(int8u)-1 || bsid>bsid_Max) bsid_Max=bsid; //Specific to first frame if (Frame_Count==0) { frmsizplus1_Max[substreamid_Independant_Current][strmtyp+substreamid]=frmsiz+1; acmod_Max[substreamid_Independant_Current][strmtyp+substreamid]=acmod; lfeon_Max[substreamid_Independant_Current][strmtyp+substreamid]=lfeon; bsmod_Max[substreamid_Independant_Current][strmtyp+substreamid]=bsmod; dsurmod_Max[substreamid_Independant_Current][strmtyp+substreamid]=dsurmod; chanmape_Max[substreamid_Independant_Current][strmtyp+substreamid]=chanmape; chanmap_Max[substreamid_Independant_Current][strmtyp+substreamid]=chanmap; 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]++; } FILLING_END(); } //--------------------------------------------------------------------------- void File_Ac3::HD() { //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>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"); BS_Begin(); Skip_S1( 7, "Unknown"); bool HasExtend; Get_SB ( HasExtend, "Has Extend"); BS_End(); if (HasExtend) { unsigned char Extend = 0; unsigned char Unknown = 0; bool HasContent = false; BS_Begin(); Get_S1( 4, Extend, "Extend Header"); Get_S1( 4, Unknown, "Unknown"); if (Unknown) HasContent = true; BS_End(); for (Extend = (Extend * 2) + 1; Extend > 0; Extend--) { Get_B1(Unknown, "Unknown"); if (Unknown) HasContent = true; } if (HasContent) HD_HasAtmos=true; //Currently only Atmos is known as having data here } 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 Sizes; for (int8u Pos=0; Pos=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::TimeStamp() { //Parsing int8u H1, H2, M1, M2, S1, S2, F1, F2; Skip_B1( "Magic value"); Skip_B1( "Size?"); 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( "Unknown"); Skip_B2( "Unknown"); Skip_B2( "Unknown (fixed)"); 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_Max[0][0], "bsmod"); Get_S1 (3, acmod_Max[0][0], "acmod"); Get_SB ( lfeon_Max[0][0], "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_Max[Pos][0], "bsmod"); Get_S1 (3, acmod_Max[Pos][0], "acmod"); Get_SB ( lfeon_Max[Pos][0], "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 { bsid=CC1(Buffer+Buffer_Offset+5)>>3; int16u Size=0; if (bsid<=0x09) { 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 { bsid=CC1(Buffer+Buffer_Offset+4)>>3; int16u Size=0; if (bsid<=0x09) { 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; //TODO: case with multiple substreams } 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+1File_Ac3_IgnoreCrc_Get(); IgnoreCrc_Done=true; } if (IgnoreCrc && !Status[IsAccepted]) //Else there are some wrong synchronizations { 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) { Ztring Format=MI.Get(Stream_General, 0, General_Format); if (Format!=__T("AC-3") && Format!=__T("E-AC-3")) IgnoreCrc=false; } else IgnoreCrc=false; // Problem } if (IgnoreCrc) return true; 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>8)^(*CRC_16_Buffer)]; //CRC bytes inversion if (CRC_16_Buffer==CRC_16_Buffer_EndMinus3 && bsid<=0x09 && ((*CRC_16_Buffer)&0x01)) //CRC inversion bit { CRC_16_Buffer++; CRC_16=(CRC_16<<8) ^ CRC_16_Table[(CRC_16>>8)^((int8u)(~(*CRC_16_Buffer)))]; CRC_16_Buffer++; CRC_16=(CRC_16<<8) ^ CRC_16_Table[(CRC_16>>8)^((int8u)(~(*CRC_16_Buffer)))]; } CRC_16_Buffer++; //5/8 intermediate test if (CRC_16_Buffer==CRC_16_Buffer_5_8 && bsid<=0x09 && CRC_16!=0x0000) break; } return (CRC_16==0x0000); } //--------------------------------------------------------------------------- size_t File_Ac3::Core_Size_Get() { int16u Size=1; bsid=(Buffer[(size_t)(Buffer_Offset+5)]&0xF8)>>3; if (bsid<=0x09) { fscod =(Buffer[(size_t)(Buffer_Offset+4)]&0xC0)>>6; frmsizecod= Buffer[(size_t)(Buffer_Offset+4)]&0x3F; //Filling fscods[fscod]++; frmsizecods[frmsizecod]++; Size=AC3_FrameSize_Get(frmsizecod, fscod); } else if (bsid>0x0A && bsid<=0x10) { int16u frmsiz =((int16u)(Buffer[(size_t)(Buffer_Offset+2)]&0x07)<<8) | ( Buffer[(size_t)(Buffer_Offset+3)] ); //Filling Size=2+frmsiz*2; substreams_Count=0; int8u substreams_Count_Independant=0; int8u substreams_Count_Dependant=0; for (;;) { if (Buffer_Offset+Size+6>Buffer_Size) { if (!IsSub && !Save_Buffer) Element_WaitForMoreData(); break; } int8u bsid=Buffer[Buffer_Offset+Size+5]>>3; if (bsid<=0x09 || bsid>0x10) break; //Not E-AC-3 int8u substreamid=(Buffer[Buffer_Offset+Size+2]>>3)&0x07; if (substreamid!=substreams_Count_Independant) break; //Problem if (substreamid!=substreams_Count_Dependant) break; //Problem int8u strmtyp = Buffer[Buffer_Offset + Size + 2] >> 6; if (substreamid==0 && strmtyp==0) break; //Next block frmsiz =((int16u)(Buffer[(size_t)(Buffer_Offset+Size+2)]&0x07)<<8) | ( Buffer[(size_t)(Buffer_Offset+Size+3)] ); //Filling Size+=2+frmsiz*2; if (strmtyp == 0) { substreams_Count_Independant++; substreams_Count_Dependant=0; } else substreams_Count_Dependant++; substreams_Count++; } } 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 MediaInfoLib/Source/MediaInfo/Audio/File_Ape.h0000664000000000000000000000304412652076434020023 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Ape files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_ApeH #define MediaInfo_File_ApeH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_ScreamTracker3.h0000664000000000000000000000242212652076434022126 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_MpcSv8.cpp0000664000000000000000000002235012652076434020772 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_TwinVQ.h0000664000000000000000000000324712652076434020513 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Caf.cpp0000664000000000000000000002531712652076434020351 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_CAF_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_Caf.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //*************************************************************************** // Constants //*************************************************************************** //--------------------------------------------------------------------------- namespace Elements { const int64u data=0x64617461; const int64u desc=0x64657363; const int64u free=0x66726565; const int64u info=0x696E666F; const int64u kuki=0x6B756B69; const int64u pakt=0x70616B74; const int64u uuid=0x75756964; } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Caf::File_Caf() :File__Analyze() { DataMustAlwaysBeComplete=false; } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Caf::FileHeader_Begin() { //Synchro if (3>Buffer_Size) return false; if (Buffer[0]!=0x63 //"caff" || Buffer[1]!=0x61 || Buffer[2]!=0x66 || Buffer[3]!=0x66) { Reject(); return false; } if (8>Buffer_Size) return false; return true; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Caf::FileHeader_Parse() { //Parsing int16u FileVersion; Skip_C4( "FileType"); Get_B2 (FileVersion, "FileVersion"); Skip_B2( "FileFlags"); FILLING_BEGIN(); Accept(); Fill(Stream_General, 0, General_Format, "CAF"); Fill(Stream_General, 0, General_Format_Version, __T("Version ")+Ztring::ToZtring(FileVersion)); Stream_Prepare(Stream_Audio); if (FileVersion!=1) Finish(); //Version 0 or 2+ are not supported FILLING_END(); } //*************************************************************************** // Buffer //*************************************************************************** //--------------------------------------------------------------------------- void File_Caf::Header_Parse() { //Parsing int64u ChunkSize; int32u ChunkType; Get_B4 (ChunkType, "ChunkType"); Get_B8(ChunkSize, "ChunkSize"); //Filling Header_Fill_Code2(ChunkType, Ztring().From_CC4(ChunkType)); Header_Fill_Size(12+ChunkSize); } //--------------------------------------------------------------------------- void File_Caf::Data_Parse() { if (Element_Code!=Elements::data && !Element_IsComplete_Get()) { Element_WaitForMoreData(); return; } #define ELEMENT_CASE(_NAME, _DETAIL) \ case Elements::_NAME : Element_Name(_DETAIL); _NAME(); break; //Parsing switch (Element_Code) { ELEMENT_CASE(data, "Audio Data"); ELEMENT_CASE(desc, "Audio Description"); ELEMENT_CASE(free, "Free"); ELEMENT_CASE(info, "Information"); ELEMENT_CASE(kuki, "Magic Cookie"); ELEMENT_CASE(pakt, "Packet Table"); ELEMENT_CASE(uuid, "User-Defined Chunk"); default : Skip_XX(Element_Size, "Data"); } } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Caf::data() { //Parsing Skip_XX(Element_Size, "Data"); Fill(Stream_Audio, 0, Retrieve(Stream_Audio, 0, Audio_Source_Duration).empty()?Audio_StreamSize:Audio_Source_StreamSize, Element_Size); //TODO: put this code in the common section Streams_Finish_StreamOnly() int64u BitRate=Retrieve(Stream_Audio, 0, "BitRate").To_int64u(); if (BitRate && Element_Size && Retrieve(Stream_Audio, 0, Audio_Source_Duration).empty() && Retrieve(Stream_Audio, 0, Audio_Duration).empty()) Fill(Stream_Audio, 0, Audio_Duration, Element_Size*8*1000/BitRate); } //--------------------------------------------------------------------------- void File_Caf::desc() { //Parsing float64 SampleRate; int32u FormatID, FormatFlags, BytesPerPacket, FramesPerPacket, ChannelsPerFrame, BitsPerChannel; Get_BF8(SampleRate, "SampleRate"); Get_C4 (FormatID, "FormatID"); Get_B4 (FormatFlags, "FormatFlags"); Get_B4 (BytesPerPacket, "BytesPerPacket"); Get_B4 (FramesPerPacket, "FramesPerPacket"); Get_B4 (ChannelsPerFrame, "ChannelsPerFrame"); Get_B4 (BitsPerChannel, "BitsPerChannel"); FILLING_BEGIN(); if (SampleRate) Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate); CodecID_Fill(Ztring().From_CC4(FormatID), Stream_Audio, 0, InfoCodecID_Format_Mpeg4); if (ChannelsPerFrame) Fill(Stream_Audio, 0, Audio_Channel_s_, ChannelsPerFrame); if (BitsPerChannel) Fill(Stream_Audio, 0, Audio_BitDepth, BitsPerChannel); if (BytesPerPacket && SampleRate && FramesPerPacket) Fill(Stream_Audio, 0, Audio_BitRate, SampleRate*BytesPerPacket*8/FramesPerPacket); FILLING_END(); } //--------------------------------------------------------------------------- void File_Caf::free() { //Parsing Skip_XX(Element_Size, "Junk"); } //--------------------------------------------------------------------------- void File_Caf::info() { if (Element_Size<4) return; //Parsing int32u NumEntries; Get_B4 (NumEntries, "NumEntries"); ZtringList List; std::map ListList; const int8u* Buffer_Max = Buffer+(size_t)(Buffer_Offset+Element_Size); while (Element_Offset::iterator Item=ListList.begin(); Item!=ListList.end(); ++Item) Fill(Stream_General, 0, Item->first.To_UTF8().c_str(), Item->second); } //--------------------------------------------------------------------------- void File_Caf::kuki() { //Parsing Skip_XX(Element_Size, "Data"); } //--------------------------------------------------------------------------- void File_Caf::pakt() { //Parsing int64u NumberPackets, NumberValidFrames; int32u PrimingFrames, RemainderFrames; Get_B8 (NumberPackets, "NumberPackets"); Get_B8 (NumberValidFrames, "NumberValidFrames"); Get_B4 (PrimingFrames, "PrimingFrames"); Get_B4 (RemainderFrames, "RemainderFrames"); Skip_XX(Element_Size-Element_Offset, "Packet sizes"); FILLING_BEGIN(); float64 SampleRate=Retrieve(Stream_Audio, 0, Audio_SamplingRate).To_float64(); Fill(Stream_Audio, 0, Audio_FrameCount, NumberPackets); Fill(Stream_Audio, 0, Audio_Duration, NumberValidFrames/SampleRate*1000, 0); if (PrimingFrames && RemainderFrames) Fill(Stream_Audio, 0, Audio_Source_Duration, (PrimingFrames+NumberValidFrames+RemainderFrames)/SampleRate*1000, 0); Fill(Stream_Audio, 0, Audio_Delay, PrimingFrames/SampleRate*1000, 0); FILLING_END(); } //--------------------------------------------------------------------------- void File_Caf::uuid() { //Parsing Skip_UUID( "UUID"); Skip_XX(Element_Size-Element_Offset, "Data"); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_CAF_YES MediaInfoLib/Source/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.h0000664000000000000000000003536612652076434023243 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_Tak.h0000664000000000000000000000375512652076434020046 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Tak files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_TakH #define MediaInfo_File_TakH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_SmpteSt0331.cpp0000664000000000000000000002062012652076434021556 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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_SMPTEST0331_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_SmpteSt0331.h" #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* Smpte_St0331_ChannelsPositions(int8u number_channels) { switch (number_channels) { case 2 : return "Front: L R"; //2 channels case 4 : return "Front: L C R, LFE"; //4 channels case 6 : return "Front: L C R, Side: L R, LFE"; //6 channels case 8 : return "Front: L C R, Side: L R, Back: L R, LFE"; //8 channels default : return ""; } } //--------------------------------------------------------------------------- const char* Smpte_St0331_ChannelsPositions2(int8u number_channels) { switch (number_channels) { case 2 : return "2/0/0.0"; //2 channels case 4 : return "3/0/0.1"; //4 channels case 6 : return "3/2/0.1"; //6 channels case 8 : return "3/2/2.1"; //8 channels default : return ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_SmpteSt0331::File_SmpteSt0331() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Aes3; #endif //MEDIAINFO_EVENTS PTS_DTS_Needed=true; IsRawStream=true; //In QuantizationBits=0; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_SmpteSt0331::Streams_Fill() { int8u Channels_Count=0; for (int8u Pos=0; Pos<8; Pos++) if (Channels_valid&(1<>4) | ((Buffer[Buffer_Pos+2]<<4)&0xF0 ); Info[Info_Offset+1] = (Buffer[Buffer_Pos+2]>>4) | ((Buffer[Buffer_Pos+3]<<4)&0xF0 ); } else { 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+=QuantizationBits==16?2:3; } Element_Offset+=4; } } Element_Offset=4; #if MEDIAINFO_DEMUX OriginalBuffer_Size=(size_t)Element_Size; OriginalBuffer=(int8u*)(Buffer+Buffer_Offset); FrameInfo.PTS=FrameInfo.DTS; FrameInfo.DUR=(Element_Size-4)*1000000000/48000/32; // 48 kHz, 4 bytes per sample Demux_random_access=true; Element_Code=(int64u)-1; Element_Offset=0; Demux(Info, Info_Offset, ContentType_MainStream); Element_Offset=4; OriginalBuffer_Size=0; OriginalBuffer=NULL; #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 FILLING_BEGIN(); if (!Status[IsAccepted]) { Accept("SMPTE ST 331"); int8u Channels=0; for (int8u Pos=0; Pos<8; Pos++) { if (Channels_valid&(1<8) { Endianness='L'; Sign='S';} else { Sign='U';} } } else if (Codec==__T("2")) {Firm=__T("Microsoft");} else if (Codec==__T("3")) { Endianness='F';} 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");} //Format Fill(Stream_Audio, 0, Audio_Codec_String, "PCM"); Fill(Stream_Audio, 0, Audio_Codec_Family, "PCM"); Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR"); //SamplingRate if (SamplingRate) Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate); //Firm 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); //Endianess const char* Value; switch (Endianness) { case 'B': Value="Big"; break; case 'L': Value="Little"; break; default : Value=""; } Fill(Stream_Audio, 0, Audio_Format_Settings, Value); Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, Value); Fill(Stream_Audio, 0, Audio_Codec_Settings, Value); Fill(Stream_Audio, 0, Audio_Codec_Settings_Endianness, Value); //Sign switch (Sign) { case 'S': Value="Signed"; break; case 'U': Value="Unsigned"; break; default : Value=""; } Fill(Stream_Audio, 0, Audio_Format_Settings, Value); Fill(Stream_Audio, 0, Audio_Format_Settings_Sign, Value); Fill(Stream_Audio, 0, Audio_Codec_Settings, Value); Fill(Stream_Audio, 0, Audio_Codec_Settings_Sign, Value); //ITU 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); //BitDepth if (BitDepth_Significant) { Fill(Stream_Audio, 0, Audio_BitDepth, BitDepth_Significant); Fill(Stream_Audio, 0, Audio_BitDepth_Stored, BitDepth); } else if (BitDepth) Fill(Stream_Audio, 0, Audio_BitDepth, BitDepth); //Channels if (Channels) Fill(Stream_Audio, 0, Audio_Channel_s_, Channels); //Bit rate if (SamplingRate && BitDepth && Channels) Fill(Stream_Audio, 0, Audio_BitRate, SamplingRate*BitDepth*Channels); //ChannelsPositions if (Codec==__T("SMPTE ST 337")) { Fill(Stream_Audio, 0, Audio_ChannelPositions, Smpte_St0302_ChannelsPositions(Channels)); Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Smpte_St0302_ChannelsPositions2(Channels)); } } //--------------------------------------------------------------------------- void File_Pcm::Streams_Finish() { //No frames in PCM! Frame_Count=(int64u)-1; Frame_Count_NotParsedIncluded=(int64u)-1; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Pcm::Read_Buffer_Continue() { //Testing if we get enough data if (SamplingRate && BitDepth && Channels) { int64u BitRate=SamplingRate*BitDepth*Channels; int64u ByteRate=BitRate/8; if (Buffer_Size>=ByteRate/4) // 1/4 of second is enough for detection Frame_Count_Valid=2; } #if MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer && !Status[IsAccepted]) { Frame_Count_Valid_Demux++; if (Frame_Count_Valid_Demux=Frame_Count_Valid_Demux) Frame_Count_NotParsedIncluded-=Frame_Count_Valid_Demux-1; } Demux_random_access=true; Element_Code=(int64u)-1; if (BitDepth==20 && Endianness=='L' && Config->Demux_PCM_20bitTo16bit_Get()) { size_t Info_Offset=(size_t)Element_Size; const int8u* Info=Buffer+Buffer_Offset; size_t Info2_Size=Info_Offset*4/5; int8u* Info2=new int8u[Info2_Size]; size_t Info2_Pos=0; size_t Info_Pos=0; //Removing bits 3-0 (Little endian) // Dest : 20LE / L1L0 L3L2 R0L4 R2R1 R4R3 // Source: L2L1 L4L3 R2R1 R4R2 while (Info_Pos+5<=Info_Offset) { Info2[Info2_Pos ] =(Info[Info_Pos+1]<<4 ) | (Info[Info_Pos+0]>>4 ); Info2[Info2_Pos+1] =(Info[Info_Pos+2]<<4 ) | (Info[Info_Pos+1]>>4 ); Info2[Info2_Pos+2] = Info[Info_Pos+3] ; Info2[Info2_Pos+3] = Info[Info_Pos+4] ; Info2_Pos+=4; Info_Pos+=5; } Demux(Info2, Info2_Pos, ContentType_MainStream); delete[] Info2; } else if (BitDepth==20 && Endianness=='L' && Config->Demux_PCM_20bitTo24bit_Get()) { size_t Info_Offset=(size_t)Element_Size; const int8u* Info=Buffer+Buffer_Offset; size_t Info2_Size=Info_Offset*6/5; int8u* Info2=new int8u[Info2_Size]; size_t Info2_Pos=0; size_t Info_Pos=0; //Padding bits 3-0 (Little endian) // Dest : 20LE / L1L0 L3L2 R0L4 R2R1 R4R3 // Source: L0XX L2L1 L4L3 R0XX R2R1 R4R2 while (Info_Pos+5<=Info_Offset) { Info2[Info2_Pos ] = Info[Info_Pos+0]<<4 ; Info2[Info2_Pos+1] =(Info[Info_Pos+1]<<4 ) | (Info[Info_Pos+0]>>4 ); Info2[Info2_Pos+2] =(Info[Info_Pos+2]<<4 ) | (Info[Info_Pos+1]>>4 ); Info2[Info2_Pos+3] = Info[Info_Pos+2]&0xF0 ; Info2[Info2_Pos+4] = Info[Info_Pos+3] ; Info2[Info2_Pos+5] = Info[Info_Pos+4] ; Info2_Pos+=6; Info_Pos+=5; } Demux(Info2, Info2_Pos, ContentType_MainStream); delete[] Info2; } else { Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream); } #endif //MEDIAINFO_DEMUX //Parsing Skip_XX(Element_Size, "Data"); //It is impossible to detect... Default is no detection, only filling #if MEDIAINFO_DEMUX if (Frame_Count_Valid_Demux) { Frame_Count+=Frame_Count_Valid_Demux-1; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded+=Frame_Count_Valid_Demux-1; FrameInfo.DUR/=Frame_Count_Valid_Demux; if (FrameInfo.DTS!=(int64u)-1) FrameInfo.DTS+=FrameInfo.DUR*Frame_Count; Frame_Count_Valid_Demux=0; } #endif //MEDIAINFO_DEMUX Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1) { if (BitDepth && Channels && SamplingRate) FrameInfo.DTS+=Element_Size*1000000000*8/BitDepth/Channels/SamplingRate; else FrameInfo.DTS+=FrameInfo.DUR; FrameInfo.PTS=FrameInfo.DTS; } if ((!Status[IsAccepted] && Frame_Count>=Frame_Count_Valid) || File_Offset+Buffer_Size>=File_Size) { Accept(); Fill(); } } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_PCM_YES MediaInfoLib/Source/MediaInfo/Audio/File_Dts.h0000664000000000000000000000744212652076434020056 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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(); private : //Streams management void Streams_Fill(); void Streams_Finish(); //Buffer - File header bool FileHeader_Begin(); //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 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); //Buffer bool FrameSynchPoint_Test(); const int8u* Save_Buffer; size_t Save_Buffer_Offset; size_t Save_Buffer_Size; //Temp std::vector Asset_Sizes; Ztring Profile; int32u Original_Size; int32u HD_size; int16u Primary_Frame_Byte_Size; int16u Number_Of_PCM_Sample_Blocks; 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; enum presence { presence_Core_Core, presence_Core_XXCh, presence_Core_X96, presence_Core_XCh, presence_Extended_Core, presence_Extended_XBR, presence_Extended_XXCh, presence_Extended_X96, presence_Extended_LBR, presence_Extended_XLL, presence_Extended_XLL_X, presence_Max }; std::bitset Presence; enum data { Profiles, Channels, ChannelPositions, ChannelPositions2, ChannelLayout, BitDepth, SamplingRate, BitRate, BitRate_Mode, Compression_Mode, data_Max, }; ZtringList Data[data_Max]; int8u Core_Core_AMODE; int8u Core_Core_LFF; int8u Core_XCh_AMODE; int8u Core_XXCh_nuNumChSetsInXXCh; size_t Extension_XLL_X_No; size_t Extension_XLL_X_Yes; //Helpers float64 BitRate_Get(bool WithHD=false); void Streams_Fill_Extension(); void Streams_Fill_Core_ES(); void Streams_Fill_Core(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_OpenMG.h0000664000000000000000000000302212652076434020437 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about OpenMG (OMA) files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_OpenMGH #define MediaInfo_File_OpenMGH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Tag/File__Tags.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_OpenMG //*************************************************************************** class File_OpenMG : public File__Analyze, public File__Tags_Helper { public : //Constructor/Destructor File_OpenMG(); private : //Streams management void Streams_Fill(); void Streams_Finish() {File__Tags_Helper::Streams_Finish();} //Buffer - File header bool FileHeader_Begin(); void FileHeader_Parse(); //Buffer - Global void Read_Buffer_Continue(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.cpp0000664000000000000000000000721512652076434024230 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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)?(Frequency_b*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 MediaInfoLib/Source/MediaInfo/Audio/File_Aac.h0000664000000000000000000003153112652076434020004 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about AAC files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_AacH #define MediaInfo_File_AacH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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(int64s 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_Accept(); void Streams_Fill(); void Streams_Update(); 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; int8u extension_sampling_frequency_index; int32u extension_sampling_frequency; bool aacScalefactorDataResilienceFlag; bool aacSectionDataResilienceFlag; bool aacSpectralDataResilienceFlag; int8u num_raw_data_blocks; bool protection_absent; int64u FrameSize_Min; int64u FrameSize_Max; bool adts_buffer_fullness_Is7FF; #if MEDIAINFO_ADVANCED int64u aac_frame_length_Total; #endif //MEDIAINFO_ADVANCED //*********************************************************************** // 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 Infos_General; std::map Infos; bool CanFill; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Celt.cpp0000664000000000000000000001242412652076434020542 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // // 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 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; Pos2) 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; icodebook_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; iBuffer_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 Parsers; void Parsers_Init(); void Parsers_Parse(const int8u* Parser_Buffer, size_t Parser_Buffer_Size); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_SmpteSt0331.h0000664000000000000000000000263112652076434021225 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about SMPTE ST 331 streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_SmpteSt0331H #define MediaInfo_File_SmpteSt0331H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_SmpteSt0331 //*************************************************************************** class File_SmpteSt0331 : public File__Analyze { public : //In int32u QuantizationBits; //Constructor/Destructor File_SmpteSt0331(); private : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue (); //Temp int8u Channels_valid; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_ImpulseTracker.h0000664000000000000000000000242312652076434022250 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_La.cpp0000664000000000000000000001345412652076434020213 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // 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=((int64u)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 MediaInfoLib/Source/MediaInfo/Audio/File_ExtendedModule.h0000664000000000000000000000242312652076434022224 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Caf.h0000664000000000000000000000267212652076434020015 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Core Audio Format files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_CafH #define MediaInfo_File_CafH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Au //*************************************************************************** class File_Caf : public File__Analyze { public : File_Caf(); protected : //Buffer - File header bool FileHeader_Begin(); void FileHeader_Parse (); //Buffer void Header_Parse(); void Data_Parse(); //Elements void data(); void desc(); void free(); void info(); void kuki(); void pakt(); void uuid(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_ScreamTracker3.cpp0000664000000000000000000001420412652076434022462 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Adpcm.h0000664000000000000000000000233212652076434020341 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_La.h0000664000000000000000000000312612652076434017653 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_LaH #define MediaInfo_File_LaH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_ChannelGrouping.h0000664000000000000000000000737612652076434022415 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_ChannelGrouping //*************************************************************************** class File_ChannelGrouping : public File__Analyze { public : //In int8u BitDepth; int16u SamplingRate; int8u Endianness; bool Aligned; bool CanBePcm; struct common { struct channel { int8u* Buffer; size_t Buffer_Offset; size_t Buffer_Size; size_t Buffer_Size_Max; std::vector Offsets_Stream; std::vector Offsets_Buffer; 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 Channels; channel MergedChannel; size_t Channel_Current; std::vector Parsers; size_t Instances; size_t Instances_Max; common() { Channel_Current=0; Instances=0; Instances_Max=0; } ~common() { for (size_t Pos=0; Pos2) break; // Not in spec // else it is as Vorbis specs, no break case 1 : // Vorbis order { Ztring ChannelPositions; ChannelPositions.From_Local(Opus_ChannelPositions[ch_count]); Ztring ChannelPositions2; ChannelPositions2.From_Local(Opus_ChannelPositions2[ch_count]); 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); } default: ; //Unknown } FILLING_END(); //Filling Identification_Done=true; } //--------------------------------------------------------------------------- void File_Opus::Stream() { Element_Name("Stream"); Skip_XX(Element_Size, "Data"); Finish("Opus"); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_OPUS_YES MediaInfoLib/Source/MediaInfo/Audio/File_Amv.h0000664000000000000000000000224512652076434020043 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Pcm_Vob.cpp0000664000000000000000000002206612652076434021203 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PCMVOB_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Audio/File_Pcm_Vob.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 ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Pcm_Vob::File_Pcm_Vob() { //Configuration ParserName=__T("PCM VOB"); IsRawStream=true; PTS_DTS_Needed=true; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Pcm_Vob::Streams_Fill() { Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "PCM"); Fill(Stream_Audio, 0, Audio_Codec, "PCM"); Fill(Stream_Audio, 0, Audio_Codec_Family, "PCM"); Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR"); 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); //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 Fill(Stream_Audio, 0, Audio_Format_Settings, "Big"); Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Big"); Fill(Stream_Audio, 0, Audio_Codec_Settings, "Big"); Fill(Stream_Audio, 0, Audio_Codec_Settings_Endianness, "Big"); Fill(Stream_Audio, 0, Audio_Format_Settings, "Signed"); Fill(Stream_Audio, 0, Audio_Format_Settings_Sign, "Signed"); Fill(Stream_Audio, 0, Audio_Codec_Settings, "Signed"); Fill(Stream_Audio, 0, Audio_Codec_Settings_Sign, "Signed"); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Pcm_Vob::Read_Buffer_Continue() { if (Buffer_Size==0) return; //Parsing 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; } 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 (!Status[IsAccepted]) { Accept(); Finish(); } FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_PCMVOB_YES MediaInfoLib/Source/MediaInfo/Audio/File_Celt.h0000664000000000000000000000257512652076434020215 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about CELT files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #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 bool Identification_Done; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Pcm_Vob.h0000664000000000000000000000262112652076434020643 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PCM (from DVD) files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_Pcm_VobH #define MediaInfo_File_Pcm_VobH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Pcm_Vob //*************************************************************************** class File_Pcm_Vob : public File__Analyze { public : //Constructor/Destructor File_Pcm_Vob(); private : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue (); //Temp int8u BitDepth; int8u Frequency; int8u NumberOfChannelsMinusOne; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_TwinVQ.cpp0000664000000000000000000001540712652076434021047 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Ac3.h0000664000000000000000000001012512652076434017722 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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 Core_Frame(); 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), compr(0), dynrng(0), compre(false), dynrnge(false) { } }; dolby FirstFrame_Dolby; dolby FirstFrame_Dolby2; std::vector dialnorms; std::vector dialnorm2s; std::vector comprs; std::vector compr2s; std::vector dynrngs; std::vector dynrng2s; std::map fscods; std::map frmsizecods; int64u Frame_Count_HD; int16u chanmap_Max[8][9]; int16u frmsizplus1_Max[8][9]; int16u HD_BitRate_Max; int16u HD_Channels2; int8u fscod; int8u fscod2; int8u frmsizecod; int8u bsid; int8u bsid_Max; int8u bsmod_Max[8][9]; int8u acmod_Max[8][9]; int8u dsurmod_Max[8][9]; 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; int8u substreamid_Independant_Current; int8u substreams_Count; bool lfeon_Max[8][9]; bool dxc3_Parsed; bool HD_MajorSync_Parsed; bool HD_NoRestart; bool HD_ExtraParity; bool HD_IsVBR; bool HD_HasAtmos; bool Core_IsPresent; bool HD_IsPresent; bool dynrnge_Exists; bool chanmape_Max[8][9]; bool TimeStamp_IsPresent; bool TimeStamp_IsParsing; bool TimeStamp_Parsed; bool TimeStamp_DropFrame_IsValid; bool TimeStamp_DropFrame_Content; bool BigEndian; bool IgnoreCrc_Done; bool IgnoreCrc; float64 TimeStamp_Content; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Mpega.cpp0000664000000000000000000020530312652076434020704 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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" #if MEDIAINFO_ADVANCED #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #endif //MEDIAINFO_ADVANCED 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; Frame_Count_NotParsedIncluded=0; //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") && ID<4 && sampling_frequency<4) { 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") && ID<4 && layer<4 && sampling_frequency<4 && bitrate_index<16 && 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) { //Padding while (Buffer_Offset+Size0+4<=Buffer_Size && Buffer[Buffer_Offset+Size0]==0x00) Size0++; 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>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) { //Padding while (Buffer_Offset+Size0+Size1+4<=Buffer_Size && Buffer[Buffer_Offset+Size0+Size1]==0x00) Size0++; 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) { //Padding while (Buffer_Offset+Size0+Size1+Size2+4<=Buffer_Size && Buffer[Buffer_Offset+Size0+Size1+Size2]==0x00) Size0++; if (Buffer_Offset+Size0+Size1+Size2+4>Buffer_Size) { if (IsSub || File_Offset+Buffer_Offset+Size0+Size1+Size2Buffer_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 return true; } //--------------------------------------------------------------------------- bool File_Mpega::Synched_Test() { //Tags if (!File__Tags_Helper::Synched_Test()) return false; //Padding while (Buffer_OffsetBuffer_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; if (Mpega_SamplingRate[ID][sampling_frequency]==0 || Mpega_Coefficient[ID][layer]==0 || Mpega_BitRate[ID][layer][bitrate_index]==0 || Mpega_SlotSize[layer]==0) return true; //Synhro issue #if MEDIAINFO_ADVANCED if (Frame_Count && File_Demux_Unpacketize_StreamLayoutChange_Skip) { int8u mode0 =CC1(Buffer+Buffer_Offset+3)>>6; if (sampling_frequency0!=sampling_frequency_Frame0 || Mpega_Channels[mode0]!=Mpega_Channels[mode_Frame0]) { return true; } } #endif //MEDIAINFO_ADVANCED 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 = ((int64u)Mpega_Coefficient[ID][layer] * (int64u)Mpega_BitRate[ID][layer][bitrate_index] * 1000 / (int64u)Mpega_SamplingRate[ID][sampling_frequency] + (padding_bit ? 1 : 0)) * (int64u)Mpega_SlotSize[layer]; //Special case: tags is inside the last frame if (File_Offset+Buffer_Offset+Size>=File_Size-File_EndTagSize) Size=File_Size-File_EndTagSize-(File_Offset+Buffer_Offset); Header_Fill_Size(Size); Header_Fill_Code(0, "frame"); //Filling error detection sampling_frequency_Count[sampling_frequency]++; mode_Count[mode]++; FILLING_BEGIN(); #if MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED if (!Frame_Count) { File_Demux_Unpacketize_StreamLayoutChange_Skip=Config->File_Demux_Unpacketize_StreamLayoutChange_Skip_Get(); if (File_Demux_Unpacketize_StreamLayoutChange_Skip) { sampling_frequency_Frame0=sampling_frequency; mode_Frame0=mode; } } #endif //MEDIAINFO_ADVANCED #endif //MEDIAINFO_DEMUX 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] * (int64u)Mpega_BitRate[ID][layer][bitrate_index] * 1000 / (int64u)Mpega_SamplingRate[ID][sampling_frequency] + (padding_bit ? 1 : 0)) * (int64u)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 && Frame_Count_NotParsedIncluded==0) PTS_Begin=FrameInfo.PTS; 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; Frequency_b=Mpega_SamplingRate[ID][sampling_frequency]; TS_Add(Samples); } //LAME if (Encoded_Library.empty() && (Frame_Count>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>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_Offset1 && !Encoded_Library.empty()) Frame_Count_Valid=Frame_Count; if (!Status[IsAccepted]) File__Analyze::Accept("MPEG Audio"); if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid) { Fill("MPEG Audio"); //Jumping if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1.0 && File_Offset+Buffer_OffsetFile_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::audio_data_Layer3() { int16u main_data_end; 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=4) return; for(int8u ch=0; chElement_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=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=__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 MediaInfoLib/Source/MediaInfo/Audio/File_DolbyE.cpp0000664000000000000000000011026212652076434021030 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Important note about Dolby E parser: // Open-Source version of MediaInfo has basic support of Dolby E, // created by reverse engineering by an anonymous third-party, // with the limitions due to reverse engineering: there is a risk // of wrong interpretation of the reverse engineeried bitstream. // If you want a safer Dolby E support, based on Dolby E specifications, // contact http://www.dolby.com/about/contact_us/contactus.aspx?goto=28 // for a license before asking it in a specific (and not Open-Source) version // of 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 //*************************************************************************** //--------------------------------------------------------------------------- const int8u DolbyE_Programs[64]= {2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 1, 2, 3, 3, 4, 5, 6, 1, 2, 3, 4, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0}; //--------------------------------------------------------------------------- const int8u DolbyE_Channels[64]= {8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8, 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, 0, 0, 0, 0, 0, 0, 0, 0}; //--------------------------------------------------------------------------- const int8u DolbyE_Channels_PerProgram(int8u program_config, int8u program) { switch (program_config) { case 0 : switch (program) { case 0 : return 6; default : return 2; } case 1 : switch (program) { case 0 : return 6; default : return 1; } case 2 : case 18 : return 4; case 3 : case 12 : switch (program) { case 0 : return 4; default : return 2; } case 4 : switch (program) { case 0 : return 4; case 1 : return 2; default : return 1; } case 5 : case 13 : switch (program) { case 0 : return 4; default : return 1; } case 6 : case 14 : case 19 : return 2; case 7 : switch (program) { case 0 : case 1 : case 2 : return 2; default : return 1; } case 8 : case 15 : switch (program) { case 0 : case 1 : return 2; default : return 1; } case 9 : case 16 : case 20 : switch (program) { case 0 : return 2; default : return 1; } case 10 : case 17 : case 21 : return 1; case 11 : return 6; case 22 : return 8; case 23 : return 8; default : return 0; } }; //--------------------------------------------------------------------------- const char* DolbyE_ChannelPositions[64]= { "Front: L C R, Side: L R, LFE / Front: L R", "Front: L C R, Side: L R, LFE / Front: C / Front: C", "Front: L C R, LFE / Front: L C R, LFE", "Front: L C R, LFE / Front: L R / Front: L R", "Front: L C R, LFE / Front: L R / Front: C / Front: C", "Front: L C R, LFE / Front: C / Front: C / Front: C / Front: C", "Front: L R / Front: L R / Front: L R / Front: L R", "Front: L R / Front: L R / Front: L R / Front: C / Front: C", "Front: L R / Front: L R / Front: C / Front: C / Front: C / Front: C", "Front: L R / Front: C / Front: C / Front: C / Front: C / Front: C / Front: C", "Front: C / Front: C / Front: C / Front: C / Front: C / Front: C / Front: C / Front: C", "Front: L C R, Side: L R, LFE", "Front: L C R, LFE / Front: L R", "Front: L C R, LFE / Front: C / Front: C", "Front: L R / Front: L R / Front: L R", "Front: L R / Front: L R / Front: C / Front: C", "Front: L R / Front: C / Front: C / Front: C / Front: C", "Front: C / Front: C / Front: C / Front: C / Front: C / Front: C", "Front: L C R, LFE", "Front: L R / Front: L R", "Front: L R / Front: C / Front: C", "Front: C / Front: C / Front: C / Front: C", "Front: L C R, Side: L R, Rear: L R, LFE", "Front: L C C C R, Side: L R, LFE", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; //--------------------------------------------------------------------------- const char* DolbyE_ChannelPositions_PerProgram(int8u program_config, int8u program) { switch (program_config) { case 0 : switch (program) { case 0 : return "Front: L C R, Side: L R, LFE"; default : return "Front: L R"; } case 1 : switch (program) { case 0 : return "Front: L C R, Side: L R, LFE"; default : return "Front: C"; } case 2 : case 18 : return "Front: L C R, LFE"; case 3 : case 12 : switch (program) { case 0 : return "Front: L C R, LFE"; default : return "Front: L R"; } case 4 : switch (program) { case 0 : return "Front: L C R, LFE"; case 1 : return "Front: L R"; default : return "Front: C"; } case 5 : case 13 : switch (program) { case 0 : return "Front: L C R, LFE"; default : return "Front: C"; } case 6 : case 14 : case 19 : return "Front: L R"; case 7 : switch (program) { case 0 : case 1 : case 2 : return "Front: L R"; default : return "Front: C"; } case 8 : case 15 : switch (program) { case 0 : case 1 : return "Front: L R"; default : return "Front: C"; } case 9 : case 16 : case 20 : switch (program) { case 0 : return "Front: L R"; default : return "Front: C"; } case 10 : case 17 : case 21 : return "Front: C"; case 11 : return "Front: L C R, Side: L R, LFE"; case 22 : return "Front: L C R, Side: L R, Rear: L R, LFE"; case 23 : return "Front: L C C C R, Side: L R, LFE"; default : return ""; } }; //--------------------------------------------------------------------------- const char* DolbyE_ChannelPositions2[64]= { "3/2/0.1 / 2/0/0", "3/2/0.1 / 1/0/0 / 1/0/0", "3/0/0.1 / 3/0/0.1", "3/0/0.1 / 2/0/0 / 2/0/0", "3/0/0.1 / 2/0/0 / 1/0/0 / 1/0/0", "3/0/0.1 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "2/0/0 / 2/0/0 / 2/0/0 / 2/0/0", "2/0/0 / 2/0/0 / 2/0/0 / 1/0/0 / 1/0/0", "2/0/0 / 2/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "2/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "3/2/0.1", "3/0/0.1 / 2/0/0", "3/0/0.1 / 1/0/0 / 1/0/0", "2/0/0 / 2/0/0 / 2/0/0", "2/0/0 / 2/0/0 / 1/0/0 / 1/0/0", "2/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "3/0/0.1", "2/0/0 / 2/0/0", "2/0/0 / 1/0/0 / 1/0/0", "1/0/0 / 1/0/0 / 1/0/0 / 1/0/0", "3/2/2.1", "5/2/0.1", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; //--------------------------------------------------------------------------- const char* DolbyE_ChannelPositions2_PerProgram(int8u program_config, int8u program) { switch (program_config) { case 0 : switch (program) { case 0 : return "3/2/0.1"; default : return "2/0/0"; } case 1 : switch (program) { case 0 : return "3/2/0.1"; default : return "1/0/0"; } case 2 : case 18 : return "3/0/0.1"; case 3 : case 12 : switch (program) { case 0 : return "3/0/0.1"; default : return "2/0/0"; } case 4 : switch (program) { case 0 : return "3/0/0.1"; case 1 : return "2/0/0"; default : return "1/0/0"; } case 5 : case 13 : switch (program) { case 0 : return "3/0/0.1"; default : return "1/0/0"; } case 6 : case 14 : case 19 : return "Front: L R"; case 7 : switch (program) { case 0 : case 1 : case 2 : return "2/0/0"; default : return "1/0/0"; } case 8 : case 15 : switch (program) { case 0 : case 1 : return "2/0/0"; default : return "1/0/0"; } case 9 : case 16 : case 20 : switch (program) { case 0 : return "2/0/0"; default : return "1/0/0"; } case 10 : case 17 : case 21 : return "1/0/0"; case 11 : return "3/2/0.1"; case 22 : return "3/2/2.1"; case 23 : return "5/2/0.1"; default : return ""; } }; extern const char* AC3_Surround[]; //--------------------------------------------------------------------------- const char* DolbyE_ChannelLayout_PerProgram(int8u ProgramConfiguration, int8u ProgramNumber) { switch (ProgramConfiguration) { case 0 : switch (ProgramNumber) { case 0 : return "L C Ls X R LFE Rs X"; default : return "X X X L X X X R"; } case 1 : switch (ProgramNumber) { case 0 : return "L C Ls X R LFE Rs X"; case 1 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 2 : switch (ProgramNumber) { case 0 : return "L C X X R S X X"; default : return "X X L C X X R S"; } case 3 : switch (ProgramNumber) { case 0 : return "L C X X R S X X"; case 1 : return "X X L X X X R X"; default : return "X X X L X X X R"; } case 4 : switch (ProgramNumber) { case 0 : return "L C X X R S X X"; case 1 : return "X X L X X X R X"; case 2 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 5 : switch (ProgramNumber) { case 0 : return "L C X X R S X X"; case 1 : return "X X C X X X X X"; case 2 : return "X X X X X X C X"; case 3 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 6 : switch (ProgramNumber) { case 0 : return "L X X X R X X X"; case 1 : return "X L X X X R X X"; case 2 : return "X X L X X X R X"; default : return "X X X L X X X R"; } case 7 : switch (ProgramNumber) { case 0 : return "L X X X R X X X"; case 1 : return "X L X X X R X X"; case 2 : return "X X L X X X R X"; case 3 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 8 : switch (ProgramNumber) { case 0 : return "L X X X R X X X"; case 1 : return "X L X X X R X X"; case 2 : return "X X C X X X X X"; case 3 : return "X X X X X X C X"; case 4 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 9 : switch (ProgramNumber) { case 0 : return "L X X X R X X X"; case 1 : return "X C X X X X X X"; case 2 : return "X X X X X C X X"; case 3 : return "X X C X X X X X"; case 4 : return "X X X X X X C X"; case 5 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 10 : switch (ProgramNumber) { case 0 : return "C X X X X X X X"; case 1 : return "X X X X C X X X"; case 2 : return "X C X X X X X X"; case 3 : return "X X X X X C X X"; case 4 : return "X X C X X X X X"; case 5 : return "X X X X X X C X"; case 6 : return "X X X C X X X X"; default : return "X X X X X X X C"; } case 11 : return "L C Ls R LFE Rs"; case 12 : switch (ProgramNumber) { case 0 : return "L C X R S X"; default : return "X X L X X R"; } case 13 : switch (ProgramNumber) { case 0 : return "L C X R S X"; case 1 : return "X X C X X X"; default : return "X X X X X C"; } case 14 : switch (ProgramNumber) { case 0 : return "L X X R X X"; case 1 : return "X L X X R X"; default : return "X X L X X R"; } case 15 : switch (ProgramNumber) { case 0 : return "L X X R X X"; case 1 : return "X L X R X"; case 2 : return "X X C X X X"; default : return "X X X X X C"; } case 16 : switch (ProgramNumber) { case 0 : return "L X X R X X"; case 1 : return "X C X X X X"; case 2 : return "X X X X C X"; case 3 : return "X X C X X X"; default : return "X X X X X C"; } case 17 : switch (ProgramNumber) { case 0 : return "C X X X X X"; case 1 : return "X X X C X X"; case 2 : return "X C X X X X"; case 3 : return "X X X X C X"; case 4 : return "X X C X X X"; default : return "X X X X X C"; } case 18 : return "L C R S"; case 19 : switch (ProgramNumber) { case 0 : return "L X R X"; default : return "X L X R"; } case 20 : switch (ProgramNumber) { case 0 : return "L X R X"; case 1 : return "X C X X"; default : return "X X X C"; } case 21 : switch (ProgramNumber) { case 0 : return "C X X X"; case 1 : return "X X C X"; case 2 : return "X C X X"; default : return "X X X C"; } case 22 : return "L C Ls Lrs R LFE Rs Rrs"; case 23 : return "L C Ls Lc R LFE Rs Rc"; default : return ""; } }; extern const float64 Mpegv_frame_rate[16]; const bool Mpegv_frame_rate_type[16]= {false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false}; //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_DolbyE::File_DolbyE() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_DolbyE; #endif //MEDIAINFO_EVENTS //Configuration MustSynchronize=true; Buffer_TotalBytes_FirstSynched_Max=32*1024; //In GuardBand_Before=0; GuardBand_After=0; //Temp SMPTE_time_code_StartTimecode=(int64u)-1; FrameInfo.DTS=0; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_DolbyE::Streams_Fill() { Fill(Stream_General, 0, General_Format, "Dolby E"); for (int8u program=0; program1) Fill(Stream_Audio, StreamPos_Last, Audio_ID, Count_Get(Stream_Audio)); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, DolbyE_Channels_PerProgram(ProgramConfiguration, program)); Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, DolbyE_ChannelPositions_PerProgram(ProgramConfiguration, program)); Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions_String2, DolbyE_ChannelPositions2_PerProgram(ProgramConfiguration, program)); Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, DolbyE_ChannelLayout_PerProgram(ProgramConfiguration, program)); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 48000); Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, BitDepth); if (SMPTE_time_code_StartTimecode!=(int64u)-1) { Fill(StreamKind_Last, StreamPos_Last, Audio_Delay, SMPTE_time_code_StartTimecode); Fill(StreamKind_Last, StreamPos_Last, Audio_Delay_Source, "Stream"); } Fill(Stream_Audio, StreamPos_Last, Audio_FrameRate, Mpegv_frame_rate[FrameRate]); if (FrameInfo.PTS!=(int64u)-1 && BitDepth) { float BitRate=(float)(96000*BitDepth); if (GuardBand_Before_Initial) { float GuardBand_Before_Initial_Duration=GuardBand_Before_Initial*8/BitRate; Fill(Stream_Audio, StreamPos_Last, "GuardBand_Before", GuardBand_Before_Initial_Duration, 9); Fill(Stream_Audio, StreamPos_Last, "GuardBand_Before/String", Ztring::ToZtring(GuardBand_Before_Initial_Duration*1000000, 0)+Ztring().From_UTF8(" \xC2xB5s")); //0xC2 0xB5 = micro sign (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("GuardBand_Before"), Info_Options)=__T("N NT"); (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("GuardBand_Before/String"), Info_Options)=__T("N NT"); } if (GuardBand_Before_Initial) { float GuardBand_After_Initial_Duration=GuardBand_After_Initial*8/BitRate; Fill(Stream_Audio, StreamPos_Last, "GuardBand_After", GuardBand_After_Initial_Duration, 9); Fill(Stream_Audio, StreamPos_Last, "GuardBand_After/String", Ztring::ToZtring(GuardBand_After_Initial_Duration*1000000, 0)+Ztring().From_UTF8(" \xC2xB5s")); //0xC2 0xB5 = micro sign (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("GuardBand_After"), Info_Options)=__T("N NT"); (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("GuardBand_After/String"), Info_Options)=__T("N NT"); } } } Fill(Stream_General, 0, General_OverallBitRate, Element_Size*8*Mpegv_frame_rate[FrameRate], 0); } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_DolbyE::Synchronize() { //Synchronizing while (Buffer_Offset+32<=Buffer_Size) { if ((CC2(Buffer+Buffer_Offset_Temp)&0xFFFE)==0x078E) //16-bit { BitDepth=16; ScrambledBitStream=(CC2(Buffer+Buffer_Offset)&0x0001)?true:false; break; //while() } if ((CC3(Buffer+Buffer_Offset)&0xFFFFE0)==0x0788E0) //20-bit { BitDepth=20; ScrambledBitStream=(CC3(Buffer+Buffer_Offset)&0x000010)?true:false; break; //while() } if ((CC3(Buffer+Buffer_Offset)&0xFFFFFE)==0x07888E) //24-bit { BitDepth=24; ScrambledBitStream=(CC3(Buffer+Buffer_Offset)&0x000001)?true:false; break; //while() } Buffer_Offset++; } //Parsing last bytes if needed if (Buffer_Offset+8>Buffer_Size) return false; //Synched return true; } //--------------------------------------------------------------------------- bool File_DolbyE::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+32>Buffer_Size) return false; //Quick test of synchro switch (BitDepth) { case 16 : if ((CC2(Buffer+Buffer_Offset)&0xFFFE )!=0x078E ) {Synched=false; return true;} break; case 20 : if ((CC3(Buffer+Buffer_Offset)&0xFFFFE0)!=0x0788E0) {Synched=false; return true;} break; case 24 : if ((CC3(Buffer+Buffer_Offset)&0xFFFFFE)!=0x07888E) {Synched=false; return true;} break; default : ; } //We continue return true; } //*************************************************************************** // Buffer - Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_DolbyE::Header_Parse() { //Filling if (IsSub) Header_Fill_Size(Buffer_Size-Buffer_Offset); else { //Looking for synchro //Synchronizing Buffer_Offset_Temp=Buffer_Offset+3; if (BitDepth==16) while (Buffer_Offset_Temp+2<=Buffer_Size) { if ((CC2(Buffer+Buffer_Offset_Temp)&0xFFFE)==0x078E) //16-bit break; //while() Buffer_Offset_Temp++; } if (BitDepth==20) while (Buffer_Offset_Temp+3<=Buffer_Size) { if ((CC3(Buffer+Buffer_Offset_Temp)&0xFFFFE0)==0x0788E0) //20-bit break; //while() Buffer_Offset_Temp++; } if (BitDepth==24) while (Buffer_Offset_Temp+3<=Buffer_Size) { if ((CC3(Buffer+Buffer_Offset_Temp)&0xFFFFFE)==0x07888E) //24-bit break; //while() Buffer_Offset_Temp++; } if (Buffer_Offset_Temp+(BitDepth>16?3:2)>Buffer_Size) { if (File_Offset+Buffer_Size==File_Size) Buffer_Offset_Temp=Buffer_Size; else { Element_WaitForMoreData(); return; } } Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset); } Header_Fill_Code(0, "Frame"); } //--------------------------------------------------------------------------- void File_DolbyE::Data_Parse() { //In case of scrambling const int8u* Save_Buffer=NULL; size_t Save_Buffer_Offset=0; int64u Save_File_Offset=0; if (ScrambledBitStream) { //We must change the buffer, Save_Buffer=Buffer; Save_Buffer_Offset=Buffer_Offset; Save_File_Offset=File_Offset; File_Offset+=Buffer_Offset; Buffer_Offset=0; Descrambled_Buffer=new int8u[(size_t)Element_Size]; std::memcpy(Descrambled_Buffer, Save_Buffer+Save_Buffer_Offset, (size_t)Element_Size); Buffer=Descrambled_Buffer; } //Parsing BS_Begin(); Block(); BS_End(); //In case of scrambling if (ScrambledBitStream) { delete[] Buffer; Buffer=Save_Buffer; Buffer_Offset=Save_Buffer_Offset; File_Offset=Save_File_Offset; } FILLING_BEGIN(); if (!Status[IsAccepted]) { Accept("Dolby E"); //Guard band GuardBand_Before_Initial=GuardBand_Before; GuardBand_After_Initial=GuardBand_After; } Frame_Count++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (Mpegv_frame_rate[FrameRate]) FrameInfo.DUR=float64_int64s(1000000000/Mpegv_frame_rate[FrameRate]); else FrameInfo.DUR=(int64u)-1; if (FrameInfo.DTS!=(int64u)-1) FrameInfo.PTS=FrameInfo.DTS+=FrameInfo.DUR; if (Frame_Count==1) { Finish("Dolby E"); } FILLING_END(); if (Frame_Count==0 && Buffer_TotalBytes>Buffer_TotalBytes_FirstSynched_Max) Reject("Dolby E"); } //--------------------------------------------------------------------------- void File_DolbyE::Block() { //Parsing Skip_S3(BitDepth, "Synchro"); if (ScrambledBitStream) { //We must change the buffer switch (BitDepth) { case 16 : if (!Descramble_16bit()) return; break; case 20 : if (!Descramble_20bit()) return; break; case 24 : if (!Descramble_24bit()) return; break; default : ; } } Skip_S2(14, "Unknown"); Get_S1 ( 6, ProgramConfiguration, "Program configuration"); Param_Info1(DolbyE_ChannelPositions[ProgramConfiguration]); Get_S1 ( 4, FrameRate, "Frame rate 1"); Param_Info3(Mpegv_frame_rate[FrameRate], 3, " fps"); Skip_S1( 4, "Frame rate 2? Always same as Frame rate 1"); Skip_S2(16, "Frame number?"); Element_Begin1("SMPTE time code?"); int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens; bool DropFrame; Skip_S1(4, "BG8"); Skip_S1(4, "BG7"); 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, "BG6"); Skip_S1(4, "BG5"); Skip_SB( "BGF0 / BGF2"); Get_S1 (3, Minutes_Tens, "Minutes (Tens)"); Get_S1 (4, Minutes_Units, "Minutes (Units)"); Skip_S1(4, "BG4"); Skip_S1(4, "BG3"); Skip_SB( "FP - Field Phase / BGF0"); Get_S1 (3, Seconds_Tens, "Seconds (Tens)"); Get_S1 (4, Seconds_Units, "Seconds (Units)"); Skip_S1(4, "BG2"); Skip_S1(4, "BG1"); 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_BS(Data_BS_Remain(), "Unknown"); if (Hours_Tens<3) { 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 + (Mpegv_frame_rate[FrameRate]?float64_int32s((Frames_Tens*10+Frames_Units)*1000/Mpegv_frame_rate[FrameRate]):0)); Element_Info1(Ztring().Duration_From_Milliseconds(TimeCode)); //TimeCode if (SMPTE_time_code_StartTimecode==(int64u)-1) SMPTE_time_code_StartTimecode=TimeCode; } } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- bool File_DolbyE::Descramble_16bit () { int16u ScrambleMask; Get_S2 (16, ScrambleMask, "Scramble mask"); int16u Size=((BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Size-Data_BS_Remain()/8)^ScrambleMask)>>2)&0x3FF; if (Data_BS_Remain()<(size_t)((Size+1)*BitDepth)) //+1 for additional unknown word return false; //There is a problem int8u* Temp=Descrambled_Buffer+(size_t)Element_Size-Data_BS_Remain()/8; for (int16u Pos=0; Pos>4))>>2)&0x3FF; if (Data_BS_Remain()<(size_t)((Size+1)*BitDepth)) //+1 for additional unknown word return false; //There is a problem int8u* Temp=Descrambled_Buffer+(size_t)Element_Size-Data_BS_Remain()/8; int64u ScrambleMasks=(((int64u)ScrambleMask)<<20)|ScrambleMask; bool Half; if (Data_BS_Remain()%8) { Temp--; int24u2BigEndian(Temp, BigEndian2int24u(Temp)^(ScrambleMask)); Half=true; } else Half=false; for (int16u Pos=0; Pos>2)&0x3FF; if (Data_BS_Remain()<(size_t)((Size+1)*BitDepth)) //+1 for additional unknown word return false; //There is a problem int8u* Temp=Descrambled_Buffer+(size_t)Element_Size-Data_BS_Remain()/8; for (int16u Pos=0; Pos 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; Frequency_b=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 MediaInfoLib/Source/MediaInfo/Audio/File_Wvpk.h0000664000000000000000000000430712652076434020250 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about WavePack files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_WvpkH #define MediaInfo_File_WvpkH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Audio/File_ImpulseTracker.cpp0000664000000000000000000001444312652076434022610 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/Audio/File_Aac_Main.cpp0000664000000000000000000012652412652076434021312 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MEDIAINFO_ADVANCED #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #endif //MEDIAINFO_ADVANCED #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- extern const int32u Aac_sampling_frequency[13]= {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350}; //--------------------------------------------------------------------------- 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", "", "", "", "", "", "", "", "", }; //--------------------------------------------------------------------------- const char* Aac_ChannelLayout[]= { "", "C", "L R", "C L R", "C L R Cs", "C L R Ls Rs", "C L R Ls Rs LFE", "C L R Ls Rs Lrs Rrs LFE", }; int8u Aac_AudioSpecificConfig_sampling_frequency_index(const int64s 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) { int32u samplingFrequency; Get_S3 (24, samplingFrequency, "samplingFrequency"); Frequency_b=samplingFrequency; sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(Frequency_b); } else Frequency_b=Aac_sampling_frequency[sampling_frequency_index]; Get_S1 (4, channelConfiguration, "channelConfiguration"); Param_Info1(Aac_ChannelConfiguration[channelConfiguration]); if (audioObjectType==5 || audioObjectType==29) { 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==(size_t)-1)?0:End), "(Not implemented)"); Element_End0(); FILLING_BEGIN() if (Mode==File_Aac::Mode_ADIF || Mode==File_Aac::Mode_ADTS) File__Tags_Helper::Finish(); else if (Mode==Mode_AudioSpecificConfig) File__Analyze::Finish(); Frame_Count=(size_t)-1; //Forcing not to parse following data anymore (if ParseSpeed==1) FILLING_END() 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==(size_t)-1)?0:End), "(Not implemented)"); Element_End0(); if (Mode==File_Aac::Mode_ADIF || Mode==File_Aac::Mode_ADTS) File__Tags_Helper::Finish(); else { if (Mode==Mode_LATM) File__Analyze::Accept(); 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 (Frequency_b, audioObjectType, sbrData, psData, sbrPresentFlag, psPresentFlag); FILLING_END(); } //--------------------------------------------------------------------------- void File_Aac::AudioSpecificConfig_OutOfBand (int64s sampling_frequency_, int8u audioObjectType_, bool sbrData, bool psData, bool sbrPresentFlag, bool psPresentFlag) { if (!Frequency_b && sampling_frequency_) //Only if not yet set { Frequency_b=sampling_frequency_; sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index((int32u)Frequency_b); } 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_; if (Frequency_b) Infos["SamplingRate"].From_Number(Frequency_b); 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]); Infos["ChannelLayout"].From_Local(Aac_ChannelLayout[channelConfiguration]); } if (sbrPresentFlag || !Infos["Format_Settings_SBR"].empty()) { Infos["Format_Profile"]=__T("HE-AAC"); Ztring SamplingRate_Previous=Infos["SamplingRate"]; int32u SamplingRate=(extension_sampling_frequency_index==(int8u)-1)?(((int32u)Frequency_b)*2):extension_sampling_frequency; if (SamplingRate) { Infos["SamplingRate"].From_Number(SamplingRate, 10); if (MediaInfoLib::Config.LegacyStreamDisplay_Get()) { Infos["Format_Profile"]+=__T(" / LC"); Infos["SamplingRate"]+=__T(" / ")+SamplingRate_Previous; } } 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_Settings_PS"].empty()) { Infos["Format_Profile"]=__T("HE-AACv2"); Ztring Channels=Infos["Channel(s)"]; Ztring ChannelPositions=Infos["ChannelPositions"]; Ztring SamplingRate_Previous=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; int32u SamplingRate=(extension_sampling_frequency_index==(int8u)-1)?(((int32u)Frequency_b)*2):extension_sampling_frequency; if (SamplingRate) Infos["SamplingRate"]=Ztring().From_Number(SamplingRate, 10)+__T(" / ")+SamplingRate_Previous; } 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 { CanFill=false; 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; i0) 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(); //Encryption management if (CA_system_ID_MustSkipSlices) { //Is not decodable BS_End(); Skip_XX(Element_Size-Element_Offset, "Encrypted data"); Frame_Count_Valid=0; return; } 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"); Frequency_b=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)); if (Aac_sampling_frequency[sampling_frequency_index]) 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]); Infos["ChannelLayout"].From_Local(Aac_ChannelLayout[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(); if (adts_buffer_fullness==0x7FF) adts_buffer_fullness_Is7FF=true; #if MEDIAINFO_ADVANCED aac_frame_length_Total+=aac_frame_length; #endif //MEDIAINFO_ADVANCED FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_AAC_YES MediaInfoLib/Source/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp0000664000000000000000000006334312652076434023572 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern const char* Aac_audioObjectType(int8u audioObjectType); //--------------------------------------------------------------------------- int8u Aac_AudioSpecificConfig_sampling_frequency_index(const int64s 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] = { 0 }; for (int8u k=0; k0) { incr=-1; k=numBands-1; } else { incr=1; k=0; } while (k2Diff) { if (k >= 64) break; 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 == 0 || 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] = { 0 }; int8u vk1[64]; numBands1=2*Aac_bands_Compute(true, bands, k1, k2); if (numBands1 == 0 || 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]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(Frequency_b); Infos["SamplingRate"].From_Number((extension_sampling_frequency_index==(int8u)-1)?(Frequency_b*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 (Frame_Count_Valid<32) Frame_Count_Valid=32; //We need to find the SBR header } 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=(int32u)(Frequency_b*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); FILLING_BEGIN(); if (MediaInfoLib::Config.ParseSpeed_Get()<0.3) { Frame_Count_Valid=Frame_Count+1; if (Frame_Count<8) Frame_Count_Valid+=8-Frame_Count; } FILLING_END(); } 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 (Endbs_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; envbs_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; relbs_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; envbs_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; relbs_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; relbs_num_env[ch]+1))/log((double)2)); Skip_BS(ptr_bits, "bs_pointer[ch]"); Element_Begin1("bs_freq_res[ch]"); for (int8u env=0; envbs_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; envbs_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 (Endbs_num_env[ch]; env++) Get_S1 (1, sbr->bs_df_env[ch][env], "bs_df_env[ch][env]"); for (int noise=0; noisebs_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; nnum_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; envbs_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; noisebs_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; bandnum_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; nnum_env_bands[1]; n++) Skip_SB( "bs_add_harmonic[ch][n]"); Element_End0(); } } //NameSpace #endif //MEDIAINFO_AAC_YES MediaInfoLib/Source/MediaInfo/Audio/File_Ape.cpp0000664000000000000000000002121212652076434020353 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_Size //--------------------------------------------------------------------------- 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 FrameTypes; int64u Header_Size; int8u FrameType; int8u Channels; bool IsWB; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Audio/File_Module.cpp0000664000000000000000000000740012652076434021076 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 MediaInfoLib/Source/MediaInfo/File__Analyze.h0000664000000000000000000023241112652076434020021 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef MediaInfo_File__AnalyzeH #define MediaInfo_File__AnalyzeH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Base.h" #include "MediaInfo/File__Analyse_Automatic.h" #include "ZenLib/BitStream_Fast.h" #include "ZenLib/BitStream_LE.h" #if MEDIAINFO_IBIUSAGE #include "MediaInfo/Multiple/File_Ibi_Creation.h" #endif //MEDIAINFO_IBIUSAGE #include "tinyxml2.h" #if MEDIAINFO_AES #include #endif //MEDIAINFO_AES #include "MediaInfo/HashWrapper.h" //--------------------------------------------------------------------------- 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_OutOfBand ( const int8u* Buffer, size_t Buffer_Size) {File__Analyze::Buffer=Buffer; File__Analyze::Buffer_Size=Buffer_Size; Element_Offset=0; Element_Size=Buffer_Size; Read_Buffer_OutOfBand(); File__Analyze::Buffer=NULL; File__Analyze::Buffer_Size=0; Element_Offset=0; Element_Size=0;} void Open_Buffer_OutOfBand (File__Analyze* Sub, const int8u* Buffer, size_t Buffer_Size); void Open_Buffer_OutOfBand (File__Analyze* Sub) {if (Element_Offset<=Element_Size) Open_Buffer_OutOfBand(Sub, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); Element_Offset=Element_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, bool IsNewPacket=true, float64 Ratio=1.0); void Open_Buffer_Continue (File__Analyze* Sub, size_t Buffer_Size) {if (Element_Offset+Buffer_Size<=Element_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) {if (Element_Offset<=Element_Size) 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 #if MEDIAINFO_ADVANCED2 void Open_Buffer_SegmentChange(); #endif //MEDIAINFO_ADVANCED2 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]; void Event_Prepare (struct MediaInfo_Event_Generic* Event); #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX int8u Demux_Level; //bit 0=frame, bit 1=container, bit 2=elementary (eg MPEG-TS), bit 3=ancillary (e.g. DTVCC), default with frame set bool Demux_random_access; bool Demux_UnpacketizeContainer; bool Demux_IntermediateItemFound; size_t Demux_Offset; int64u Demux_TotalBytes; File__Analyze* Demux_CurrentParser; #endif //MEDIAINFO_DEMUX Ztring File_Name_WithoutDemux; bool PTS_DTS_Needed; enum ts_type { TS_NONE=0, TS_PTS=1, TS_DTS=2, TS_ALL=TS_PTS|TS_DTS, }; void TS_Clear(ts_type Type=TS_ALL); void TS_Set(int64s Ticks, ts_type Type=TS_ALL); void TS_Set(File__Analyze* Parser, ts_type Type=TS_ALL); void TS_Add(int64s Ticks, ts_type Type=TS_ALL); void TS_Ajust(int64s Ticks); int64s Frequency_c; //Frequency of the timestamp of the container (e.g. 90000 for MPEG-PS) int64s Frequency_b; //Frequency of the timestamp of the bitstream (e.g. 48000 for AC-3) #if MEDIAINFO_ADVANCED2 static const int64s NoTs=0x8000000000000000LL; int64s PTSb; //In 1/Frequency_b if sub, in 1/(Frequency_c*Frequency_b) if in a container int64s DTSb; //In 1/Frequency_b if sub, in 1/(Frequency_c*Frequency_b) if in a container #endif //MEDIAINFO_ADVANCED2 struct frame_info { int64u Buffer_Offset_End; int64u PCR; //In nanoseconds int64u PTS; //In nanoseconds int64u DTS; //In nanoseconds int64u DUR; //In nanoseconds #if MEDIAINFO_ADVANCED2 int64s PTSc; //In 1/Frequency_c int64s DTSc; //In 1/Frequency_c int64u Frame_Count_AfterLastTimeStamp; #endif //MEDIAINFO_ADVANCED2 frame_info() { Buffer_Offset_End=(int64u)-1; PCR=(int64u)-1; PTS=(int64u)-1; DTS=(int64u)-1; DUR=(int64u)-1; #if MEDIAINFO_ADVANCED2 PTSc=NoTs; DTSc=NoTs; Frame_Count_AfterLastTimeStamp=0; #endif //MEDIAINFO_ADVANCED2 } }; frame_info FrameInfo; frame_info FrameInfo_Previous; frame_info FrameInfo_Next; std::vector Offsets_Stream; std::vector Offsets_Buffer; size_t Offsets_Pos; int8u* OriginalBuffer; size_t OriginalBuffer_Size; size_t OriginalBuffer_Capacity; #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) struct servicedescriptor { string language; }; typedef std::map servicedescriptors608; typedef std::map servicedescriptors708; struct servicedescriptors { #if defined(MEDIAINFO_EIA608_YES) std::map ServiceDescriptors608; #endif #if defined(MEDIAINFO_EIA708_YES) std::map ServiceDescriptors708; #endif }; servicedescriptors* ServiceDescriptors; #endif //Out int64u PTS_Begin; //In nanoseconds #if MEDIAINFO_ADVANCED2 int64u PTS_Begin_Segment; //In nanoseconds #endif //MEDIAINFO_ADVANCED2 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; int64u FrameNumber_PresentationOrder; bool Synched; //Data is synched bool UnSynched_IsNotJunk; //Data is actually 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_OutOfBand () {}; //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 #if MEDIAINFO_ADVANCED2 virtual void Read_Buffer_SegmentChange () {}; //Temp, should be in File__Base caller #endif //MEDIAINFO_ADVANCED2 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); #define Header_Fill_Code2(A,B) Header_Fill_Code(A,B) 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) {if (Config_Trace_Level<1) return; Element_Info(Ztring().From_UTF8(Parameter));} inline void Element_Info (const char* Parameter, const char* Measure) {if (Config_Trace_Level<1) return; Element_Info(Ztring().From_UTF8(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int8s Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int8u Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int16s Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int16u Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int32s Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int32u Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int64s Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int64u Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));} inline void Element_Info (int128u Parameter, const char* Measure=NULL) {if (Config_Trace_Level<1) return; 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) {if (Config_Trace_Level<1) return; Element_Info(Ztring::ToZtring(Parameter, AfterComma)+Ztring().From_UTF8(Measure));} inline void Element_Info (float64 Parameter, int8u AfterComma=3, const char* Measure=NULL) {if (Config_Trace_Level<1) return; 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) {if (Config_Trace_Level<1) return; Element_Info(Ztring().Duration_From_Milliseconds(Parameter));} void Element_Parser (const Ztring &Name); //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_BF2 (float32 &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 (int8u 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(int8u 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_BF2(_INFO, _NAME) float32 _INFO; Get_BF2 (_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_6937_2(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_ISO_8859_5(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_ISO_6937_2(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_ISO_6937_2(_BYTES, _INFO, _NAME) Ztring _INFO; Get_ISO_6937_2 (_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 (int8u 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 (int8u Bits, int8u &Info, const char* Name); void Get_S2 (int8u Bits, int16u &Info, const char* Name); void Get_S3 (int8u Bits, int32u &Info, const char* Name); void Get_S4 (int8u Bits, int32u &Info, const char* Name); void Get_S5 (int8u Bits, int64u &Info, const char* Name); void Get_S6 (int8u Bits, int64u &Info, const char* Name); void Get_S7 (int8u Bits, int64u &Info, const char* Name); void Get_S8 (int8u Bits, int64u &Info, const char* Name); void Peek_BS(int8u Bits, int32u &Info); void Peek_SB( bool &Info); bool Peek_SB() {bool Temp; Peek_SB(Temp); return Temp;} 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); void Skip_BS(size_t Bits, const char* Name); void Skip_SB( const char* Name); void Skip_S1(int8u Bits, const char* Name); void Skip_S2(int8u Bits, const char* Name); void Skip_S3(int8u Bits, const char* Name); void Skip_S4(int8u Bits, const char* Name); void Skip_S5(int8u Bits, const char* Name); void Skip_S6(int8u Bits, const char* Name); void Skip_S7(int8u Bits, const char* Name); void Skip_S8(int8u 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_T4 (size_t Bits, int32u &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_T4(size_t Bits, int32u &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_T4(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_T4(_BITS, _INFO, _NAME) int32u _INFO; Get_T4(_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); bool Trusted_Get () {return !Element[Element_Level].UnTrusted;} //*************************************************************************** // 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);} void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float32 Value, int8u AfterComma=3, bool Replace=false); inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float64 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, (float32)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, (float32)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 (); static 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 (); //*************************************************************************** // 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 void CodecID_Fill (const Ztring &Value, stream_t StreamKind, size_t StreamPos, infocodecid_format_t Format, stream_t StreamKind_CodecID=Stream_Max); void PixelAspectRatio_Fill (const Ztring &Value, stream_t StreamKind, size_t StreamPos, size_t Parameter_Width, size_t Parameter_Height, size_t Parameter_PixelAspectRatio, size_t Parameter_DisplayAspectRatio); void DisplayAspectRatio_Fill(const Ztring &Value, stream_t StreamKind, size_t StreamPos, size_t Parameter_Width, size_t Parameter_Height, size_t Parameter_PixelAspectRatio, size_t Parameter_DisplayAspectRatio); //*************************************************************************** // 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_Other(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 Streams_Finish_HumanReadable(); void Streams_Finish_HumanReadable_PerStream(stream_t StreamKind, size_t StreamPos, size_t Parameter); 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); //*************************************************************************** // //*************************************************************************** protected : //Save for speed improvement float Config_Trace_Level; std::bitset<32> Config_Trace_Layers; MediaInfo_Config::trace_Format Config_Trace_Format; 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 protected : //Buffer bool Open_Buffer_Continue_Loop(); const int8u* Buffer; public : //TO CHANGE size_t Buffer_Size; int64u Buffer_TotalBytes; int64u Buffer_TotalBytes_FirstSynched; int64u Buffer_TotalBytes_LastSynched; int64u Buffer_PaddingBytes; int64u Buffer_JunkBytes; 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: void TestContinuousFileNames(size_t CountOfFiles=24, Ztring FileExtension=Ztring(), bool SkipComputeDelay=false); 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 Ztring &Details_Get(size_t Level=0) {return Element[Level].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 Ztring Value; //The value (currently used only with Trace XML) 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; //NextCode std::map NextCode; //BookMarks size_t BookMark_Element_Level; int64u BookMark_GoTo; std::vector BookMark_Code; std::vector 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; bool CA_system_ID_MustSkipSlices; bool FillAllMergedStreams; class streamidentity { public: stream_t StreamKind; size_t StreamPos; streamidentity(stream_t StreamKind_, size_t StreamPos_) : StreamKind(StreamKind_) , StreamPos(StreamPos_) {} }; std::vector MergedStreams_Last; //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, const int8u* OriginalBuffer=NULL, size_t OriginalBuffer_Size=0); 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; //AES #if MEDIAINFO_AES AESdecrypt* AES; int8u* AES_IV; int8u* AES_Decrypted; size_t AES_Decrypted_Size; #endif //MEDIAINFO_AES //Hash #if MEDIAINFO_HASH HashWrapper* Hash; int64u Hash_ParseUpTo; #endif //MEDIAINFO_HASH #if MEDIAINFO_SEEK private: bool Seek_Duration_Detected; #endif //MEDIAINFO_SEEK #if MEDIAINFO_IBIUSAGE public: int64u Ibi_SynchronizationOffset_Current; int64u Ibi_SynchronizationOffset_BeginOfFrame; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE public: bool Config_Ibi_Create; ibi Ibi; //If Main only ibi::stream* IbiStream; //If sub only 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_IBIUSAGE 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_IBIUSAGE }; //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() \ { \ } \ */ //Begin #define FILLING_BEGIN() \ if (Element_IsOK()) \ { #define FILLING_BEGIN_PRECISE() \ if (Element_IsOK() && Element_Offset==Element_Size) \ { //Else #define FILLING_ELSE() \ } \ else \ { \ //End #define FILLING_END() \ } #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 MediaInfoLib/Source/MediaInfo/MediaInfo_Inform.cpp0000664000000000000000000011476112652076434021027 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Inform part // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Utils.h" #if defined(MEDIAINFO_EBUCORE_YES) #include "MediaInfo/Export/Export_EbuCore.h" #endif //defined(MEDIAINFO_EBUCORE_YES) #if defined(MEDIAINFO_FIMS_YES) #include "MediaInfo/Export/Export_Fims.h" #endif //defined(MEDIAINFO_EBUCORE_YES) #if defined(MEDIAINFO_MPEG7_YES) #include "MediaInfo/Export/Export_Mpeg7.h" #endif //defined(MEDIAINFO_MPEG7_YES) #if defined(MEDIAINFO_REVTMD_YES) #include "MediaInfo/Export/Export_reVTMD.h" #endif //defined(MEDIAINFO_REVTMD_YES) #if defined(MEDIAINFO_PBCORE_YES) #include "MediaInfo/Export/Export_PBCore.h" #include "MediaInfo/Export/Export_PBCore2.h" #endif //defined(MEDIAINFO_PBCORE_YES) #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/File__Analyze.h" #include "base64.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- #if defined(MEDIAINFO_XML_YES) Ztring Xml_Name_Escape_0_7_78 (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("("), Ztring(), 0, Ztring_Recursive); ToReturn.FindAndReplace(__T(")"), Ztring(), 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=__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; } #endif //defined(MEDIAINFO_XML_YES) //--------------------------------------------------------------------------- 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.Inform_Get()!=__T("MAXML") && (MediaInfoLib::Config.Trace_Level_Get() || MediaInfoLib::Config.Inform_Get()==__T("Details"))) { if (!Details.empty()) return Details; else if (Info) return Info->Details_Get(); else return Ztring(); } #endif //MEDIAINFO_TRACE #if defined(MEDIAINFO_EBUCORE_YES) if (MediaInfoLib::Config.Inform_Get()==__T("EBUCore_1.6")) return Export_EbuCore().Transform(*this, Export_EbuCore::Version_1_6); if (MediaInfoLib::Config.Inform_Get()==__T("EBUCore") || MediaInfoLib::Config.Inform_Get()==__T("EBUCore_1.5")) return Export_EbuCore().Transform(*this); #endif //defined(MEDIAINFO_EBUCORE_YES) #if defined(MEDIAINFO_EBUCORE_YES) if (MediaInfoLib::Config.Inform_Get()==__T("FIMS_1.1")) return Export_Fims().Transform(*this, Export_Fims::Version_1_1); if (MediaInfoLib::Config.Inform_Get()==__T("FIMS_1.2") || MediaInfoLib::Config.Inform_Get()==__T("FIMS")) return Export_Fims().Transform(*this, Export_Fims::Version_1_2); if (MediaInfoLib::Config.Inform_Get()==__T("FIMS_1.3")) return Export_Fims().Transform(*this, Export_Fims::Version_1_3); #endif //defined(MEDIAINFO_FIMS_YES) #if defined(MEDIAINFO_MPEG7_YES) if (MediaInfoLib::Config.Inform_Get()==__T("MPEG-7")) return Export_Mpeg7().Transform(*this); #endif //defined(MEDIAINFO_MPEG7_YES) #if defined(MEDIAINFO_PBCORE_YES) 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("PBCore2") || MediaInfoLib::Config.Inform_Get()==__T("PBCore_2.0")) return Export_PBCore2().Transform(*this); #endif //defined(MEDIAINFO_PBCORE_YES) #if defined(MEDIAINFO_REVTMD_YES) if (MediaInfoLib::Config.Inform_Get()==__T("reVTMD")) return __T("reVTMD is disabled due to its non-free licensing."); //return Export_reVTMD().Transform(*this); #endif //defined(MEDIAINFO_REVTMD_YES) #if defined(MEDIAINFO_CUSTOM_YES) 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\n\n\n\n\n"); #if defined(MEDIAINFO_XML_YES) if (XML_0_7_78_MA || XML_0_7_78_MI) { size_t Modified; Retour+=__T("\n"); } if (XML_0_7_78_MA) Retour+=__T("\n"); if (XML) Retour+=__T("\n"); #endif //defined(MEDIAINFO_XML_YES) for (size_t StreamKind=(size_t)Stream_General; StreamKind\n\n

"); if (XML || XML_0_7_78_MA || XML_0_7_78_MI) Retour+=__T("\n "); if (XML || XML_0_7_78_MA || XML_0_7_78_MI) 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("\n
"); if (XML || XML_0_7_78_MA || XML_0_7_78_MI) Retour+=__T("\n"); Retour+=MediaInfoLib::Config.LineSeparator_Get(); } } if (HTML) Retour+=__T("\n\n\n"); if (XML_0_7_78_MA) Retour+=__T("\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); #if MEDIAINFO_TRACE if (XML_0_7_78_MA) { if (MediaInfoLib::Config.Trace_Level_Get() || MediaInfoLib::Config.Inform_Get()==__T("Details")) { Retour+=__T("\n"); if (!Details.empty()) Retour+=Details; else if (Info) Retour+=Info->Details_Get(); Retour+=__T("\n"); Retour+=__T("\n"); } } #endif //MEDIAINFO_TRACE if (XML_0_7_78_MA || XML_0_7_78_MI) Retour+=__T("\n"); if (XML) Retour+=__T("\n"); return Retour; #else //defined(MEDIAINFO_TEXT_YES) || defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES) return Ztring(); //Disabled #endif //defined(MEDIAINFO_TEXT_YES) || defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES) } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_TEXT_YES) || defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES) || defined(MEDIAINFO_CUSTOM_YES) 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; #if defined(MEDIAINFO_HTML_YES) bool HTML=MediaInfoLib::Config.Inform_Get()==__T("HTML")?true:false; #endif //defined(MEDIAINFO_HTML_YES) #if defined(MEDIAINFO_XML_YES) bool XML=MediaInfoLib::Config.Inform_Get()==__T("XML")?true:false; bool XML_0_7_78=(MediaInfoLib::Config.Inform_Get()==__T("MAXML") || MediaInfoLib::Config.Inform_Get()==__T("MIXML"))?true:false; if (XML_0_7_78) XML=true; #endif //defined(MEDIAINFO_XML_YES) #if defined(MEDIAINFO_CSV_YES) bool CSV=MediaInfoLib::Config.Inform_Get()==__T("CSV")?true:false; #endif //defined(MEDIAINFO_CSV_YES) #if defined(MEDIAINFO_TEXT_YES) && (defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES)) bool Text=true; #if defined(MEDIAINFO_HTML_YES) if (HTML) Text=false; #endif //defined(MEDIAINFO_HTML_YES) #if defined(MEDIAINFO_XML_YES) if (XML) Text=false; #endif //defined(MEDIAINFO_XML_YES) #if defined(MEDIAINFO_CSV_YES) if (CSV) Text=false; #endif //defined(MEDIAINFO_CSV_YES) #endif //defined(MEDIAINFO_TEXT_YES) && (defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES)) size_t Size=Count_Get(StreamKind, StreamPos); bool IsExtra=false; for (size_t Champ_Pos=0; Champ_Pos=Stream[StreamKind][StreamPos].size()) Shouldshow=true; else { Ztring Options=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Options); if (InfoOption_ShowInXml=Stream[StreamKind][StreamPos].size()) { Retour+=__T("\n"); IsExtra=true; } #endif //defined(MEDIAINFO_XML_YES Ztring Nom=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Name_Text); #if defined(MEDIAINFO_XML_YES) if (Nom.empty() || XML_0_7_78) #else if (Nom.empty()) #endif //defined(MEDIAINFO_XML_YES Nom=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Name); //Texte n'existe pas #if defined(MEDIAINFO_TEXT_YES) && (defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES)) if (Text) #endif //defined(MEDIAINFO_TEXT_YES) && (defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES)) { 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); #if defined(MEDIAINFO_XML_YES) if (XML_0_7_78 && MediaInfoLib::Config.Info_Get(StreamKind).Read(Champ_Pos, Info_Measure)==__T(" ms")) { size_t Decimal = Valeur.find(__T('.')); size_t Precision=3; if (Decimal != (size_t)-1) Precision+=Valeur.size()-Decimal-1; float64 Ms=Valeur.To_float64(); Valeur.From_Number(Ms/1000, Precision); } #endif // defined(MEDIAINFO_XML_YES) Valeur.FindAndReplace(__T("\\"), __T("|SC1|"), 0, Ztring_Recursive); #if defined(MEDIAINFO_HTML_YES) if (HTML) { Retour+=__T(" \n "); Retour+=Nom; Retour+=__T(" :\n "); Retour+=Valeur; Retour+=__T("\n "); } #endif //defined(MEDIAINFO_HTML_YES) #if defined(MEDIAINFO_XML_YES) if (XML) { if (XML_0_7_78) Nom=Xml_Name_Escape_0_7_78(Nom); else Nom=Xml_Name_Escape(Nom); size_t Modified; Xml_Content_Escape_Modifying(Valeur, Modified); if (XML_0_7_78 && Nom.size()>8 && Nom.rfind(__T("_Version"))==Nom.size()-8 && Valeur.size()>8 && Valeur.rfind(__T("Version "), 0)==0) { Valeur.erase(0, 8); // Remove useless "Version " size_t SlashPos = Valeur.find(__T(" / ")); if (SlashPos!=string::npos) Valeur.erase(SlashPos); } Retour+=__T("<"); Retour+=Nom; if (Modified==1 && !MediaInfoLib::Config.SkipBinaryData_Get()) //Base64 Retour+=__T(" dt=\"binary.base64\""); Retour+=__T(">"); if (Modified==1 && MediaInfoLib::Config.SkipBinaryData_Get()) Retour+=__T("(Binary data)"); else Retour+=Valeur; Retour+=__T(""); } #endif //defined(MEDIAINFO_XML_YES) #if defined(MEDIAINFO_CSV_YES) if (CSV) { Retour+=Nom; Retour+=__T(","); Retour+=Valeur; } #endif //defined(MEDIAINFO_CSV_YES) #if defined(MEDIAINFO_TEXT_YES) && (defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES)) if (Text) #endif //defined(MEDIAINFO_TEXT_YES) && (defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES)) Retour+=Nom + MediaInfoLib::Config.Language_Get(__T(" Config_Text_Separator")) + Valeur; Retour+=MediaInfoLib::Config.LineSeparator_Get(); } } //Extra if (IsExtra) { Retour+=__T("\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); 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; 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 if (PosX == (size_t)-1) break; 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 if (PosX == (size_t)-1) break; else PosX++; } //Retour=__T("\n\n \n \r\n \n \n \n \r\n \n \n \n \r\n \n \n \n \r\n \n \n \n \r\n \n \n \n \r\n \n \n \n \r\n
Video #0
Codec :WMV1
Codec/Info :Windows Media Video 7
Width :200 pixels
Height :150 pixels
Aspect ratio :4/3
Resolution :24 bits
\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; } #endif //defined(MEDIAINFO_TEXT_YES) || defined(MEDIAINFO_HTML_YES) || defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_CSV_YES) || defined(MEDIAINFO_CUSTOM_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_CUSTOM_YES) 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); } #endif //defined(MEDIAINFO_CUSTOM_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_XML_YES) 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=__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; } #endif //defined(MEDIAINFO_XML_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_XML_YES) Ztring MediaInfo_Internal::Xml_Content_Escape (const Ztring &Content, size_t &Modified) { Ztring ToReturn(Content); return Xml_Content_Escape_Modifying(ToReturn, Modified); } #endif //defined(MEDIAINFO_XML_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_XML_YES) size_t Xml_Content_Escape_MustEscape(const Ztring &Content) { size_t Pos=0; size_t Size=Content.size(); for (; Pos') : return Pos; default : if (Content[Pos]<0x20) return Pos; } } return Pos; } Ztring &MediaInfo_Internal::Xml_Content_Escape_Modifying (Ztring &Content, size_t &Modified) { size_t Pos=Xml_Content_Escape_MustEscape(Content); Ztring Content_Save=Content; Modified=0; if (Pos>=Content.size()) return Content; for (; Pos'): Content[Pos]=__T('&'); Content.insert(Pos+1, __T("gt;")); Pos+=3; break; case __T('\r'): case __T('\n'): break; default: if (Content[Pos]<0x20) { /* Is still invalid XML 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; */ string Content_Utf8=Content_Save.To_UTF8(); //TODO: shouldn't we never convert to Unicode? string Content_Base64=Base64::encode(Content_Utf8); Content.From_UTF8(Content_Base64); Modified=1; //Base64 Pos=Content.size(); //End } } } return Content; } #endif //defined(MEDIAINFO_XML_YES) } //NameSpace MediaInfoLib/Source/MediaInfo/File_Dummy.h0000664000000000000000000000265712652076434017361 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Archive/0000775000000000000000000000000012652076434016525 5ustar rootrootMediaInfoLib/Source/MediaInfo/Archive/File_Mz.cpp0000664000000000000000000001553112652076434020563 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 (Buffer[0]!=0x4D //"MZ" || Buffer[1]!=0x5A) { 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 MediaInfoLib/Source/MediaInfo/Archive/File_Mz.h0000664000000000000000000000232612652076434020226 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Archive/File_Elf.cpp0000664000000000000000000002117612652076434020705 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 (Buffer[0]!=0x7F //".ELF" || Buffer[1]!=0x45 || Buffer[2]!=0x4C || Buffer[3]!=0x46) { 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 MediaInfoLib/Source/MediaInfo/Archive/File_Rar.h0000664000000000000000000000346312652076434020367 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Archive/File_Tar.h0000664000000000000000000000223712652076434020367 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Archive/File_Zip.cpp0000664000000000000000000004645212652076434020745 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 (Buffer[0]!=0x50 //"PK.." || Buffer[1]!=0x4B || Buffer[2]!=0x03 || Buffer[3]!=0x04) { Reject("ZIP"); return false; } //This is OK, ZIP detected Accept(); Fill(Stream_General, 0, General_Format, "ZIP"); //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 break; case 1 : local_file_Step=2; //file_data is always parsed if (!file_data()) return false; break; case 2: if (!data_descriptor()) return false; local_file_Step=0; //data_descriptor is parsed, back to begin break; 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 MediaInfoLib/Source/MediaInfo/Archive/File_Zip.h0000664000000000000000000000333612652076434020404 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Archive/File_Gzip.h0000664000000000000000000000234012652076434020545 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Archive/File_Rar.cpp0000664000000000000000000003125612652076434020723 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 if (Buffer[0]!=0x52 //"Rar!" || Buffer[1]!=0x61 || Buffer[2]!=0x72 || Buffer[3]!=0x21 || Buffer[4]!=0x1A || Buffer[5]!=0x07 || Buffer[6]!=0x00) { Reject("RAR"); return false; } state=0; //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 using namespace ZenLib; //--------------------------------------------------------------------------- namespace MediaInfoLib { #if MEDIAINFO_EVENTS class File__Analyze; #endif //MEDIAINFO_EVENTS //*************************************************************************** // Class MediaInfo_Config_PerPackage //*************************************************************************** class MediaInfo_Config_PerPackage { public : //Constructor/Destructor MediaInfo_Config_PerPackage(); ~MediaInfo_Config_PerPackage(); //General Ztring Option (const String &Option, const String &Value=Ztring()); #if MEDIAINFO_EVENTS void IsClosedGOP (File__Analyze* Source); #endif //MEDIAINFO_EVENTS #if MEDIAINFO_EVENTS bool Event_CallBackFunction_IsSet (); Ztring Event_CallBackFunction_Set (const Ztring &Value); Ztring Event_CallBackFunction_Get (); void Event_Send(File__Analyze* Source, const int8u* Data_Content, size_t Data_Size, const Ztring &File_Name=Ztring()); void Event_SubFile_Start(const Ztring &FileName_Absolute); #endif //MEDIAINFO_EVENTS //Internal size_t CountOfPackages; private : //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 ZenLib::CriticalSection CS; //Constructor MediaInfo_Config_PerPackage (const MediaInfo_Config_PerPackage&); // Prevent copy-construction MediaInfo_Config_PerPackage& operator=(const MediaInfo_Config_PerPackage&); // Prevent assignment }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File__Analyze_Streams.cpp0000664000000000000000000053021212652076434022052 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 "MediaInfo/TimeCode.h" #include "ZenLib/File.h" #include "ZenLib/FileName.h" #include "ZenLib/BitStream_LE.h" #include #include 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; Pos1) Fill(StreamKind_Last, Pos, General_StreamKindPos, Pos+1, 10, true); else Clear(StreamKind_Last, Pos, General_StreamKindPos); } //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 (StreamPos0) { //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)); } 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 && BeginFileName_Modified_PathSeparatorOffset) { Fill (Stream_General, 0, General_FileName, FileName_Modified.substr(FileName_Modified_PathSeparatorOffset+1, FileName_Modified_ExtensionSeparatorOffset-(FileName_Modified_PathSeparatorOffset+1))); Fill (Stream_General, 0, General_FileExtension, FileName_Modified.substr(FileName_Modified_ExtensionSeparatorOffset+1)); } else Fill (Stream_General, 0, General_FileName, FileName_Modified.substr(FileName_Modified_PathSeparatorOffset+1)); } } //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; PosStream_Max || StreamPos>=Count_Get(KindOfStream)) return Error; //Filling Lists & Counts if (!IsSub && KindOfStream!=Stream_General) { const Ztring& StreamKind_Text=Get(KindOfStream, 0, General_StreamKind, Info_Text); ZtringList Temp; Temp.Separator_Set(0, __T(" / ")); Temp.Write(Retrieve(Stream_General, 0, Ztring(StreamKind_Text+__T("_Codec_List")).To_Local().c_str())); if (StreamPos1) Fill(KindOfStream, Pos, General_StreamKindPos, Pos+1, 10, true); else Clear(KindOfStream, Pos, General_StreamKindPos); } 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) { //MergedStreams if (FillAllMergedStreams) { FillAllMergedStreams=false; size_t s = MergedStreams_Last.size(); for (size_t i=0; iStream_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); switch (StreamKind) { case Stream_Video: switch (Parameter) { case Video_Width: if (IsRawStream) Fill(Stream_Video, StreamPos, Video_Sampled_Width, Value); break; case Video_Height: if (IsRawStream) Fill(Stream_Video, StreamPos, Video_Sampled_Height, Value); break; case Video_DisplayAspectRatio: DisplayAspectRatio_Fill(Value, Stream_Video, StreamPos, Video_Width, Video_Height, Video_PixelAspectRatio, Video_DisplayAspectRatio); break; case Video_PixelAspectRatio: PixelAspectRatio_Fill(Value, Stream_Video, StreamPos, Video_Width, Video_Height, Video_PixelAspectRatio, Video_DisplayAspectRatio); break; case Video_DisplayAspectRatio_CleanAperture: DisplayAspectRatio_Fill(Value, Stream_Video, StreamPos, Video_Width_CleanAperture, Video_Height_CleanAperture, Video_PixelAspectRatio_CleanAperture, Video_DisplayAspectRatio_CleanAperture); break; case Video_PixelAspectRatio_CleanAperture: PixelAspectRatio_Fill(Value, Stream_Video, StreamPos, Video_Width_CleanAperture, Video_Height_CleanAperture, Video_PixelAspectRatio_CleanAperture, Video_DisplayAspectRatio_CleanAperture); break; case Video_DisplayAspectRatio_Original: DisplayAspectRatio_Fill(Value, Stream_Video, StreamPos, Video_Width_Original, Video_Height_Original, Video_PixelAspectRatio_Original, Video_DisplayAspectRatio_Original); break; case Video_PixelAspectRatio_Original: PixelAspectRatio_Fill(Value, Stream_Video, StreamPos, Video_Width_Original, Video_Height_Original, Video_PixelAspectRatio_Original, Video_DisplayAspectRatio_Original); break; } break; case Stream_Audio: switch (Parameter) { case Audio_SamplesPerFrame: if (Retrieve(Stream_Audio, StreamPos, Audio_FrameRate).empty()) { float64 SamplesPerFrame=Value.To_float64(); float64 SamplingRate=DBL_MAX; ZtringList SamplingRates; SamplingRates.Separator_Set(0, " / "); SamplingRates.Write(Retrieve(Stream_Audio, StreamPos, Audio_SamplingRate)); if (!SamplingRates.empty()) { size_t i=SamplingRates.size(); do { --i; float64 SamplingRateTemp = SamplingRates[i].To_float64(); if (SamplingRateTemp && SamplingRateTempFile_MergeBitRateInfo_Get() #endif //MEDIAINFO_ADVANCED ) { 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_NominalFile_MergeBitRateInfo_Get() #endif //MEDIAINFO_ADVANCED ) { 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=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) Languages[Pos][0]=Language_Orig; //We failed to detect language, using the original version } } 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=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) { if (Languages[Pos].size()==2 && Languages[Pos][1].size()>=2 && Languages[Pos][1].size()<=3 && (Languages[Pos][1][0]&0xDF)>=__T('A') && (Languages[Pos][1][0]&0xDF)<=__T('Z') && (Languages[Pos][1][1]&0xDF)>=__T('A') && (Languages[Pos][1][1]&0xDF)<=__T('Z')) { Language_Translated+=__T(" ("); Language_Translated+=Ztring(Languages[Pos][1]).MakeUpperCase(); Language_Translated+=__T(")"); } else for (size_t Pos2=1; Pos2FrameRate*0.9995 && FrameRate_Nominal -0.000002 && float32_int32s(Value) - Value*1.001000 < +0.000002) // Detection of precise 1.001 (e.g. 24000/1001) taking into account precision of 32-bit float { Fill(StreamKind, StreamPos, Video_FrameRate_Num, Value*1001, 0, Replace); Fill(StreamKind, StreamPos, Video_FrameRate_Den, 1001, 10, Replace); } if (float32_int32s(Value) - Value*1.001001 > -0.000002 && float32_int32s(Value) - Value*1.001001 < +0.000002) // Detection of rounded 1.001 (e.g. 23976/1000) taking into account precision of 32-bit float { Fill(StreamKind, StreamPos, Video_FrameRate_Num, Value*1000, 0, Replace); Fill(StreamKind, StreamPos, Video_FrameRate_Den, 1000, 10, Replace); } } } Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace); } //--------------------------------------------------------------------------- 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 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 || Parameter==NULL || Parameter[0]=='\0') return; if (StreamPos>=(*Stream)[StreamKind].size()) { size_t Pos=Fill_Temp.Find(Ztring().From_UTF8(Parameter)); if (Pos!=string::npos) Fill_Temp.erase(Fill_Temp.begin()+Pos); 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=(*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+6; 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(); } else if (Parameter+1<(*Stream)[StreamKind][StreamPos].size() && MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter+1, Info_Name).find(__T("/String"))!=string::npos) { (*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=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=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_Num_Temp, FrameRate_Den_Temp, FrameRate_Mode_Temp, ScanType_Temp, ScanOrder_Temp, Channels_Temp, Delay_Temp, Delay_DropFrame_Temp, Delay_Source_Temp, Delay_Settings_Temp, Source_Temp, Source_Kind_Temp, Source_Info_Temp; Ztring colour_description_present_Temp, colour_primaries_Temp, transfer_characteristics_Temp, matrix_coefficients_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_Num_Temp=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate_Num); FrameRate_Den_Temp=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate_Den); FrameRate_Mode_Temp=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate_Mode); //We want to keep the FrameRate_Mode of AVI 120 fps ScanType_Temp=Retrieve(Stream_Video, StreamPos_To, Video_ScanType); ScanOrder_Temp=Retrieve(Stream_Video, StreamPos_To, Video_ScanOrder); colour_description_present_Temp=Retrieve(Stream_Video, StreamPos_To, Video_colour_description_present); if (!colour_description_present_Temp.empty()) { colour_primaries_Temp=Retrieve(Stream_Video, StreamPos_To, Video_colour_primaries); transfer_characteristics_Temp=Retrieve(Stream_Video, StreamPos_To, Video_transfer_characteristics); matrix_coefficients_Temp=Retrieve(Stream_Video, StreamPos_To, Video_matrix_coefficients); } Clear(Stream_Video, StreamPos_To, Video_colour_description_present); Clear(Stream_Video, StreamPos_To, Video_colour_primaries); Clear(Stream_Video, StreamPos_To, Video_transfer_characteristics); Clear(Stream_Video, StreamPos_To, Video_matrix_coefficients); } if (StreamKind==Stream_Audio) { Channels_Temp=Retrieve(Stream_Audio, StreamPos_To, Audio_Channel_s_); } 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_DropFrame", Retrieve(StreamKind, StreamPos_To, "Delay_DropFrame"), true); Clear(StreamKind, StreamPos_To, "Delay_DropFrame"); 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_DropFrame_Temp=Retrieve(StreamKind, StreamPos_To, "Delay_DropFrame"); //We want to keep the Delay_Source 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"); Ztring BitRate_Temp=Retrieve(StreamKind, StreamPos_To, "BitRate"); //Merging size_t Count=0; size_t Size=ToAdd.Count_Get(StreamKind, StreamPos_From); for (size_t Pos=General_Inform; Pos 9.990 && FrameRate<=10.010) FrameRate=10.000; else if (FrameRate>11.984 && FrameRate<=11.994) FrameRate=11.988; else if (FrameRate>11.994 && FrameRate<=12.010) FrameRate=12.000; else if (FrameRate>14.980 && FrameRate<=14.990) FrameRate=14.985; else if (FrameRate>14.990 && FrameRate<=15.010) FrameRate=15.000; else if (FrameRate>23.952 && FrameRate<=23.988) FrameRate=23.976; else if (FrameRate>23.988 && FrameRate<=24.024) FrameRate=24.000; else if (FrameRate>24.975 && FrameRate<=25.025) FrameRate=25.000; else if (FrameRate>29.940 && FrameRate<=29.985) FrameRate=29.970; else if (FrameRate>29.970 && FrameRate<=30.030) FrameRate=30.000; else if (FrameRate>23.952*2 && FrameRate<=23.988*2) FrameRate=23.976*2; else if (FrameRate>23.988*2 && FrameRate<=24.024*2) FrameRate=24.000*2; else if (FrameRate>24.975*2 && FrameRate<=25.025*2) FrameRate=25.000*2; else if (FrameRate>29.940*2 && FrameRate<=29.985*2) FrameRate=29.970*2; else if (FrameRate>29.970*2 && FrameRate<=30.030*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) && Retrieve(Stream_General, 0, General_Collection).empty()) 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) && Retrieve(Stream_General, 0, General_Collection).empty()) 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) && Retrieve(Stream_General, 0, General_Collection).empty()) 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); Clear(StreamKind, StreamPos, Parameter+5); Clear(StreamKind, StreamPos, Parameter+6); //Retrieving multiple values ZtringList List; List.Separator_Set(0, __T(" / ")); List.Write(Retrieve(StreamKind, StreamPos, Parameter)); //Per value for (size_t Pos=0; Pos0) { 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 Sec=MS/1000; //s if (Sec>0 || MM>0 || HH>0) { if (DurationString1.size()>0) DurationString1+=__T(" "); DurationString1+=Ztring::ToZtring(Sec)+MediaInfoLib::Config.Language_Get(__T("s")); if (DurationString2.size()<5) { if (DurationString2.size()>0) DurationString2+=__T(" "); DurationString2+=Ztring::ToZtring(Sec)+MediaInfoLib::Config.Language_Get(__T("s")); } else if (DurationString2.size()==0) DurationString2+=Ztring::ToZtring(Sec)+MediaInfoLib::Config.Language_Get(__T("s")); if (Sec<10) DurationString3+=Ztring(__T("0"))+Ztring::ToZtring(Sec)+__T("."); else DurationString3+=Ztring::ToZtring(Sec)+__T("."); MS-=Sec*1000; } else { DurationString3+=__T("00."); } //Milliseconds if (MS>0 || Sec>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 if (Parameter==Fill_Parameter(StreamKind, Generic_Duration)) { Ztring DurationString4; Ztring FrameRateS=Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_FrameRate)); Ztring FrameCountS=Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_FrameCount)); if (!FrameRateS.empty() && !FrameCountS.empty() && FrameRateS.To_int64u() && FrameRateS.To_int64u()<256) { bool DropFrame=false; bool DropFrame_IsValid=false; // Testing time code if (StreamKind==Stream_Video) { Ztring TC=Retrieve(Stream_Video, StreamPos, Video_TimeCode_FirstFrame); if (TC.size()>=11 && TC[2]==__T(':') && TC[5]==__T(':')) { switch (TC[8]) { case __T(':'): DropFrame=false; DropFrame_IsValid=true; break; case __T(';'): DropFrame=true; DropFrame_IsValid=true; break; default : ; } } } // Testing delay if (!DropFrame_IsValid) { Ztring TC=Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Delay_Original_DropFrame)); if (TC.size()>=11 && TC[2]==__T(':') && TC[5]==__T(':')) { switch (TC[8]) { case __T(':'): DropFrame=false; DropFrame_IsValid=true; break; case __T(';'): DropFrame=true; DropFrame_IsValid=true; break; default : ; } } } // Testing time code track if (!DropFrame_IsValid) { for (size_t Step=Retrieve(Stream_General, 0, General_Format)==__T("MXF")?0:1; Step<2; ++Step) { for (size_t TC_Pos=0; TC_Pos=11 && TC[2]==__T(':') && TC[5]==__T(':')) { switch (TC[8]) { case __T(':'): DropFrame=false; DropFrame_IsValid=true; break; case __T(';'): DropFrame=true; DropFrame_IsValid=true; break; default : ; } } if (DropFrame_IsValid) break; //Using first time code track } if (DropFrame_IsValid) break; //Using first time code track } } // Testing frame rate (1/1001) if (!DropFrame_IsValid) { float32 FrameRateF=FrameRateS.To_float32(); int32s FrameRateI=float32_int32s(FrameRateS.To_float32()); float FrameRateF_Min=((float32)FrameRateI)/((float32)1.002); float FrameRateF_Max=(float32)FrameRateI; if (FrameRateF>=FrameRateF_Min && FrameRateF=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; case 4 : Measure=__T(" TiB"); 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)); ZtringList List2; List2.Separator_Set(0, __T(" / ")); //Per value for (size_t Pos=0; Pos__T('9'))) { List2.push_back(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")); List2.push_back(MediaInfoLib::Config.Language_Get(BitRateS, Measure, true)); } else { //Standard if (BitRate>10000000000LL) { Ztring Measure=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure); Measure.insert(1, __T("G")); List2.push_back(MediaInfoLib::Config.Language_Get(Ztring::ToZtring(((float)BitRate)/1000000000, BitRate>100000000000LL?0:1), Measure, true)); } else if (BitRate>10000000) { Ztring Measure=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure); Measure.insert(1, __T("M")); List2.push_back(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")); List2.push_back(MediaInfoLib::Config.Language_Get(Ztring::ToZtring(((float)BitRate)/1000, BitRate>100000?0:1), Measure, true)); } else List2.push_back(MediaInfoLib::Config.Language_Get(Ztring::ToZtring(BitRate), MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure), true)); } } } Fill(StreamKind, StreamPos, Parameter+1, List2.Read()); } //--------------------------------------------------------------------------- //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; //Special cases if (StreamKind==Stream_Audio && Parameter==Audio_BitDepth_Detected && Retrieve(Stream_Audio, StreamPos, Audio_BitDepth)==Retrieve(Stream_Audio, StreamPos, Audio_BitDepth_Detected)) 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)); ZtringList List2; List2.Separator_Set(0, __T(" / ")); //Per value for (size_t Pos=0; Pos 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, stream_t StreamKind_CodecID) { if (StreamKind_CodecID==Stream_Max) StreamKind_CodecID=StreamKind; Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID), Value); const Ztring &C1=MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, 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_CodecID, Format, Value, InfoCodecID_Description), true); Fill(StreamKind, StreamPos, "CodecID/Hint", MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, Format, Value, InfoCodecID_Hint), true); Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID_Url), MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, Format, Value, InfoCodecID_Url), true); Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Version), MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, Format, Value, InfoCodecID_Version), true); Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Profile), MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, Format, Value, InfoCodecID_Profile), true); Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_ColorSpace), MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, Format, Value, InfoCodecID_ColorSpace), true); Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_ChromaSubsampling), MediaInfoLib::Config.CodecID_Get(StreamKind_CodecID, 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_CodecID, 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_CodecID, Format, Value, InfoCodecID_Compression_Mode), true); //Specific cases if (Value==__T("v210") || Value==__T("V210")) Fill(Stream_Video, StreamPos, Video_BitDepth, 10); } //--------------------------------------------------------------------------- void File__Analyze::PixelAspectRatio_Fill(const Ztring &Value, stream_t StreamKind, size_t StreamPos, size_t Parameter_Width, size_t Parameter_Height, size_t Parameter_PixelAspectRatio, size_t Parameter_DisplayAspectRatio) { if (Value.empty() || !Retrieve(StreamKind, StreamPos, Parameter_DisplayAspectRatio).empty()) return; if (Retrieve(StreamKind, StreamPos, Parameter_DisplayAspectRatio).empty()) { float32 PAR=Value.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(StreamKind, StreamPos, Parameter_Width ).To_float32(); float32 Height=Retrieve(StreamKind, StreamPos, Parameter_Height ).To_float32(); if (PAR && Height && Width) Fill(StreamKind, StreamPos, Parameter_DisplayAspectRatio, ((float32)Width)/Height*PAR); } } //--------------------------------------------------------------------------- void File__Analyze::DisplayAspectRatio_Fill(const Ztring &Value, stream_t StreamKind, size_t StreamPos, size_t Parameter_Width, size_t Parameter_Height, size_t Parameter_PixelAspectRatio, size_t Parameter_DisplayAspectRatio) { if (Value.empty()) return; float DAR=Value.To_float32(); if (Retrieve(StreamKind, StreamPos, Parameter_PixelAspectRatio).empty()) { float Width =Retrieve(StreamKind, StreamPos, Parameter_Width).To_float32(); float Height=Retrieve(StreamKind, StreamPos, Parameter_Height).To_float32(); if (DAR && Height && Width) { if (Value==__T("1.778")) DAR=((float)16)/9; //More exact value if (Value==__T("1.333")) DAR=((float)4)/3; //More exact value Fill(StreamKind, StreamPos, Parameter_PixelAspectRatio, DAR/(((float32)Width)/Height)); } } // /String version Ztring DARS; if (DAR>=(float)1.23 && DAR<(float)1.27) DARS=__T("5:4"); else if (DAR>=(float)1.30 && DAR<(float)1.37) DARS=__T("4:3"); else if (DAR>=(float)1.45 && DAR<(float)1.55) DARS=__T("3:2"); else if (DAR>=(float)1.55 && DAR<(float)1.65) DARS=__T("16:10"); else if (DAR>=(float)1.65 && DAR<(float)1.70) DARS=__T("5:3"); else if (DAR>=(float)1.74 && DAR<(float)1.82) DARS=__T("16:9"); else if (DAR>=(float)1.82 && DAR<(float)1.88) DARS=__T("1.85:1"); else if (DAR>=(float)2.15 && DAR<(float)2.22) DARS=__T("2.2:1"); else if (DAR>=(float)2.23 && DAR<(float)2.30) DARS=__T("2.25:1"); else if (DAR>=(float)2.30 && DAR<(float)2.37) DARS=__T("2.35:1"); else if (DAR>=(float)2.37 && DAR<(float)2.45) DARS=__T("2.40:1"); else DARS.From_Number(DAR); DARS.FindAndReplace(__T("."), MediaInfoLib::Config.Language_Get(__T(" Config_Text_FloatSeparator"))); if (MediaInfoLib::Config.Language_Get(__T(" Language_ISO639"))==__T("fr") && DARS.find(__T(":1"))==string::npos) DARS.FindAndReplace(__T(":"), __T("/")); Fill(StreamKind, StreamPos, Parameter_DisplayAspectRatio+1, DARS, true); } //--------------------------------------------------------------------------- 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_Duration_String4 : return General_Duration_String4; case Generic_Duration_String5 : return General_Duration_String5; case Generic_FrameRate : return General_FrameRate; case Generic_FrameCount : return General_FrameCount; case Generic_Delay : return General_Delay; case Generic_Delay_String : return General_Delay_String; case Generic_Delay_String1 : return General_Delay_String1; case Generic_Delay_String2 : return General_Delay_String2; case Generic_Delay_String3 : return General_Delay_String3; case Generic_Delay_String4 : return General_Delay_String4; case Generic_Delay_String5 : return General_Delay_String5; case Generic_Delay_Settings : return General_Delay_Settings; case Generic_Delay_DropFrame : return General_Delay_DropFrame; case Generic_Delay_Source : return General_Delay_Source; case Generic_Delay_Source_String : return General_Delay_Source_String; 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_Duration_String4 : return Video_Duration_String4; case Generic_Duration_String5 : return Video_Duration_String5; 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_Source_Duration_String4 : return Video_Source_Duration_String4; case Generic_Source_Duration_String5 : return Video_Source_Duration_String5; 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_FrameRate : return Video_FrameRate; 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_String5 : return Video_Delay_String5; case Generic_Delay_Settings : return Video_Delay_Settings; case Generic_Delay_DropFrame : return Video_Delay_DropFrame; 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_DropFrame : return Video_Delay_Original_DropFrame; 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_Duration_String4 : return Audio_Duration_String4; case Generic_Duration_String5 : return Audio_Duration_String5; 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_Source_Duration_String4 : return Audio_Source_Duration_String4; case Generic_Source_Duration_String5 : return Audio_Source_Duration_String5; 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_FrameRate : return Audio_FrameRate; 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_String5 : return Audio_Delay_String5; case Generic_Delay_Settings : return Audio_Delay_Settings; case Generic_Delay_DropFrame : return Audio_Delay_DropFrame; 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_DropFrame : return Audio_Delay_Original_DropFrame; 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_Duration_String4 : return Text_Duration_String4; case Generic_Duration_String5 : return Text_Duration_String5; 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_Source_Duration_String4 : return Text_Source_Duration_String4; case Generic_Source_Duration_String5 : return Text_Source_Duration_String5; 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_FrameRate : return Text_FrameRate; 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_String5 : return Text_Delay_String5; case Generic_Delay_Settings : return Text_Delay_Settings; case Generic_Delay_DropFrame : return Text_Delay_DropFrame; 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_DropFrame : return Text_Delay_Original_DropFrame; 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_Other : switch (StreamPos) { case Generic_Format : return Other_Format; case Generic_Format_Info : return Other_Format_Info; case Generic_Format_Url : return Other_Format_Url; case Generic_Format_Commercial : return Other_Format_Commercial; case Generic_Format_Commercial_IfAny : return Other_Format_Commercial_IfAny; case Generic_Format_Version : return Other_Format_Version; case Generic_Format_Profile : return Other_Format_Profile; case Generic_Format_Settings : return Other_Format_Settings; case Generic_CodecID : return Other_CodecID; case Generic_CodecID_Info : return Other_CodecID_Info; case Generic_CodecID_Hint : return Other_CodecID_Hint; case Generic_CodecID_Url : return Other_CodecID_Url; case Generic_CodecID_Description : return Other_CodecID_Description; case Generic_Duration : return Other_Duration; case Generic_Duration_String : return Other_Duration_String; case Generic_Duration_String1 : return Other_Duration_String1; case Generic_Duration_String2 : return Other_Duration_String2; case Generic_Duration_String3 : return Other_Duration_String3; case Generic_Duration_String4 : return Other_Duration_String4; case Generic_Duration_String5 : return Other_Duration_String5; case Generic_FrameRate : return Other_FrameRate; case Generic_FrameCount : return Other_FrameCount; case Generic_Language : return Other_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_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_Duration_String4 : return Menu_Duration_String4; case Generic_Duration_String5 : return Menu_Duration_String5; 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 MediaInfoLib/Source/MediaInfo/File__MultipleParsing.cpp0000664000000000000000000006320712652076434022075 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__MultipleParsing.h" //--------------------------------------------------------------------------- // Multiple #if defined(MEDIAINFO_AAF_YES) #include "MediaInfo/Multiple/File_Aaf.h" #endif #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_DASHMPD_YES) #include "MediaInfo/Multiple/File_DashMpd.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpAm.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpCpl.h" #endif #if defined(MEDIAINFO_DCP_YES) #include "MediaInfo/Multiple/File_DcpPkl.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_HDSF4M_YES) #include "MediaInfo/Multiple/File_HdsF4m.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_IMF_YES) #include "MediaInfo/Multiple/File_ImfCpl.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_PMP_YES) #include "MediaInfo/Multiple/File_Pmp.h" #endif #if defined(MEDIAINFO_PTX_YES) #include "MediaInfo/Multiple/File_Ptx.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_HEVC_YES) #include "MediaInfo/Video/File_Hevc.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_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_CAF_YES) #include "MediaInfo/Audio/File_Caf.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_OPENMG_YES) #include "MediaInfo/Audio/File_OpenMG.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_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.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_PDF_YES) #include "MediaInfo/Text/File_Pdf.h" #endif #if defined(MEDIAINFO_SCC_YES) #include "MediaInfo/Text/File_Scc.h" #endif #if defined(MEDIAINFO_SUBRIP_YES) #include "MediaInfo/Text/File_SubRip.h" #endif #if defined(MEDIAINFO_TTML_YES) #include "MediaInfo/Text/File_Ttml.h" #endif #if defined(MEDIAINFO_OTHERTEXT_YES) #include "MediaInfo/Text/File_OtherText.h" #endif //--------------------------------------------------------------------------- // Image #if defined(MEDIAINFO_ARRIRAW_YES) #include "MediaInfo/Image/File_ArriRaw.h" #endif #if defined(MEDIAINFO_BMP_YES) #include "MediaInfo/Image/File_Bmp.h" #endif #if defined(MEDIAINFO_BPG_YES) #include "MediaInfo/Image/File_Bpg.h" #endif #if defined(MEDIAINFO_DDS_YES) #include "MediaInfo/Image/File_Dds.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_PCX_YES) #include "MediaInfo/Image/File_Pcx.h" #endif #if defined(MEDIAINFO_PNG_YES) #include "MediaInfo/Image/File_Png.h" #endif #if defined(MEDIAINFO_PSD_YES) #include "MediaInfo/Image/File_Psd.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_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 // Multiple #if defined(MEDIAINFO_AAF_YES) Parser.push_back(new File_Aaf()); #endif #if defined(MEDIAINFO_BDAV_YES) {File_MpegTs* Temp=new File_MpegTs(); Temp->BDAV_Size=4; Parser.push_back(Temp);} #endif // Only with directories, no By Buffer interface // #if defined(MEDIAINFO_BDMV_YES) // Parser.push_back(new File_Bdmv()); // #endif #if defined(MEDIAINFO_CDXA_YES) Parser.push_back(new File_Cdxa()); #endif #if defined(MEDIAINFO_DASHMPD_YES) Parser.push_back(new File_DashMpd()); #endif #if defined(MEDIAINFO_DCP_YES) Parser.push_back(new File_DcpAm()); #endif #if defined(MEDIAINFO_DCP_YES) Parser.push_back(new File_DcpCpl()); #endif #if defined(MEDIAINFO_DCP_YES) Parser.push_back(new File_DcpPkl()); #endif #if defined(MEDIAINFO_DPG_YES) Parser.push_back(new File_Dpg()); #endif #if defined(MEDIAINFO_DVDIF_YES) Parser.push_back(new File_DvDif()); #endif #if defined(MEDIAINFO_DVDV_YES) Parser.push_back(new File_Dvdv()); #endif #if defined(MEDIAINFO_DXW_YES) Parser.push_back(new File_Dxw()); #endif #if defined(MEDIAINFO_FLV_YES) Parser.push_back(new File_Flv()); #endif #if defined(MEDIAINFO_GXF_YES) Parser.push_back(new File_Gxf()); #endif #if defined(MEDIAINFO_HDSF4M_YES) Parser.push_back(new File_HdsF4m()); #endif #if defined(MEDIAINFO_HLS_YES) Parser.push_back(new File_Hls()); #endif #if defined(MEDIAINFO_ISM_YES) Parser.push_back(new File_Ism()); #endif #if defined(MEDIAINFO_IVF_YES) Parser.push_back(new File_Ivf()); #endif #if defined(MEDIAINFO_LXF_YES) Parser.push_back(new File_Lxf()); #endif #if defined(MEDIAINFO_MK_YES) Parser.push_back(new File_Mk()); #endif #if defined(MEDIAINFO_MPEG4_YES) Parser.push_back(new File_Mpeg4()); #endif #if defined(MEDIAINFO_MPEGPS_YES) Parser.push_back(new File_MpegPs()); #endif #if defined(MEDIAINFO_MPEGTS_YES) Parser.push_back(new File_MpegTs()); #endif #if defined(MEDIAINFO_TSP_YES) {File_MpegTs* Temp=new File_MpegTs(); Temp->TSP_Size=16; Parser.push_back(Temp);} #endif #if defined(MEDIAINFO_MXF_YES) Parser.push_back(new File_Mxf()); #endif #if defined(MEDIAINFO_NUT_YES) Parser.push_back(new File_Nut()); #endif #if defined(MEDIAINFO_OGG_YES) Parser.push_back(new File_Ogg()); #endif #if defined(MEDIAINFO_P2_YES) Parser.push_back(new File_P2_Clip()); #endif #if defined(MEDIAINFO_PMP_YES) Parser.push_back(new File_Pmp()); #endif #if defined(MEDIAINFO_PTX_YES) Parser.push_back(new File_Ptx()); #endif #if defined(MEDIAINFO_RIFF_YES) Parser.push_back(new File_Riff()); #endif #if defined(MEDIAINFO_RM_YES) Parser.push_back(new File_Rm()); #endif #if defined(MEDIAINFO_SEQUENCEINFO_YES) Parser.push_back(new File_SequenceInfo()); #endif #if defined(MEDIAINFO_SKM_YES) Parser.push_back(new File_Skm()); #endif #if defined(MEDIAINFO_SWF_YES) Parser.push_back(new File_Swf()); #endif #if defined(MEDIAINFO_WM_YES) Parser.push_back(new File_Wm()); #endif #if defined(MEDIAINFO_XDCAM_YES) Parser.push_back(new File_Xdcam_Clip()); #endif // Video #if defined(MEDIAINFO_AVC_YES) Parser.push_back(new File_Avc()); #endif #if defined(MEDIAINFO_HEVC_YES) Parser.push_back(new File_Hevc()); #endif #if defined(MEDIAINFO_AVSV_YES) Parser.push_back(new File_AvsV()); #endif #if defined(MEDIAINFO_DIRAC_YES) Parser.push_back(new File_Dirac()); #endif #if defined(MEDIAINFO_FLIC_YES) Parser.push_back(new File_Flic()); #endif #if defined(MEDIAINFO_H263_YES) Parser.push_back(new File_H263()); #endif #if defined(MEDIAINFO_MPEG4V_YES) Parser.push_back(new File_Mpeg4v()); #endif #if defined(MEDIAINFO_MPEGV_YES) Parser.push_back(new File_Mpegv()); #endif #if defined(MEDIAINFO_VC1_YES) Parser.push_back(new File_Vc1()); #endif #if defined(MEDIAINFO_VC3_YES) Parser.push_back(new File_Vc3()); #endif #if defined(MEDIAINFO_Y4M_YES) Parser.push_back(new File_Y4m()); #endif // Audio #if defined(MEDIAINFO_AAC_YES) {File_Aac* Temp=new File_Aac(); Temp->Mode=File_Aac::Mode_ADIF; Parser.push_back(Temp);} #endif #if defined(MEDIAINFO_AAC_YES) {File_Aac* Temp=new File_Aac(); Temp->Mode=File_Aac::Mode_ADTS; Parser.push_back(Temp);} #endif #if defined(MEDIAINFO_AC3_YES) Parser.push_back(new File_Ac3()); #endif #if defined(MEDIAINFO_SMPTEST0337_YES) Parser.push_back(new File_SmpteSt0337()); #endif #if defined(MEDIAINFO_ALS_YES) Parser.push_back(new File_Als()); #endif #if defined(MEDIAINFO_AMR_YES) Parser.push_back(new File_Amr()); #endif #if defined(MEDIAINFO_AMV_YES) Parser.push_back(new File_Amv()); #endif #if defined(MEDIAINFO_APE_YES) Parser.push_back(new File_Ape()); #endif #if defined(MEDIAINFO_AU_YES) Parser.push_back(new File_Au()); #endif #if defined(MEDIAINFO_CAF_YES) Parser.push_back(new File_Caf()); #endif #if defined(MEDIAINFO_DTS_YES) Parser.push_back(new File_Dts()); #endif // Too many false-positives // #if defined(MEDIAINFO_DOLBYE_YES) // Parser.push_back(new File_DolbyE()); // #endif #if defined(MEDIAINFO_FLAC_YES) Parser.push_back(new File_Flac()); #endif #if defined(MEDIAINFO_IT_YES) Parser.push_back(new File_ImpulseTracker()); #endif #if defined(MEDIAINFO_LA_YES) Parser.push_back(new File_La()); #endif #if defined(MEDIAINFO_MIDI_YES) Parser.push_back(new File_Midi()); #endif #if defined(MEDIAINFO_MOD_YES) Parser.push_back(new File_Module()); #endif #if defined(MEDIAINFO_MPC_YES) Parser.push_back(new File_Mpc()); #endif #if defined(MEDIAINFO_MPCSV8_YES) Parser.push_back(new File_MpcSv8()); #endif #if defined(MEDIAINFO_MPEGA_YES) Parser.push_back(new File_Mpega()); #endif #if defined(MEDIAINFO_OPENMG_YES) Parser.push_back(new File_OpenMG()); #endif #if defined(MEDIAINFO_RKAU_YES) Parser.push_back(new File_Rkau()); #endif #if defined(MEDIAINFO_S3M_YES) Parser.push_back(new File_ScreamTracker3()); #endif #if defined(MEDIAINFO_TAK_YES) Parser.push_back(new File_Tak()); #endif #if defined(MEDIAINFO_TTA_YES) Parser.push_back(new File_Tta()); #endif #if defined(MEDIAINFO_TWINVQ_YES) Parser.push_back(new File_TwinVQ()); #endif #if defined(MEDIAINFO_WVPK_YES) Parser.push_back(new File_Wvpk()); #endif #if defined(MEDIAINFO_XM_YES) Parser.push_back(new File_ExtendedModule()); #endif // Text // Too many false-positives // #if defined(MEDIAINFO_EIA608_YES) // Parser.push_back(new File_Eia608()); // #endif #if defined(MEDIAINFO_N19_YES) Parser.push_back(new File_N19()); #endif #if defined(MEDIAINFO_PDF_YES) Parser.push_back(new File_Pdf()); #endif #if defined(MEDIAINFO_SCC_YES) Parser.push_back(new File_Scc()); #endif #if defined(MEDIAINFO_SUBRIP_YES) Parser.push_back(new File_SubRip()); #endif #if defined(MEDIAINFO_TTML_YES) Parser.push_back(new File_Ttml()); #endif #if defined(MEDIAINFO_OTHERTEXT_YES) Parser.push_back(new File_OtherText()); #endif // Image #if defined(MEDIAINFO_ARRIRAW_YES) Parser.push_back(new File_ArriRaw()); #endif #if defined(MEDIAINFO_BMP_YES) Parser.push_back(new File_Bmp()); #endif #if defined(MEDIAINFO_BPG_YES) Parser.push_back(new File_Bpg()); #endif #if defined(MEDIAINFO_DDS_YES) Parser.push_back(new File_Dds()); #endif #if defined(MEDIAINFO_DPX_YES) Parser.push_back(new File_Dpx()); #endif #if defined(MEDIAINFO_EXR_YES) Parser.push_back(new File_Exr()); #endif #if defined(MEDIAINFO_GIF_YES) Parser.push_back(new File_Gif()); #endif #if defined(MEDIAINFO_ICO_YES) Parser.push_back(new File_Ico()); #endif #if defined(MEDIAINFO_JPEG_YES) Parser.push_back(new File_Jpeg()); #endif #if defined(MEDIAINFO_PCX_YES) Parser.push_back(new File_Pcx()); #endif #if defined(MEDIAINFO_PNG_YES) Parser.push_back(new File_Png()); #endif #if defined(MEDIAINFO_PSD_YES) Parser.push_back(new File_Psd()); #endif #if defined(MEDIAINFO_TIFF_YES) Parser.push_back(new File_Tiff()); #endif #if defined(MEDIAINFO_TGA_YES) Parser.push_back(new File_Tga()); #endif // Archive #if defined(MEDIAINFO_7Z_YES) Parser.push_back(new File_7z()); #endif #if defined(MEDIAINFO_ACE_YES) Parser.push_back(new File_Ace()); #endif #if defined(MEDIAINFO_BZIP2_YES) Parser.push_back(new File_Bzip2()); #endif #if defined(MEDIAINFO_ELF_YES) Parser.push_back(new File_Elf()); #endif #if defined(MEDIAINFO_GZIP_YES) Parser.push_back(new File_Gzip()); #endif #if defined(MEDIAINFO_ISO9660_YES) Parser.push_back(new File_Iso9660()); #endif #if defined(MEDIAINFO_MZ_YES) Parser.push_back(new File_Mz()); #endif #if defined(MEDIAINFO_RAR_YES) Parser.push_back(new File_Rar()); #endif #if defined(MEDIAINFO_TAR_YES) Parser.push_back(new File_Tar()); #endif #if defined(MEDIAINFO_ZIP_YES) Parser.push_back(new File_Zip()); #endif // Other #if defined(MEDIAINFO_OTHER_YES) Parser.push_back(new File_Other()); #endif } //--------------------------------------------------------------------------- File__MultipleParsing::~File__MultipleParsing() { for (size_t Pos=0; PosOpen_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; PosInit(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; PosOpen_Buffer_Unsynch(); } //--------------------------------------------------------------------------- void File__MultipleParsing::Read_Buffer_Continue() { //Parsing for (size_t Pos=0; PosOpen_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_PosStatus[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 MediaInfoLib/Source/MediaInfo/MediaInfo_Config.h0000664000000000000000000003675412652076434020454 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Global configuration of MediaInfo // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_ConfigH #define MediaInfo_ConfigH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 using namespace ZenLib; using std::vector; using std::string; using std::map; using std::make_pair; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class MediaInfo_Config //*************************************************************************** class MediaInfo_Config { public : //Constructor/Destructor MediaInfo_Config() {} 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 Legacy_Set (bool NewValue); bool Legacy_Get (); void LegacyStreamDisplay_Set (bool Value); bool LegacyStreamDisplay_Get (); void SkipBinaryData_Set (bool Value); bool SkipBinaryData_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 Compat_Set (int64u NewValue); int64u Compat_Get (); void Trace_TimeSection_OnlyFirstOccurrence_Set (bool Value); bool Trace_TimeSection_OnlyFirstOccurrence_Get (); enum trace_Format { Trace_Format_Tree, Trace_Format_CSV, Trace_Format_XML, }; 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); 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 Iso639_Translate (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 (bool Complete=false); 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 (); #if MEDIAINFO_ADVANCED void VariableGopDetection_Occurences_Set (int64u Value); int64u VariableGopDetection_Occurences_Get (); void VariableGopDetection_GiveUp_Set (bool Value); bool VariableGopDetection_GiveUp_Get (); void InitDataNotRepeated_Occurences_Set (int64u Value); int64u InitDataNotRepeated_Occurences_Get (); void InitDataNotRepeated_GiveUp_Set (bool Value); bool InitDataNotRepeated_GiveUp_Get (); #endif //MEDIAINFO_ADVANCED 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 (); #if MEDIAINFO_ADVANCED void MpegTs_VbrDetection_Delta_Set (float64 Value); float64 MpegTs_VbrDetection_Delta_Get (); void MpegTs_VbrDetection_Occurences_Set (int64u Value); int64u MpegTs_VbrDetection_Occurences_Get (); void MpegTs_VbrDetection_GiveUp_Set (bool Value); bool MpegTs_VbrDetection_GiveUp_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED Ztring MAXML_StreamKinds_Get (); Ztring MAXML_Fields_Get (const Ztring &StreamKind); #endif //MEDIAINFO_ADVANCED 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));} #else //MEDIAINFO_EVENTS inline void Log_Send(int8u Type, int8u Severity, int32u MessageCode, const Ztring &Message) {} inline void Log_Send(int8u Type, int8u Severity, int32u MessageCode, const char* 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 FormatDetection_MaximumOffset; #if MEDIAINFO_ADVANCED int64u VariableGopDetection_Occurences; bool VariableGopDetection_GiveUp; int64u InitDataNotRepeated_Occurences; bool InitDataNotRepeated_GiveUp; #endif //MEDIAINFO_ADVANCED int64u MpegTs_MaximumOffset; int64u MpegTs_MaximumScanDuration; bool MpegTs_ForceStreamDisplay; #if MEDIAINFO_ADVANCED float64 MpegTs_VbrDetection_Delta; int64u MpegTs_VbrDetection_Occurences; bool MpegTs_VbrDetection_GiveUp; #endif //MEDIAINFO_ADVANCED 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; int64u Compat; bool Trace_TimeSection_OnlyFirstOccurrence; std::bitset<32> Trace_Layers; //0-7: Container, 8: Stream std::map Trace_Modificators; //If we want to add/remove some details bool Language_Raw; bool ReadByHuman; bool Legacy; bool LegacyStreamDisplay; bool SkipBinaryData; 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", "Other", "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 > 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) //Constructor MediaInfo_Config (const MediaInfo_Config&); // Prevent copy-construction MediaInfo_Config& operator=(const MediaInfo_Config&); // Prevent assignment }; extern MediaInfo_Config Config; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File__Analyze_Streams_Finish.cpp0000664000000000000000000016760312652076434023364 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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; #if MEDIAINFO_ADVANCED //Default frame rate if (Count_Get(Stream_Video)==1 && Retrieve(Stream_Video, 0, Video_FrameRate).empty() && Config->File_DefaultFrameRate_Get()) Fill(Stream_Video, 0, Video_FrameRate, Config->File_DefaultFrameRate_Get()); #endif //MEDIAINFO_ADVANCED //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_IBIUSAGE 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_IBIUSAGE } Streams_Finish_StreamOnly(); Streams_Finish_StreamOnly(); Streams_Finish_InterStreams(); Streams_Finish_StreamOnly(); Streams_Finish_InterStreams(); Streams_Finish_StreamOnly(); Streams_Finish_InterStreams(); Streams_Finish_StreamOnly(); if (!IsSub && !Config->File_IsReferenced_Get() && MediaInfoLib::Config.ReadByHuman_Get()) Streams_Finish_HumanReadable(); } //--------------------------------------------------------------------------- void File__Analyze::TestContinuousFileNames(size_t CountOfFiles, Ztring FileExtension, bool SkipComputeDelay) { if (IsSub || !Config->File_TestContinuousFileNames_Get()) return; size_t Pos=Config->File_Names.size(); if (!Pos) return; //Trying to detect continuous file names (e.g. video stream as an image or HLS) size_t Pos_Base = (size_t)-1; bool AlreadyPresent=Config->File_Names.size()==1?true:false; FileName FileToTest(Config->File_Names.Read(Config->File_Names.size()-1)); Ztring FileToTest_Name=FileToTest.Name_Get(); Ztring FileToTest_Name_After=FileToTest_Name; size_t FileNameToTest_End=FileToTest_Name.size(); while (FileNameToTest_End && !(FileToTest_Name[FileNameToTest_End-1]>=__T('0') && FileToTest_Name[FileNameToTest_End-1]<=__T('9'))) FileNameToTest_End--; size_t FileNameToTest_Pos=FileNameToTest_End; 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() && FileNameToTest_Pos!=FileNameToTest_End) { size_t Numbers_Size=FileNameToTest_End-FileNameToTest_Pos; int64u Pos=Ztring(FileToTest_Name.substr(FileNameToTest_Pos)).To_int64u(); FileToTest_Name.resize(FileNameToTest_Pos); FileToTest_Name_After.erase(0, FileToTest_Name.size()+Numbers_Size); /* for (;;) { Pos++; Ztring Pos_Ztring; Pos_Ztring.From_Number(Pos); if (Numbers_Size>Pos_Ztring.size()) Pos_Ztring.insert(0, Numbers_Size-Pos_Ztring.size(), __T('0')); Ztring Next=FileToTest.Path_Get()+PathSeparator+FileToTest_Name+Pos_Ztring+__T('.')+(FileExtension.empty()?FileToTest.Extension_Get():FileExtension); if (!File::Exists(Next)) break; Config->File_Names.push_back(Next); } */ //Detecting with a smarter algo (but missing frames are not detected) Ztring FileToTest_Name_Begin=FileToTest.Path_Get()+PathSeparator+FileToTest_Name; Ztring FileToTest_Name_End=FileToTest_Name_After+__T('.')+(FileExtension.empty()?FileToTest.Extension_Get():FileExtension); Pos_Base = (size_t)Pos; size_t Pos_Add_Max = 1; #if MEDIAINFO_ADVANCED bool File_IgnoreSequenceFileSize=Config->File_IgnoreSequenceFilesCount_Get(); //TODO: double check if it is expected size_t SequenceFileSkipFrames=Config->File_SequenceFilesSkipFrames_Get(); if (SequenceFileSkipFrames) { for (;;) { size_t Pos_Add_Max_Old=Pos_Add_Max; for (size_t TempPos=Pos_Add_Max; TempPos<=Pos_Add_Max+SequenceFileSkipFrames; TempPos++) { Ztring Pos_Ztring; Pos_Ztring.From_Number(Pos_Base+TempPos); if (Numbers_Size>Pos_Ztring.size()) Pos_Ztring.insert(0, Numbers_Size-Pos_Ztring.size(), __T('0')); Ztring Next=FileToTest_Name_Begin+Pos_Ztring+FileToTest_Name_End; if (File::Exists(Next)) { Pos_Add_Max=TempPos+1; break; } } if (Pos_Add_Max==Pos_Add_Max_Old) break; } } else { #endif //MEDIAINFO_ADVANCED for (;;) { Ztring Pos_Ztring; Pos_Ztring.From_Number(Pos_Base+Pos_Add_Max); if (Numbers_Size>Pos_Ztring.size()) Pos_Ztring.insert(0, Numbers_Size-Pos_Ztring.size(), __T('0')); Ztring Next=FileToTest_Name_Begin+Pos_Ztring+FileToTest_Name_End; if (!File::Exists(Next)) break; Pos_Add_Max<<=1; #if MEDIAINFO_ADVANCED if (File_IgnoreSequenceFileSize && Pos_Add_Max>=CountOfFiles) break; #endif //MEDIAINFO_ADVANCED } size_t Pos_Add_Min = Pos_Add_Max >> 1; while (Pos_Add_Min+1> 1); Ztring Pos_Ztring; Pos_Ztring.From_Number(Pos_Base+Pos_Add_Middle); if (Numbers_Size>Pos_Ztring.size()) Pos_Ztring.insert(0, Numbers_Size-Pos_Ztring.size(), __T('0')); Ztring Next=FileToTest_Name_Begin+Pos_Ztring+FileToTest_Name_End; if (File::Exists(Next)) Pos_Add_Min=Pos_Add_Middle; else Pos_Add_Max=Pos_Add_Middle; } #if MEDIAINFO_ADVANCED } //SequenceFileSkipFrames #endif //MEDIAINFO_ADVANCED size_t Pos_Max = Pos_Base + Pos_Add_Max; Config->File_Names.reserve(Pos_Add_Max); for (Pos=Pos_Base+1; PosPos_Ztring.size()) Pos_Ztring.insert(0, Numbers_Size-Pos_Ztring.size(), __T('0')); Config->File_Names.push_back(FileToTest_Name_Begin+Pos_Ztring+FileToTest_Name_End); } if (!Config->File_IsReferenced_Get() && Config->File_Names.size()File_Names.resize(1); //Removing files, wrong detection } if (Config->File_Names.size()==Pos) return; Config->File_IsImageSequence=true; Frame_Count_NotParsedIncluded=Pos_Base; #if MEDIAINFO_DEMUX float64 Demux_Rate=Config->Demux_Rate_Get(); if (!Demux_Rate) Demux_Rate=24; if (!SkipComputeDelay) Fill(Stream_Video, 0, Video_Delay, float64_int64s(Frame_Count_NotParsedIncluded*1000/Demux_Rate)); #endif //MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED if (!Config->File_IgnoreSequenceFileSize_Get() || Config->File_Names.size()<=1) #endif //MEDIAINFO_ADVANCED { for (; PosFile_Names.size(); Pos++) { int64u Size=File::Size_Get(Config->File_Names[Pos]); Config->File_Sizes.push_back(Size); Config->File_Size+=Size; } } #if MEDIAINFO_ADVANCED else { Config->File_Size=(int64u)-1; File_Size=(int64u)-1; Clear(Stream_General, 0, General_FileSize); } #endif //MEDIAINFO_ADVANCED File_Size=Config->File_Size; Element[0].Next=File_Size; #if MEDIAINFO_ADVANCED if (!Config->File_IgnoreSequenceFileSize_Get() || Config->File_Names.size()<=1) #endif //MEDIAINFO_ADVANCED Fill (Stream_General, 0, General_FileSize, File_Size, 10, true); #if MEDIAINFO_ADVANCED if (!Config->File_IgnoreSequenceFilesCount_Get()) #endif //MEDIAINFO_ADVANCED { Fill (Stream_General, 0, General_CompleteName_Last, Config->File_Names[Config->File_Names.size()-1], true); Fill (Stream_General, 0, General_FolderName_Last, FileName::Path_Get(Config->File_Names[Config->File_Names.size()-1]), true); Fill (Stream_General, 0, General_FileName_Last, FileName::Name_Get(Config->File_Names[Config->File_Names.size()-1]), true); Fill (Stream_General, 0, General_FileExtension_Last, FileName::Extension_Get(Config->File_Names[Config->File_Names.size()-1]), true); } #if MEDIAINFO_ADVANCED if (Config->File_Source_List_Get()) { Ztring SourcePath=FileName::Path_Get(Retrieve(Stream_General, 0, General_CompleteName)); size_t SourcePath_Size=SourcePath.size()+1; //Path size + path separator size for (size_t Pos=0; PosFile_Names.size(); Pos++) { Ztring Temp=Config->File_Names[Pos]; Temp.erase(0, SourcePath_Size); Fill(Stream_General, 0, "Source_List", Temp); } (*Stream_More)[Stream_General][0](Ztring().From_Local("Source_List"), Info_Options)=__T("N NT"); } #endif //MEDIAINFO_ADVANCED } //--------------------------------------------------------------------------- void File__Analyze::Streams_Finish_StreamOnly() { //Generic for (size_t StreamKind=Stream_General; StreamKind0 && StreamSize>0) Fill(StreamKind, Pos, "BitRate", StreamSize*8*1000/Duration, 0); } //BitRate_Encoded from Duration and StreamSize_Encoded if (StreamKind!=Stream_General && StreamKind!=Stream_Other && 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_Other && 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_Other && 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); } //FrameRate from FrameCount and Duration if (Retrieve(Stream_Video, Pos, Video_FrameRate).empty()) { int64u FrameCount=Retrieve(Stream_Video, Pos, Video_FrameCount).To_int64u(); float64 Duration=Retrieve(Stream_Video, Pos, Video_Duration).To_float64()/1000; if (FrameCount && Duration) Fill(Stream_Video, Pos, Video_FrameRate, FrameCount/Duration, 3); } //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") && Retrieve(Stream_Video, Pos, Video_FrameRate)==__T("25.000")) 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_FrameRate)==__T("29.970")) 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")) && Retrieve(Stream_Video, Pos, Video_FrameRate)==__T("25.000")) 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")) && Retrieve(Stream_Video, Pos, Video_FrameRate)==__T("29.970")) 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, "Progressive"); //Useless chroma subsampling if (Retrieve(Stream_Video, Pos, Video_ColorSpace)==__T("RGB") && Retrieve(Stream_Video, Pos, Video_ChromaSubsampling)==__T("4:4:4")) Clear(Stream_Video, Pos, Video_ChromaSubsampling); //Commercial name #if defined(MEDIAINFO_VC3_YES) if (Retrieve(Stream_Video, Pos, Video_Format_Commercial_IfAny).empty() && Retrieve(Stream_Video, Pos, Video_Format)==__T("VC-3")) { //http://www.avid.com/static/resources/US/documents/dnxhd.pdf int64u Height=Retrieve(Stream_Video, Pos, Video_Height).To_int64u(); int64u BitRate=float64_int64s(Retrieve(Stream_Video, Pos, Video_BitRate).To_float64()/1000000); int64u FrameRate=float64_int64s(Retrieve(Stream_Video, Pos, Video_FrameRate).To_float64()); int64u BitRate_Final=0; if (Height>=900 && Height<=1300) { if (FrameRate==60) { if (BitRate>=420 && BitRate<440) //440 BitRate_Final=440; if (BitRate>=271 && BitRate<311) //291 BitRate_Final=290; if (BitRate>=80 && BitRate<100) //90 BitRate_Final=90; } if (FrameRate==50) { if (BitRate>=347 && BitRate<387) //367 BitRate_Final=365; if (BitRate>=222 && BitRate<262) //242 BitRate_Final=240; if (BitRate>=65 && BitRate<85) //75 BitRate_Final=75; } if (FrameRate==30) { if (BitRate>=420 && BitRate<440) //440 BitRate_Final=440; if (BitRate>=200 && BitRate<240) //220 BitRate_Final=220; if (BitRate>=130 && BitRate<160) //145 BitRate_Final=145; if (BitRate>=90 && BitRate<110) //100 BitRate_Final=100; if (BitRate>=40 && BitRate<50) //45 BitRate_Final=45; } if (FrameRate==25) { if (BitRate>=347 && BitRate<387) //367 BitRate_Final=365; if (BitRate>=164 && BitRate<204) //184 BitRate_Final=185; if (BitRate>=111 && BitRate<131) //121 BitRate_Final=120; if (BitRate>=74 && BitRate<94) //84 BitRate_Final=85; if (BitRate>=31 && BitRate<41) //36 BitRate_Final=36; } if (FrameRate==24) { if (BitRate>=332 && BitRate<372) //352 BitRate_Final=350; if (BitRate>=156 && BitRate<196) //176 BitRate_Final=175; if (BitRate>=105 && BitRate<125) //116 BitRate_Final=116; if (BitRate>=70 && BitRate<90) //80 BitRate_Final=80; if (BitRate>=31 && BitRate<41) //36 BitRate_Final=36; } } if (Height>=600 && Height<=800) { if (FrameRate==60) { if (BitRate>=200 && BitRate<240) //220 BitRate_Final=220; if (BitRate>=130 && BitRate<160) //145 BitRate_Final=145; if (BitRate>=90 && BitRate<110) //110 BitRate_Final=100; } if (FrameRate==50) { if (BitRate>=155 && BitRate<195) //175 BitRate_Final=175; if (BitRate>=105 && BitRate<125) //115 BitRate_Final=115; if (BitRate>=75 && BitRate<95) //85 BitRate_Final=85; } if (FrameRate==30) { if (BitRate>=100 && BitRate<120) //110 BitRate_Final=110; if (BitRate>=62 && BitRate<82) //72 BitRate_Final=75; if (BitRate>=44 && BitRate<56) //51 BitRate_Final=50; } if (FrameRate==25) { if (BitRate>=82 && BitRate<102) //92 BitRate_Final=90; if (BitRate>=55 && BitRate<65) //60 BitRate_Final=60; if (BitRate>=38 && BitRate<48) //43 BitRate_Final=45; } if (FrameRate==24) { if (BitRate>=78 && BitRate<98) //88 BitRate_Final=90; if (BitRate>=53 && BitRate<63) //58 BitRate_Final=60; if (BitRate>=36 && BitRate<46) //41 BitRate_Final=41; } } if (BitRate_Final) { int64u BitDepth=Retrieve(Stream_Video, Pos, Video_BitDepth).To_int64u(); if (BitDepth==8 || BitDepth==10) Fill(Stream_Video, Pos, Video_Format_Commercial_IfAny, __T("DNxHD ")+Ztring::ToZtring(BitRate_Final)+(BitDepth==10?__T("x"):__T(""))); //"x"=10-bit } } #endif //defined(MEDIAINFO_VC3_YES) } //--------------------------------------------------------------------------- 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); } //FrameRate same as SampleRate if (Retrieve(Stream_Audio, Pos, Audio_SamplingRate).To_float64() == Retrieve(Stream_Audio, Pos, Audio_FrameRate).To_float64()) Clear(Stream_Audio, Pos, Audio_FrameRate); //SamplingRate if (Retrieve(Stream_Audio, Pos, Audio_SamplingRate).empty()) { float64 BitDepth=Retrieve(Stream_Audio, Pos, Audio_BitDepth).To_float64(); float64 Channels=Retrieve(Stream_Audio, Pos, Audio_Channel_s_).To_float64(); float64 BitRate=Retrieve(Stream_Audio, Pos, Audio_BitRate).To_float64(); if (BitDepth && Channels && BitRate) Fill(Stream_Audio, Pos, Audio_SamplingRate, BitRate/Channels/BitDepth, 0); } //SamplesPerFrames if (Retrieve(Stream_Audio, Pos, Audio_SamplesPerFrame).empty()) { float64 FrameRate=Retrieve(Stream_Audio, Pos, Audio_FrameRate).To_float64(); float64 SamplingRate=0; ZtringList SamplingRates; SamplingRates.Separator_Set(0, " / "); SamplingRates.Write(Retrieve(Stream_Audio, Pos, Audio_SamplingRate)); for (size_t i=0; i1601 && SamplesPerFrameF<1602) SamplesPerFrame = __T("1601.6"); // Usually this is 29.970 fps PCM. TODO: check if it is OK in all cases else if (SamplesPerFrameF>800 && SamplesPerFrameF<801) SamplesPerFrame = __T("800.8"); // Usually this is 59.940 fps PCM. TODO: check if it is OK in all cases else SamplesPerFrame.From_Number(SamplesPerFrameF, 0); Fill(Stream_Audio, Pos, Audio_SamplesPerFrame, SamplesPerFrame); } } //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 Pos) { //FrameRate from FrameCount and Duration if (Retrieve(Stream_Text, Pos, Text_FrameRate).empty()) { int64u FrameCount=Retrieve(Stream_Text, Pos, Text_FrameCount).To_int64u(); float64 Duration=Retrieve(Stream_Text, Pos, Text_Duration).To_float64()/1000; if (FrameCount && Duration) Fill(Stream_Text, Pos, Text_FrameRate, FrameCount/Duration, 3); } } //--------------------------------------------------------------------------- void File__Analyze::Streams_Finish_StreamOnly_Other(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; StreamKindDuration) 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; StreamKind0 && StreamSize_Total4 && 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; } if (Get(Stream_General, 0, __T("Format"))==__T("MXF")) { GeneralBitRate_Ratio=1; GeneralBitRate_Minus=1000; VideoBitRate_Ratio =1.00; VideoBitRate_Minus =1000; AudioBitRate_Ratio =1.00; AudioBitRate_Minus =1000; TextBitRate_Ratio =1.00; TextBitRate_Minus =1000; } //Testing float64 VideoBitRate=Retrieve(Stream_General, 0, General_OverallBitRate).To_float64()*GeneralBitRate_Ratio-GeneralBitRate_Minus; bool VideobitRateIsValid=true; for (size_t Pos=0; Pos=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_Pos0 || 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 #include //--------------------------------------------------------------------------- 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_Other, ///< 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_ShowInXml, ///< 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; ///< Unicode/Ansi independant char #undef __T #define __T(__x) L ## __x #else typedef char Char; ///< Unicode/Ansi independant char #undef __T #define __T(__x) __x #endif typedef std::basic_string String; ///< Unicode/Ansi independant string typedef std::basic_stringstream StringStream; ///< Unicode/Ansi independant stringstream typedef std::basic_istringstream tiStringStream; ///< Unicode/Ansi independant istringstream typedef std::basic_ostringstream toStringStream; ///< Unicode/Ansi independant ostringstream //--------------------------------------------------------------------------- } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/0000775000000000000000000000000012652076434016425 5ustar rootrootMediaInfoLib/Source/MediaInfo/Export/Export_Mpeg7.h0000664000000000000000000000201712652076434021116 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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 MediaInfoLib/Source/MediaInfo/Export/Export_Fims.cpp0000664000000000000000000025521512652076434021402 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_FIMS_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Export/Export_Fims.h" #include "MediaInfo/File__Analyse_Automatic.h" #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern MediaInfo_Config Config; //--------------------------------------------------------------------------- //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- Ztring Fims_XML_Encode (const Ztring& Data) { Ztring Result; wstring::size_type Pos; for (Pos=0; Pos'): Result+=__T("≶"); break; default: Result+=Data[Pos]; } } return Result; } //--------------------------------------------------------------------------- int32u Fims_VideoCompressionCodeCS_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 Fims_VideoCompressionCodeCS_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); } } //--------------------------------------------------------------------------- int32u Fims_AudioCompressionCodeCS_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 40200; if (Format==__T("E-AC-3")) return 40300; if (Format==__T("Dolby E")) return 40600; if (Format==__T("DTS")) return 50000; if (Format==__T("MPEG Audio")) { if (Version.find(__T("1"))!=string::npos) { if (Profile.find(__T("1"))!=string::npos) return 70100; if (Profile.find(__T("2"))!=string::npos) return 70200; if (Profile.find(__T("3"))!=string::npos) return 70300; return 70000; } if (Version.find(__T("2"))!=string::npos) { if (Profile.find(__T("1"))!=string::npos) return 90100; if (Profile.find(__T("2"))!=string::npos) return 90200; if (Profile.find(__T("3"))!=string::npos) return 90300; return 90000; } return 0; } if (Format==__T("PCM")) return 110000; return 0; } Ztring Fims_AudioCompressionCodeCS_Name(int32u termID, MediaInfo_Internal &MI, size_t StreamPos) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number { switch (termID/10000) { case 4 : switch ((termID%10000)/100) { case 2 : return __T("AC3"); case 3 : return __T("E-AC3"); case 6 : return __T("Dolby E"); default: return __T("Dolby"); } case 5 : return __T("DTS"); case 7 : 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 9 : switch ((termID%10000)/100) { case 1 : return __T("MPEG-2 Audio Layer I"); case 2 : return __T("MPEG-2 Audio Layer II"); case 3 : return __T("MPEG-2 Audio Layer III"); default: return __T("MPEG-2 Audio"); } default: return MI.Get(Stream_Audio, StreamPos, Video_Format); } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Export_Fims::Export_Fims () { } //--------------------------------------------------------------------------- Export_Fims::~Export_Fims () { } //*************************************************************************** // Input //*************************************************************************** //--------------------------------------------------------------------------- Ztring Fims_Transform_Video(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, Export_Fims::version Version) { size_t As11_UkDpp_Pos=(size_t)-1; for (size_t StreamPos_Temp=0; StreamPos_Temp"); if (!MI.Get(Stream_Video, StreamPos, Video_Format_Version).empty()) ToReturn+=__T(" "); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); //flag_3D if (!MI.Get(Stream_Video, StreamPos, Video_MultiView_Count).empty()) ToReturn+=__T("\t\t\t\t\ttrue\n"); //technicalAttributeString - ActiveFormatDescription if (!MI.Get(Stream_Video, StreamPos, Video_ActiveFormatDescription).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_ActiveFormatDescription)+__T("\n"); //technicalAttributeString - Standard if (!MI.Get(Stream_Video, StreamPos, Video_Standard).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Standard)+__T("\n"); } //technicalAttributeString - ColorSpace if (!MI.Get(Stream_Video, StreamPos, Video_ColorSpace).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_ColorSpace)+__T("\n"); } //technicalAttributeString - ChromaSubsampling if (!MI.Get(Stream_Video, StreamPos, Video_ChromaSubsampling).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_ChromaSubsampling)+__T("\n"); } //technicalAttributeString - colour_primaries if (!MI.Get(Stream_Video, StreamPos, __T("colour_primaries")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("colour_primaries"))+__T("\n"); } //technicalAttributeString - transfer_characteristics if (!MI.Get(Stream_Video, StreamPos, __T("transfer_characteristics")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("transfer_characteristics"))+__T("\n"); } //technicalAttributeString - matrix_coefficients if (!MI.Get(Stream_Video, StreamPos, __T("matrix_coefficients")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("matrix_coefficients"))+__T("\n"); } //technicalAttributeString - colour_range if (!MI.Get(Stream_Video, StreamPos, __T("colour_range")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("colour_range"))+__T("\n"); } //technicalAttributeString - StreamSize if (!MI.Get(Stream_Video, StreamPos, Video_StreamSize).empty()) { ToReturn+=__T("\t\t\t\t\t=Export_Fims::Version_1_2?Ztring(__T(" unit=\"byte\"")):Ztring())+__T(">")+MI.Get(Stream_Video, StreamPos, Video_StreamSize)+__T("")+(Version")):Ztring())+__T("\n"); } //technicalAttributeString - BitDepth if (!MI.Get(Stream_Video, StreamPos, Video_BitDepth).empty()) { ToReturn+=__T("\t\t\t\t\t=Export_Fims::Version_1_2?Ztring(__T(" unit=\"bit\"")):Ztring())+__T(">")+MI.Get(Stream_Video, StreamPos, Video_BitDepth)+__T("")+(Version")):Ztring())+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaManufacturer")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaManufacturer"))+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaVersion")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaVersion"))+__T("\n"); } //technicalAttributeBoolean - Format_Settings_CABAC if (MI.Get(Stream_Video, StreamPos, Video_Format)==__T("AVC") && !MI.Get(Stream_Video, StreamPos, Video_Format_Settings_CABAC).empty()) { ToReturn+=__T("\t\t\t\t\t")+Ztring(MI.Get(Stream_Video, StreamPos, Video_Format_Settings_CABAC)==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //technicalAttributeBoolean - Format_Settings_MBAFF if (MI.Get(Stream_Video, StreamPos, Video_Format)==__T("AVC") && !MI.Get(Stream_Video, StreamPos, Video_ScanType).empty()) { ToReturn+=__T("\t\t\t\t\t")+Ztring(MI.Get(Stream_Video, StreamPos, Video_ScanType)==__T("MBAFF")?__T("true"):__T("false"))+__T("\n"); } //technicalAttributeBoolean - FpaPass if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaPass")).empty()) { ToReturn+=__T("\t\t\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaPass"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //technicalAttributeString - VideoComments if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("VideoComments")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("VideoComments"))+__T("\n"); } //width if (!MI.Get(Stream_Video, StreamPos, Video_Width).empty()) { Ztring Width; if (!MI.Get(Stream_Video, StreamPos, Video_Width_Original).empty()) Width=MI.Get(Stream_Video, StreamPos, Video_Width_Original); else Width=MI.Get(Stream_Video, StreamPos, Video_Width); ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Width)+__T("\n"); } //height if (!MI.Get(Stream_Video, StreamPos, Video_Height).empty()) { Ztring Height; if (!MI.Get(Stream_Video, StreamPos, Video_Height_Original).empty()) Height=MI.Get(Stream_Video, StreamPos, Video_Height_Original); else Height=MI.Get(Stream_Video, StreamPos, Video_Height); ToReturn+=__T("\t\t\t\t\t")+Height+__T("\n"); } //frameRate if (!MI.Get(Stream_Video, StreamPos, Video_FrameRate).empty()) { Ztring FrameRateString=MI.Get(Stream_Video, StreamPos, Video_FrameRate); Ztring factorNumerator, factorDenominator; if (FrameRateString==__T("23.976")) { factorNumerator=__T("24000"); factorDenominator=__T("1001"); } if (FrameRateString==__T("29.970")) { factorNumerator=__T("30000"); factorDenominator=__T("1001"); } if (FrameRateString==__T("59.940")) { factorNumerator=__T("60000"); factorDenominator=__T("1001"); } if (factorNumerator.empty()) { factorNumerator=Ztring::ToZtring(FrameRateString.To_float64()*1000, 0); factorDenominator=__T("1000"); } ToReturn+=__T("\t\t\t\t\t")+Ztring::ToZtring(FrameRateString.To_float64(), 0); ToReturn+=__T("\n"); } //aspectRatio if (!MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio).empty()) { Ztring AspectRatioString=MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio_String); size_t AspectRatioString_Pos=AspectRatioString.find(__T(':')); Ztring factorNumerator, factorDenominator; if (AspectRatioString_Pos!=(size_t)-1) { factorNumerator=AspectRatioString.substr(0, AspectRatioString_Pos); factorDenominator=AspectRatioString.substr(AspectRatioString_Pos+1); } if (factorNumerator.empty()) { factorNumerator=Ztring::ToZtring(AspectRatioString.To_float64()*1000, 0); factorDenominator=__T("1000"); } ToReturn+=__T("\t\t\t\t\t")+Ztring::ToZtring(MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio).To_float64(), 0); ToReturn+=__T("\n"); } //videoEncoding //if (!MI.Get(Stream_Video, StreamPos, Video_Format_Profile).empty()) { int32u TermID=Fims_VideoCompressionCodeCS_termID(MI, StreamPos); Ztring typeLabel; Ztring TermID_String; if (TermID) { typeLabel=Fims_VideoCompressionCodeCS_Name(TermID, MI, StreamPos); TermID_String=Ztring::ToZtring(TermID/10000); if (TermID%10000) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring((TermID%10000)/100); if (TermID%100) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring(TermID%100); } } } else typeLabel=MI.Get(Stream_Video, StreamPos, Video_Format_Profile); ToReturn+=__T("\t\t\t\t\t\n"); if (!MI.Get(Stream_Video, StreamPos, Video_Format).empty()) ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Format)+__T("\n"); if (!MI.Get(Stream_Video, StreamPos, Video_CodecID).empty()) { ToReturn+=__T("\t\t\t\t\t\t\n"); } if (!MI.Get(Stream_Video, StreamPos, Video_Format_Commercial_IfAny).empty()) ToReturn+=__T("\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); } //videoTrack if (!MI.Get(Stream_Video, StreamPos, Video_ID).empty() || !MI.Get(Stream_Video, StreamPos, Video_Title).empty()) { ToReturn+=__T("\t\t\t\t\t"); if (!MI.Get(Stream_Video, StreamPos, Video_ID).empty()) ToReturn+=__T(" "); ToReturn+=__T("\n"); } //bitRate if (!MI.Get(Stream_Video, StreamPos, Video_BitRate).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_BitRate)+__T("\n"); //bitRateMax if (!MI.Get(Stream_Video, StreamPos, Video_BitRate_Maximum).empty()) ToReturn+=__T("\t\t\t\t\t \n"); //bitRateMode if (!MI.Get(Stream_Video, StreamPos, Video_BitRate_Mode).empty()) { Ztring bitRateMode=MI.Get(Stream_Video, StreamPos, Video_BitRate_Mode); if (bitRateMode==__T("CBR")) bitRateMode=__T("constant"); if (bitRateMode==__T("VBR")) bitRateMode=__T("variable"); ToReturn+=__T("\t\t\t\t\t")+bitRateMode+__T("\n"); } //lines if (!MI.Get(Stream_Video, StreamPos, Video_Height_Original).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Height_Original)+__T("\n"); //scanningFormat if (!MI.Get(Stream_Video, StreamPos, Video_ScanType).empty()) { Ztring ScanType=MI.Get(Stream_Video, StreamPos, Video_ScanType); if (ScanType==__T("MBAFF")) ScanType=__T("Interlaced"); ScanType.MakeLowerCase(); ToReturn+=__T("\t\t\t\t\t")+ScanType+__T("\n"); } //scanningOrder if (!MI.Get(Stream_Video, StreamPos, Video_ScanOrder).empty()) { Ztring ScanOrder=MI.Get(Stream_Video, StreamPos, Video_ScanOrder); if (ScanOrder==__T("TFF")) ScanOrder=__T("top"); if (ScanOrder==__T("BFF")) ScanOrder=__T("bottom"); if (ScanOrder.find(__T("Pulldown"))!=string::npos) ScanOrder=__T("pulldown"); ToReturn+=__T("\t\t\t\t\t")+ScanOrder+__T("\n"); } ToReturn+=__T("\t\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Fims_Transform_Audio(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, Export_Fims::version Version) { size_t As11_Core_Pos=(size_t)-1; size_t As11_UkDpp_Pos=(size_t)-1; for (size_t StreamPos_Temp=0; StreamPos_Temp"); if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Version).empty()) ToReturn+=__T(" "); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); //format - technicalAttributeString - ChannelPositions if (!MI.Get(Stream_Audio, StreamPos, Audio_ChannelPositions).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_ChannelPositions)+__T("\n"); } //format - technicalAttributeString - ChannelLayout if (!MI.Get(Stream_Audio, StreamPos, Audio_ChannelLayout).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_ChannelLayout)+__T("\n"); } //technicalAttributeString - Format_Settings_Endianness if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Endianness).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Endianness)+__T("\n"); } //technicalAttributeString - Format_Settings_Wrapping if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Wrapping).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Wrapping)+__T("\n"); } //technicalAttributeString - StreamSize if (!MI.Get(Stream_Audio, StreamPos, Audio_StreamSize).empty()) { ToReturn+=__T("\t\t\t\t\t=Export_Fims::Version_1_2?Ztring(__T(" unit=\"byte\"")):Ztring())+__T(">")+MI.Get(Stream_Audio, StreamPos, Audio_StreamSize)+__T("")+(Version")):Ztring())+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioComments")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioComments"))+__T("\n"); } //samplingRate if (!MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate)+__T("\n"); //audioEncoding //if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Profile).empty()) { int32u TermID=Fims_AudioCompressionCodeCS_termID(MI, StreamPos); Ztring typeLabel; Ztring TermID_String; if (TermID) { typeLabel=Fims_AudioCompressionCodeCS_Name(TermID, MI, StreamPos); TermID_String=Ztring::ToZtring(TermID/10000); if (TermID%10000) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring((TermID%10000)/100); if (TermID%100) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring(TermID%100); } } } else typeLabel=MI.Get(Stream_Audio, StreamPos, Audio_Format_Profile); ToReturn+=__T("\t\t\t\t\t\n"); if (!MI.Get(Stream_Audio, StreamPos, Audio_Format).empty()) ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Format)+__T("\n"); if (!MI.Get(Stream_Audio, StreamPos, Audio_CodecID).empty()) { ToReturn+=__T("\t\t\t\t\t\t\n"); } if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Commercial_IfAny).empty()) ToReturn+=__T("\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); } //audioTrackConfiguration if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("AudioTrackLayout")).empty()) { ToReturn+=__T("\t\t\t\t\t\n"); } //audioTrack if (!MI.Get(Stream_Audio, StreamPos, Audio_ID).empty() || !MI.Get(Stream_Audio, StreamPos, Audio_Title).empty() || !MI.Get(Stream_Audio, StreamPos, Audio_Language).empty()) { ToReturn+=__T("\t\t\t\t\t"); if (!MI.Get(Stream_Audio, StreamPos, Audio_ID).empty()) { Ztring ID=MI.Get(Stream_Audio, StreamPos, Audio_ID); ID.FindAndReplace(__T(" / "), __T("_")); ToReturn+=__T(" "); } ToReturn+=__T("\n"); } //channels if (!MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_)+__T("\n"); //bitRate if (!MI.Get(Stream_Audio, StreamPos, Audio_BitRate).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_BitRate)+__T("\n"); //bitRateMax if (!MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Maximum).empty()) ToReturn+=__T("\t\t\t\t\t<-- ")+MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Maximum)+__T(" -->\n"); //bitRateMode if (!MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Mode).empty()) { Ztring bitRateMode=MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Mode); if (bitRateMode==__T("CBR")) bitRateMode=__T("constant"); if (bitRateMode==__T("VBR")) bitRateMode=__T("variable"); ToReturn+=__T("\t\t\t\t\t")+bitRateMode+__T("\n"); } //sampleSize if (!MI.Get(Stream_Audio, StreamPos, Audio_BitDepth).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_BitDepth)+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Fims_Transform_Text(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos) { ToReturn+=__T("\t\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Fims_Transform_TimeCode(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, bool Is1_2) { if (Is1_2) ToReturn+=__T("\t\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Fims_Transform_Metadata(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, bool Is1_2) { if (Is1_2) ToReturn+=__T("\t\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Export_Fims::Transform(MediaInfo_Internal &MI, version Version) { //Current date/time is ISO format time_t Seconds=time(NULL); Ztring DateTime; DateTime.Date_From_Seconds_1970((int32u)Seconds); DateTime.FindAndReplace(__T("UTC "), __T("")); DateTime.FindAndReplace(__T(" "), __T("T")); Ztring Date=DateTime.substr(0, 10); Ztring Time=DateTime.substr(11, 8); size_t As11_Core_Pos=(size_t)-1; size_t As11_Segmentation_Pos=(size_t)-1; size_t As11_UkDpp_Pos=(size_t)-1; for (size_t StreamPos_Temp=0; StreamPos_Temp\n"); ToReturn+=__T("\n"); ToReturn+=__T("\n"); ToReturn+=__T("\n"); ToReturn+=__T("\n"); if (Version==Version_1_1) ToReturn+=__T("\n"); if (Version==Version_1_2) ToReturn+=__T("\n"); if (Version==Version_1_3) ToReturn+=__T("\n"); ToReturn+=__T("\t\n"); //bmContentFormats ToReturn+=__T("\t\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); //bmContentFormats - resourceCreationDate if (!MI.Get(Stream_General, 0, General_Encoded_Date).empty()) { Ztring DateTime=MI.Get(Stream_General, 0, General_Encoded_Date); DateTime.FindAndReplace(__T("UTC "), __T("")); DateTime.FindAndReplace(__T(" "), __T("T")); Ztring Date=DateTime.substr(0, 10); Ztring Time=DateTime.substr(11, 8); ToReturn+=__T("\t\t\t")+Date+__T('T')+Time+__T("Z\n"); } //bmContentFormats - dateModified if (!MI.Get(Stream_General, 0, General_Tagged_Date).empty()) { Ztring DateTime=MI.Get(Stream_General, 0, General_Tagged_Date); DateTime.FindAndReplace(__T("UTC "), __T("")); DateTime.FindAndReplace(__T(" "), __T("T")); Ztring Date=DateTime.substr(0, 10); Ztring Time=DateTime.substr(11, 8); ToReturn+=__T("\t\t\t")+Date+__T('T')+Time+__T("Z\n"); } //bmContentFormats - bmEssenceLocators if (!MI.Get(Stream_General, 0, General_CompleteName).empty()) { ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t")+Fims_XML_Encode(MI.Get(Stream_General, 0, General_CompleteName))+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); } //bmContentFormats - per stream { ToReturn+=__T("\t\t\t\n"); //videoFormat for (size_t Pos=0; Pos\n"); break; } Fims_Transform_Video(ToReturn, MI, Pos, Version); } //audioFormat for (size_t Pos=0; Pos\n"); break; } Fims_Transform_Audio(ToReturn, MI, Pos, Version); } //format - SigningPresent if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("SigningPresent")).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } //format - ClosedCaptionsPresent if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ClosedCaptionsPresent")).empty()) { if (Version\n"); ToReturn+=__T("\t\t\t\t\t\n"); if (Version\n"); else ToReturn+=__T("\t\t\t\t\t \n"); ToReturn+=__T("\t\t\t\t\n"); if (Version\n"); } //format - OpenCaptionsPresent if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OpenCaptionsPresent")).empty()) { if (Version\n"); ToReturn+=__T("\t\t\t\t\t\n"); if (Version\n"); else ToReturn+=__T("\t\t\t\t\t \n"); ToReturn+=__T("\t\t\t\t\n"); if (Version\n"); } //dataFormat for (size_t Pos=0; Pos"); if (!MI.Get(Stream_General, 0, General_ID).empty()) ToReturn+=__T(" "); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); //format - containerFormat - technicalAttribute formatLabel=\"string\" - AS11ShimName if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ShimName")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("ShimName"))+__T("\n"); } //format - containerFormat - technicalAttribute formatLabel=\"string\" - AS11ShimVersion if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ShimVersion")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("ShimVersion"))+__T("\n"); } //format - containerFormat - technicalAttribute formatLabel=\"string\" - Format_Profile if (!MI.Get(Stream_General, 0, __T("Format_Profile")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_General, 0, __T("Format_Profile"))+__T("\n"); } //format - containerFormat - technicalAttribute formatLabel=\"string\" - Format_Settings if (!MI.Get(Stream_General, 0, __T("Format_Profile")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_General, 0, __T("Format_Settings"))+__T("\n"); } //format - containerFormat - technicalAttribute formatLabel=\"string\" - Encoded_Application if (!MI.Get(Stream_General, 0, __T("Encoded_Application")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_General, 0, __T("Encoded_Application"))+__T("\n"); } //format - containerFormat - technicalAttribute formatLabel=\"string\" - Encoded_Library if (!MI.Get(Stream_General, 0, __T("Encoded_Library/String")).empty()) { ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_General, 0, __T("Encoded_Library/String"))+__T("\n"); } //format - containerFormat { ToReturn+=__T("\t\t\t\t\t=Version_1_1 && !MI.Get(Stream_General, 0, General_Format_Profile).empty()) // ToReturn+=__T(" containeFormatProfile=\"")+MI.Get(Stream_General, 0, General_Format_Profile)+__T("\""); ToReturn+=__T("/>\n"); } ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); } //format - technicalAttribute formatLabel=\"string\" - LineUpStart if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("LineUpStart")).empty()) { ToReturn+=__T("\t\t\t\n"); } //format - technicalAttribute formatLabel=\"string\" - IdentClockStart if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("IdentClockStart")).empty()) { ToReturn+=__T("\t\t\t\n"); } //format - duration bool durationDone=false; if (!MI.Get(Stream_General, 0, General_Duration).empty()) { float64 DurationS=MI.Get(Stream_General, 0, General_Duration).To_float64()/1000; int64u DurationH=(int64u)(DurationS/60/60); DurationS-=DurationH*60*60; int64u DurationM=(int64u)(DurationS/60); DurationS-=DurationM*60; Ztring Duration; if (DurationH) Duration+=Ztring::ToZtring(DurationH)+__T('H'); if (DurationM) Duration+=Ztring::ToZtring(DurationM)+__T('M'); Duration+=Ztring::ToZtring(DurationS, 3)+__T('S'); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\tPT")+Duration+__T("\n"); ToReturn+=__T("\t\t\t\n"); durationDone=true; } //duration if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TotalProgrammeDuration")).empty()) { if (Version\n"); ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TotalProgrammeDuration"))+__T("\n"); ToReturn+=__T("\t\t\t\n"); if (Version\n"); } //fileSize if (!MI.Get(Stream_General, 0, General_FileSize).empty()) ToReturn+=__T("\t\t\t")+MI.Get(Stream_General, 0, General_FileSize)+__T("\n"); if (As11_UkDpp_Pos!=(size_t)-1) { if (Version")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioLoudnessStandard"))+__T("\n"); } //format - technicalAttribute formatLabel=\"string\" - AudioDescriptionType if (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioDescriptionType")).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioDescriptionType"))+__T("\n"); } //format - technicalAttribute formatLabel=\"string\" - overallBitRate if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(Stream_General, 0, General_OverallBitRate)+__T("\n"); } //format - technicalAttribute formatLabel=\"string\" - ProgrammeHasText if (!MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeHasText")).empty()) { ToReturn+=__T("\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProgrammeHasText"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //format - technicalAttribute formatLabel=\"string\" - AudioDescriptionPresent if (!MI.Get(Stream_Other, As11_Core_Pos, __T("AudioDescriptionPresent")).empty()) { ToReturn+=__T("\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioDescriptionPresent"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } if (Version\n"); } //bmContentFormats ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\n"); //descriptions if (true) { ToReturn+=__T("\t\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); //title if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeTitle")).empty()) { ToReturn+=__T("\t\t\t\t")+(Version>=Version_1_2?Ztring(__T(" typeLabel=\"PROGRAMME TITLE\"")):Ztring())+MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeTitle"))+__T("")+(Version")):Ztring())+__T("\n"); } else if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber"))+__T(" \n"); } //alternativeTitle if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("SeriesTitle")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("SeriesTitle"))+__T("\n"); } if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber")).empty() && !MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeTitle")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber"))+__T("\n"); } //description if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Synopsis")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Synopsis"))+__T("\n"); } //ProductPlacement if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductPlacement")).empty()) { ToReturn+=__T("\t\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductPlacement"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //ContactEmail / ContactTelephoneNumber if (As11_UkDpp_Pos!=(size_t)-1 && (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactEmail")).empty() || !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactTelephoneNumber")).empty())) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\n"); if (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactEmail")).empty()) ToReturn+=__T("\t\t\t\t\t\t\t")+Fims_XML_Encode(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactEmail")))+__T("\n"); if (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactTelephoneNumber")).empty()) ToReturn+=__T("\t\t\t\t\t\t\t")+Fims_XML_Encode(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactTelephoneNumber")))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } //Originator if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Originator")).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Fims_XML_Encode(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Originator")))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } //Distributor if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Distributor")).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Distributor"))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } //date if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("CopyrightYear")).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } //type if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Genre")).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } //identifier if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductionNumber")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductionNumber"))+__T("\n"); } if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifier")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifier"))+__T("\n"); } if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifierType")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifierType"))+__T("\n"); } //format - PrimaryAudioLanguage if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("PrimaryAudioLanguage")).empty()) { ToReturn+=__T("\t\t\t\t\n"); } //format - SecondaryAudioLanguage if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("SecondaryAudioLanguage")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("SecondaryAudioLanguage"))+__T("<\"/>\n"); } //format - TertiaryAudioLanguage if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TertiaryAudioLanguage")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TertiaryAudioLanguage"))+__T("\"/>\n"); } //language if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProgrammeTextLanguage")).empty()) { ToReturn+=__T("\t\t\t\t\n"); } //part if (As11_Segmentation_Pos!=(size_t)-1) { size_t Pos=1; for (;;) { Ztring Content=MI.Get(Stream_Other, As11_Segmentation_Pos, Ztring::ToZtring(Pos)); if (Content.empty()) break; Ztring Begin=Content.SubString(Ztring(), __T(" + ")); Ztring Duration=Content.SubString(__T(" + "), __T(" = ")); ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Begin+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Duration+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); Pos++; } } ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\n"); } //bmContent ToReturn+=__T("\n"); //Carriage return ToReturn.FindAndReplace(__T("\n"), EOL, 0, Ztring_Recursive); return ToReturn; } //*************************************************************************** // //*************************************************************************** } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/Export_reVTMD.h0000664000000000000000000000007412652076434021241 0ustar rootroot// reVTMD is disabled due to its non-compatible licensing. MediaInfoLib/Source/MediaInfo/Export/Export_PBCore2.cpp0000664000000000000000000006523012652076434021674 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Dave Rice, dave@dericed.com // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PBCORE_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Export/Export_PBCore2.h" #include "MediaInfo/File__Analyse_Automatic.h" #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern MediaInfo_Config Config; //--------------------------------------------------------------------------- //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- Ztring PBCore2_MediaType(MediaInfo_Internal &MI) { if (MI.Count_Get(Stream_Video)) return __T("Moving Image"); 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_PBCore2::Export_PBCore2 () { } //--------------------------------------------------------------------------- Export_PBCore2::~Export_PBCore2 () { } //*************************************************************************** // Input //*************************************************************************** //--------------------------------------------------------------------------- void PBCore2_Transform(Ztring &ToReturn, MediaInfo_Internal &MI, stream_t StreamKind, size_t StreamPos) { //Menu: only if TimeCode if (StreamKind==Stream_Menu && MI.Get(Stream_Menu, StreamPos, Menu_Format)!=__T("TimeCode")) return; //essenceTrackType Ztring essenceTrackType; switch (StreamKind) { case Stream_Video: essenceTrackType=__T("Video"); break; case Stream_Audio: essenceTrackType=__T("Audio"); break; case Stream_Image: essenceTrackType=__T("Image"); break; case Stream_Text: { Ztring Format=MI.Get(Stream_Text, StreamPos, Text_Format); if (Format==__T("EIA-608") || Format==__T("EIA-708")) essenceTrackType=__T("CC"); else essenceTrackType=__T("Text"); } break; case Stream_Menu: if (MI.Get(Stream_Menu, StreamPos, Menu_Format)==__T("TimeCode")) { essenceTrackType=__T("TimeCode"); break; } else return; //Not supported default: return; //Not supported } ToReturn+=__T("\t\n"); ToReturn+=__T("\t\t"); ToReturn+=essenceTrackType; ToReturn+=__T("\n"); //essenceTrackIdentifier if (!MI.Get(StreamKind, StreamPos, __T("ID")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("ID")); ToReturn+=__T("\n"); } if (!MI.Get(Stream_General, 0, General_UniqueID).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("UniqueID")); ToReturn+=__T("\n"); } if (!MI.Get(StreamKind, StreamPos, __T("StreamKindID")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("StreamKindID")); ToReturn+=__T("\n"); } if (!MI.Get(StreamKind, StreamPos, __T("StreamOrder")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("StreamOrder")); ToReturn+=__T("\n"); } //essenceTrackStandard if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_Standard).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(Stream_Video, StreamPos, Video_Standard); ToReturn+=__T("\n"); } //essenceTrackEncoding if (!MI.Get(StreamKind, StreamPos, __T("Format")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("Format")); ToReturn+=__T("\n"); } //essenceTrackDataRate if (!MI.Get(StreamKind, StreamPos, __T("BitRate")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("BitRate")); ToReturn+=__T("\n"); } //essenceTrackFrameRate if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_FrameRate).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(Stream_Video, StreamPos, Video_FrameRate); ToReturn+=__T("\n"); } //essenceTrackSamplingRate if (StreamKind==Stream_Audio && !MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate); ToReturn+=__T("\n"); } //essenceTrackBitDepth if (!MI.Get(StreamKind, StreamPos, __T("BitDepth")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("BitDepth")); ToReturn+=__T("\n"); } //essenceTrackFrameSize if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_Width).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(Stream_Video, StreamPos, Video_Width); ToReturn+=__T('x'); ToReturn+=MI.Get(Stream_Video, StreamPos, Video_Height); ToReturn+=__T("\n"); } //essenceTrackAspectRatio if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio); ToReturn+=__T("\n"); } //essenceTrackDuration if (!MI.Get(StreamKind, StreamPos, __T("Duration_String3")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(StreamKind, StreamPos, __T("Duration_String3")); ToReturn+=__T("\n"); } //essenceTrackLanguage if (!MI.Get(StreamKind, StreamPos, __T("Language")).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MediaInfoLib::Config.Iso639_2_Get(MI.Get(StreamKind, StreamPos, __T("Language"))); ToReturn+=__T("\n"); } //essenceTrackAnnotation - all fields (except *_String* and a blacklist) for (size_t Pos=0; Pos"); ToReturn+=MI.Get(StreamKind, StreamPos, Pos); ToReturn+=__T("\n"); } ToReturn+=__T("\t\n"); } //--------------------------------------------------------------------------- Ztring Export_PBCore2::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("\n"); ToReturn+=__T("\n"); ToReturn+=__T("\n"); //instantiationIdentifier ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_General, 0, General_FileName); if (!MI.Get(Stream_General, 0, General_FileExtension).empty()) { ToReturn+=__T("."); ToReturn+=MI.Get(Stream_General, 0, General_FileExtension); } ToReturn+=__T("\n"); // need to figure out how to get to non-internally-declared-values //if (!MI.Get(Stream_General, 0, General_Media/UUID).empty()) //{ // ToReturn+=__T("\t")+MI.Get(Stream_General, 0, General_Media/UUID)+__T("\n"); //} //instantiationDates //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"); ToReturn+=dateIssued+__T("\n"); } //dateFileModified if (!MI.Get(Stream_General, 0, General_File_Modified_Date).empty()) { Ztring dateModified=MI.Get(Stream_General, 0, General_File_Modified_Date); dateModified.FindAndReplace(__T("UTC "), __T("")); dateModified.FindAndReplace(__T(" "), __T("T")); dateModified+=__T('Z'); ToReturn+=__T("\t"); ToReturn+=dateModified+__T("\n"); } //dateEncoder if (!MI.Get(Stream_General, 0, General_Encoded_Date).empty()) { Ztring dateEncoded=MI.Get(Stream_General, 0, General_Encoded_Date); dateEncoded.FindAndReplace(__T("UTC "), __T("")); dateEncoded.FindAndReplace(__T(" "), __T("T")); dateEncoded+=__T('Z'); ToReturn+=__T("\t"); ToReturn+=dateEncoded+__T("\n"); } //dateTagged if (!MI.Get(Stream_General, 0, General_Tagged_Date).empty()) { Ztring dateTagged=MI.Get(Stream_General, 0, General_Tagged_Date); dateTagged.FindAndReplace(__T("UTC "), __T("")); dateTagged.FindAndReplace(__T(" "), __T("T")); dateTagged+=__T('Z'); ToReturn+=__T("\t"); ToReturn+=dateTagged+__T("\n"); } //formatDigital if (!MI.Get(Stream_General, 0, General_InternetMediaType).empty()) { ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_General, 0, General_InternetMediaType); ToReturn+=__T("\n"); } else { //TODO: how to implement formats without Media Type? ToReturn+=__T("\t"); 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("\n"); } //formatLocation ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_General, 0, General_CompleteName); ToReturn+=__T("\n"); //formatMediaType if (!PBCore2_MediaType(MI).empty()) { ToReturn+=__T("\t"); ToReturn+=PBCore2_MediaType(MI); ToReturn+=__T("\n"); } //formatFileSize if (!MI.Get(Stream_General, 0, General_FileSize).empty()) { ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_General, 0, General_FileSize); ToReturn+=__T("\n"); } //formatTimeStart if (!MI.Get(Stream_Video, 0, Video_Delay_Original_String3).empty()) { ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_Video, 0, Video_Delay_Original_String3); ToReturn+=__T("\n"); } else if (!MI.Get(Stream_Video, 0, Video_Delay_String3).empty()) { ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_Video, 0, Video_Delay_String3); ToReturn+=__T("\n"); } //formatDuration if (!MI.Get(Stream_General, 0, General_Duration_String3).empty()) { ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_General, 0, General_Duration_String3); ToReturn+=__T("\n"); } //formatDataRate if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty()) { ToReturn+=__T("\t"); ToReturn+=MI.Get(Stream_General, 0, General_OverallBitRate); ToReturn+=__T("\n"); } //formatTracks ToReturn+=__T("\t")+Ztring::ToZtring(MI.Count_Get(Stream_Video)+MI.Count_Get(Stream_Audio)+MI.Count_Get(Stream_Image)+MI.Count_Get(Stream_Text))+__T("\n"); //Streams for (size_t StreamKind=Stream_General+1; StreamKind"); ToReturn+=MI.Get(Stream_General, 0, Pos); ToReturn+=__T("\n"); } ToReturn+=__T("\n"); //Carriage return ToReturn.FindAndReplace(__T("\n"), EOL, 0, Ztring_Recursive); return ToReturn; } //*************************************************************************** // //*************************************************************************** } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/Export_EbuCore.h0000664000000000000000000000220512652076434021462 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef Export_EbuCoreH #define Export_EbuCoreH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Internal.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** /// @brief Export_EbuCore //*************************************************************************** class Export_EbuCore { public : //Constructeur/Destructeur Export_EbuCore (); ~Export_EbuCore (); //Input enum version { Version_1_5, Version_1_6, }; Ztring Transform(MediaInfo_Internal &MI, version Version=Version_1_6); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/Export_Fims.h0000664000000000000000000000221112652076434021031 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef Export_FimsH #define Export_FimsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Internal.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** /// @brief Export_Fims //*************************************************************************** class Export_Fims { public : //Constructeur/Destructeur Export_Fims (); ~Export_Fims (); //Input enum version { Version_1_1, Version_1_2, Version_1_3, }; Ztring Transform(MediaInfo_Internal &MI, version Version=Version_1_2); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/Export_EbuCore.cpp0000664000000000000000000030552612652076434022031 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_EBUCORE_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Export/Export_EbuCore.h" #include "MediaInfo/File__Analyse_Automatic.h" #include #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern MediaInfo_Config Config; //--------------------------------------------------------------------------- //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- Ztring XML_Encode (const Ztring& Data) { Ztring Result; wstring::size_type Pos; for (Pos=0; Pos'): Result+=__T("≶"); break; default: Result+=Data[Pos]; } } return Result; } //--------------------------------------------------------------------------- int32u EbuCore_VideoCompressionCodeCS_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 EbuCore_VideoCompressionCodeCS_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); } } //--------------------------------------------------------------------------- int32u EbuCore_AudioCompressionCodeCS_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 40200; if (Format==__T("E-AC-3")) return 40300; if (Format==__T("Dolby E")) return 40600; if (Format==__T("DTS")) return 50000; if (Format==__T("MPEG Audio")) { if (Version.find(__T("1"))!=string::npos) { if (Profile.find(__T("1"))!=string::npos) return 70100; if (Profile.find(__T("2"))!=string::npos) return 70200; if (Profile.find(__T("3"))!=string::npos) return 70300; return 70000; } if (Version.find(__T("2"))!=string::npos) { if (Profile.find(__T("1"))!=string::npos) return 90100; if (Profile.find(__T("2"))!=string::npos) return 90200; if (Profile.find(__T("3"))!=string::npos) return 90300; return 90000; } return 0; } if (Format==__T("PCM")) return 110000; return 0; } Ztring EbuCore_AudioCompressionCodeCS_Name(int32u termID, MediaInfo_Internal &MI, size_t StreamPos) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number { switch (termID/10000) { case 4 : switch ((termID%10000)/100) { case 2 : return __T("AC3"); case 3 : return __T("E-AC3"); case 6 : return __T("Dolby E"); default: return __T("Dolby"); } case 5 : return __T("DTS"); case 7 : 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 9 : switch ((termID%10000)/100) { case 1 : return __T("MPEG-2 Audio Layer I"); case 2 : return __T("MPEG-2 Audio Layer II"); case 3 : return __T("MPEG-2 Audio Layer III"); default: return __T("MPEG-2 Audio"); } default: return MI.Get(Stream_Audio, StreamPos, Video_Format); } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Export_EbuCore::Export_EbuCore () { } //--------------------------------------------------------------------------- Export_EbuCore::~Export_EbuCore () { } //*************************************************************************** // Input //*************************************************************************** //--------------------------------------------------------------------------- Ztring EbuCore_Transform_Video(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, Export_EbuCore::version Version) { size_t As11_UkDpp_Pos=(size_t)-1; for (size_t StreamPos_Temp=0; StreamPos_Temp\n"); //width if (!MI.Get(Stream_Video, StreamPos, Video_Width).empty()) { Ztring Width; if (!MI.Get(Stream_Video, StreamPos, Video_Width_Original).empty()) Width=MI.Get(Stream_Video, StreamPos, Video_Width_Original); else Width=MI.Get(Stream_Video, StreamPos, Video_Width); ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Width)+__T("\n"); } //height if (!MI.Get(Stream_Video, StreamPos, Video_Height).empty()) { Ztring Height; if (!MI.Get(Stream_Video, StreamPos, Video_Height_Original).empty()) Height=MI.Get(Stream_Video, StreamPos, Video_Height_Original); else Height=MI.Get(Stream_Video, StreamPos, Video_Height); ToReturn+=__T("\t\t\t\t")+Height+__T("\n"); } //lines if (!MI.Get(Stream_Video, StreamPos, Video_Height_Original).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Height_Original)+__T("\n"); //frameRate if (!MI.Get(Stream_Video, StreamPos, Video_FrameRate).empty()) { Ztring FrameRateString=MI.Get(Stream_Video, StreamPos, Video_FrameRate); Ztring factorNumerator, factorDenominator; if (FrameRateString==__T("23.976")) { factorNumerator=__T("24000"); factorDenominator=__T("1001"); } if (FrameRateString==__T("29.970")) { factorNumerator=__T("30000"); factorDenominator=__T("1001"); } if (FrameRateString==__T("59.940")) { factorNumerator=__T("60000"); factorDenominator=__T("1001"); } if (factorNumerator.empty()) { factorNumerator=Ztring::ToZtring(FrameRateString.To_float64()*1000, 0); factorDenominator=__T("1000"); } ToReturn+=__T("\t\t\t\t")+Ztring::ToZtring(FrameRateString.To_float64(), 0); ToReturn+=__T("\n"); } //aspectRatio if (!MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio).empty()) { Ztring AspectRatioString=MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio_String); size_t AspectRatioString_Pos=AspectRatioString.find(__T(':')); Ztring factorNumerator, factorDenominator; if (AspectRatioString_Pos!=(size_t)-1) { factorNumerator=AspectRatioString.substr(0, AspectRatioString_Pos); factorDenominator=AspectRatioString.substr(AspectRatioString_Pos+1); } else { AspectRatioString_Pos=AspectRatioString.find(__T('.')); if (AspectRatioString_Pos!=(size_t)-1) { int64s Denominator=float64_int64s(pow((double)10, (int)(AspectRatioString.size()-AspectRatioString_Pos+1))); //Computing the right denomintor compared to the count of decimals in the value e.g. 1.778 will have a denominator of 1000 (3 digits after the comma) factorNumerator=Ztring::ToZtring(AspectRatioString.To_float32()*Denominator, 0); factorDenominator=Ztring::ToZtring(Denominator); } else { factorNumerator=AspectRatioString; //No decimal factorDenominator=__T("1"); } } ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t")+factorNumerator+__T("\n"); ToReturn+=__T("\t\t\t\t\t")+factorDenominator+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); } //videoEncoding //if (!MI.Get(Stream_Video, StreamPos, Video_Format_Profile).empty()) { int32u TermID=EbuCore_VideoCompressionCodeCS_termID(MI, StreamPos); Ztring typeLabel; Ztring TermID_String; if (TermID) { typeLabel=EbuCore_VideoCompressionCodeCS_Name(TermID, MI, StreamPos); TermID_String=Ztring::ToZtring(TermID/10000); if (TermID%10000) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring((TermID%10000)/100); if (TermID%100) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring(TermID%100); } } } else typeLabel=MI.Get(Stream_Video, StreamPos, Video_Format_Profile); ToReturn+=__T("\t\t\t\t\n"); } //codec if (!MI.Get(Stream_Video, StreamPos, Video_CodecID).empty() || !MI.Get(Stream_Video, StreamPos, Video_Format_Commercial_IfAny).empty()) { ToReturn+=__T("\t\t\t\t\n"); if (!MI.Get(Stream_Video, StreamPos, Video_CodecID).empty()) { ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_CodecID)+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); } if (!MI.Get(Stream_Video, StreamPos, Video_Format_Commercial_IfAny).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Format_Commercial_IfAny)+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); } //bitRate if (!MI.Get(Stream_Video, StreamPos, Video_BitRate).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_BitRate)+__T("\n"); //bitRateMax if (!MI.Get(Stream_Video, StreamPos, Video_BitRate_Maximum).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_BitRate_Maximum)+__T("\n"); //bitRateMode if (!MI.Get(Stream_Video, StreamPos, Video_BitRate_Mode).empty()) { Ztring bitRateMode=MI.Get(Stream_Video, StreamPos, Video_BitRate_Mode); if (bitRateMode==__T("CBR")) bitRateMode=__T("constant"); if (bitRateMode==__T("VBR")) bitRateMode=__T("variable"); ToReturn+=__T("\t\t\t\t")+bitRateMode+__T("\n"); } //scanningFormat if (!MI.Get(Stream_Video, StreamPos, Video_ScanType).empty()) { Ztring ScanType=MI.Get(Stream_Video, StreamPos, Video_ScanType); if (ScanType==__T("MBAFF")) ScanType=__T("Interlaced"); ScanType.MakeLowerCase(); ToReturn+=__T("\t\t\t\t")+ScanType+__T("\n"); } //scanningOrder if (!MI.Get(Stream_Video, StreamPos, Video_ScanOrder).empty()) { Ztring ScanOrder=MI.Get(Stream_Video, StreamPos, Video_ScanOrder); if (ScanOrder==__T("TFF")) ScanOrder=__T("top"); if (ScanOrder==__T("BFF")) ScanOrder=__T("bottom"); if (ScanOrder.find(__T("Pulldown"))!=string::npos) ScanOrder=__T("pulldown"); ToReturn+=__T("\t\t\t\t")+ScanOrder+__T("\n"); } //videoTrack if (!MI.Get(Stream_Video, StreamPos, Video_ID).empty() || !MI.Get(Stream_Video, StreamPos, Video_Title).empty()) { ToReturn+=__T("\t\t\t\t\n"); } //flag_3D if (!MI.Get(Stream_Video, StreamPos, Video_MultiView_Count).empty()) ToReturn+=__T("\t\t\t\ttrue\n"); //technicalAttributeString - ActiveFormatDescription if (!MI.Get(Stream_Video, StreamPos, Video_ActiveFormatDescription).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_ActiveFormatDescription)+__T("\n"); //technicalAttributeString - Standard if (!MI.Get(Stream_Video, StreamPos, Video_Standard).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Standard)+__T("\n"); } //technicalAttributeString - ColorSpace if (!MI.Get(Stream_Video, StreamPos, Video_ColorSpace).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_ColorSpace)+__T("\n"); } //technicalAttributeString - ChromaSubsampling if (!MI.Get(Stream_Video, StreamPos, Video_ChromaSubsampling).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_ChromaSubsampling)+__T("\n"); } //technicalAttributeString - colour_primaries if (!MI.Get(Stream_Video, StreamPos, __T("colour_primaries")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("colour_primaries"))+__T("\n"); } //technicalAttributeString - transfer_characteristics if (!MI.Get(Stream_Video, StreamPos, __T("transfer_characteristics")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("transfer_characteristics"))+__T("\n"); } //technicalAttributeString - matrix_coefficients if (!MI.Get(Stream_Video, StreamPos, __T("matrix_coefficients")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("matrix_coefficients"))+__T("\n"); } //technicalAttributeString - colour_range if (!MI.Get(Stream_Video, StreamPos, __T("colour_range")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Video, StreamPos, __T("colour_range"))+__T("\n"); } //technicalAttributeString - StreamSize if (!MI.Get(Stream_Video, StreamPos, Video_StreamSize).empty()) { ToReturn+=__T("\t\t\t\t=Export_EbuCore::Version_1_6?Ztring(__T(" unit=\"byte\"")):Ztring())+__T(">")+MI.Get(Stream_Video, StreamPos, Video_StreamSize)+__T("\n"); } //technicalAttributeString - BitDepth if (!MI.Get(Stream_Video, StreamPos, Video_BitDepth).empty()) { ToReturn+=__T("\t\t\t\t=Export_EbuCore::Version_1_6?Ztring(__T(" unit=\"bit\"")):Ztring())+__T(">")+MI.Get(Stream_Video, StreamPos, Video_BitDepth)+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaManufacturer")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaManufacturer"))+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaVersion")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaVersion"))+__T("\n"); } //technicalAttributeBoolean - Format_Settings_CABAC if (MI.Get(Stream_Video, StreamPos, Video_Format)==__T("AVC") && !MI.Get(Stream_Video, StreamPos, Video_Format_Settings_CABAC).empty()) { ToReturn+=__T("\t\t\t\t")+Ztring(MI.Get(Stream_Video, StreamPos, Video_Format_Settings_CABAC)==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //technicalAttributeBoolean - Format_Settings_MBAFF if (MI.Get(Stream_Video, StreamPos, Video_Format)==__T("AVC") && !MI.Get(Stream_Video, StreamPos, Video_ScanType).empty()) { ToReturn+=__T("\t\t\t\t")+Ztring(MI.Get(Stream_Video, StreamPos, Video_ScanType)==__T("MBAFF")?__T("true"):__T("false"))+__T("\n"); } //technicalAttributeBoolean - FpaPass if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaPass")).empty()) { ToReturn+=__T("\t\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("FpaPass"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("VideoComments")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("VideoComments"))+__T("\n"); } ToReturn+=__T("\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring EbuCore_Transform_Audio(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, Export_EbuCore::version Version) { size_t As11_Core_Pos=(size_t)-1; size_t As11_UkDpp_Pos=(size_t)-1; for (size_t StreamPos_Temp=0; StreamPos_Temp\n"); //audioEncoding //if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Profile).empty()) { int32u TermID=EbuCore_AudioCompressionCodeCS_termID(MI, StreamPos); Ztring typeLabel; Ztring TermID_String; if (TermID) { typeLabel=EbuCore_AudioCompressionCodeCS_Name(TermID, MI, StreamPos); TermID_String=Ztring::ToZtring(TermID/10000); if (TermID%10000) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring((TermID%10000)/100); if (TermID%100) { TermID_String+=__T('.'); TermID_String+=Ztring::ToZtring(TermID%100); } } } else typeLabel=MI.Get(Stream_Audio, StreamPos, Audio_Format_Profile); ToReturn+=__T("\t\t\t\t\n"); } //codec if (!MI.Get(Stream_Audio, StreamPos, Audio_CodecID).empty() || !MI.Get(Stream_Audio, StreamPos, Audio_Format_Commercial_IfAny).empty()) { ToReturn+=__T("\t\t\t\t\n"); if (!MI.Get(Stream_Audio, StreamPos, Audio_CodecID).empty()) { ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_CodecID)+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); } if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Commercial_IfAny).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Format_Commercial_IfAny)+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); } //audioTrackConfiguration if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("AudioTrackLayout")).empty()) { ToReturn+=__T("\t\t\t\t\n"); } //samplingRate if (!MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate)+__T("\n"); //sampleSize if (!MI.Get(Stream_Audio, StreamPos, Audio_BitDepth).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_BitDepth)+__T("\n"); //bitRate if (!MI.Get(Stream_Audio, StreamPos, Audio_BitRate).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_BitRate)+__T("\n"); //bitRateMax if (!MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Maximum).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Maximum)+__T("\n"); //bitRateMode if (!MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Mode).empty()) { Ztring bitRateMode=MI.Get(Stream_Audio, StreamPos, Audio_BitRate_Mode); if (bitRateMode==__T("CBR")) bitRateMode=__T("constant"); if (bitRateMode==__T("VBR")) bitRateMode=__T("variable"); ToReturn+=__T("\t\t\t\t")+bitRateMode+__T("\n"); } //audioTrack if (!MI.Get(Stream_Audio, StreamPos, Audio_ID).empty() || !MI.Get(Stream_Audio, StreamPos, Audio_Title).empty() || !MI.Get(Stream_Audio, StreamPos, Audio_Language).empty()) { ToReturn+=__T("\t\t\t\t\n"); } //channels if (!MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_).empty()) ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_)+__T("\n"); //format - technicalAttributeString - ChannelPositions if (!MI.Get(Stream_Audio, StreamPos, Audio_ChannelPositions).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_ChannelPositions)+__T("\n"); } //format - technicalAttributeString - ChannelLayout if (!MI.Get(Stream_Audio, StreamPos, Audio_ChannelLayout).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_ChannelLayout)+__T("\n"); } //technicalAttributeString - Format_Settings_Endianness if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Endianness).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Endianness)+__T("\n"); } //technicalAttributeString - Format_Settings_Wrapping if (!MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Wrapping).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Wrapping)+__T("\n"); } //technicalAttributeString - StreamSize if (!MI.Get(Stream_Audio, StreamPos, Audio_StreamSize).empty()) { ToReturn+=__T("\t\t\t\t=Export_EbuCore::Version_1_6?Ztring(__T(" unit=\"byte\"")):Ztring())+__T(">")+MI.Get(Stream_Audio, StreamPos, Audio_StreamSize)+__T("\n"); } //technicalAttributeString if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioComments")).empty()) { ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioComments"))+__T("\n"); } ToReturn+=__T("\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring EbuCore_Transform_Text(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos) { ToReturn+=__T("\t\t\t\n"); //subtitlingTrack { ToReturn+=__T("\t\t\t\t\n"); if (!MI.Get(Stream_Text, StreamPos, Text_CodecID).empty() || !MI.Get(Stream_Text, StreamPos, Text_Format_Commercial_IfAny).empty()) { ToReturn+=__T("\t\t\t\t\n"); if (!MI.Get(Stream_Text, StreamPos, Text_CodecID).empty()) { ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_Text, StreamPos, Text_CodecID)+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); } if (!MI.Get(Stream_Text, StreamPos, Text_Format_Commercial_IfAny).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_Text, StreamPos, Text_Format_Commercial_IfAny)+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); } } ToReturn+=__T("\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- #if 0 //Old version void EbuCore_Transform_AcquisitionMetadata(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, Export_EbuCore::version Version) { ToReturn+=__T("\t\t\t\n"); } #endif //0 //--------------------------------------------------------------------------- Ztring EbuCore_Duration(int64s MS) { Ztring DurationString3; int64s HH, MM, Sec; //Hours HH=MS/1000/60/60; //h if (HH>0) { 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 (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 Sec=MS/1000; //s if (Sec>0 || MM>0 || HH>0) { if (Sec<10) DurationString3+=Ztring(__T("0"))+Ztring::ToZtring(Sec)+__T("."); else DurationString3+=Ztring::ToZtring(Sec)+__T("."); MS-=Sec*1000; } else { DurationString3+=__T("00."); } //Milliseconds if (MS>0 || Sec>0 || MM>0 || HH>0) { 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"); } return DurationString3; } //--------------------------------------------------------------------------- void EbuCore_Transform_AcquisitionMetadata(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, Export_EbuCore::version Version) { ToReturn+=__T("\t\t\t\n"); } //--------------------------------------------------------------------------- Ztring EbuCore_Transform_TimeCode(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, bool Is1_5) { if (Is1_5) ToReturn+=__T("\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring EbuCore_Transform_Metadata(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos, bool Is1_5) { if (Is1_5) ToReturn+=__T("\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Export_EbuCore::Transform(MediaInfo_Internal &MI, version Version) { //Current date/time is ISO format time_t Seconds=time(NULL); Ztring DateTime; DateTime.Date_From_Seconds_1970((int32u)Seconds); if (DateTime.size()>=4 && DateTime[0]==__T('U') && DateTime[1]==__T('T') && DateTime[2]==__T('C') && DateTime[3]==__T(' ')) { DateTime.erase(0, 4); DateTime+=__T('Z'); } Ztring Date=DateTime.substr(0, 10); Ztring Time=DateTime.substr(11); size_t As11_Core_Pos=(size_t)-1; size_t As11_Segmentation_Pos=(size_t)-1; size_t As11_UkDpp_Pos=(size_t)-1; for (size_t StreamPos_Temp=0; StreamPos_Temp\n"); ToReturn+=__T("\n"); if (Version==Version_1_5) ToReturn+=__T("\n"); else ToReturn+=__T("\n"); //coreMetadata ToReturn+=__T("\t\n"); //title if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeTitle")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeTitle"))+__T("\n"); ToReturn+=__T("\t\t\n"); } else if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //alternativeTitle if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("SeriesTitle")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("SeriesTitle"))+__T("\n"); ToReturn+=__T("\t\t\n"); } if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber")).empty() && !MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeTitle")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("EpisodeTitleNumber"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //description if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Synopsis")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Synopsis"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //ProductPlacement if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductPlacement")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductPlacement"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //ContactEmail / ContactTelephoneNumber if (As11_UkDpp_Pos!=(size_t)-1 && (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactEmail")).empty() || !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactTelephoneNumber")).empty())) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); if (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactEmail")).empty()) ToReturn+=__T("\t\t\t\t\t")+XML_Encode(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactEmail")))+__T("\n"); if (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactTelephoneNumber")).empty()) ToReturn+=__T("\t\t\t\t\t")+XML_Encode(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ContactTelephoneNumber")))+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); } //Originator if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Originator")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t")+XML_Encode(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Originator")))+__T("\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); } //Distributor if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Distributor")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Distributor"))+__T("\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); } //date if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("CopyrightYear")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); } //type if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("Genre")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); } //format ToReturn+=__T("\t\t\n"); //format - videoFormat for (size_t Pos=0; Pos=Version_1_6?__T(" containerFormatName=\""):__T(" formatLabel=\""))+MI.Get(Stream_General, 0, General_Format)+__T("\""); if (!MI.Get(Stream_General, 0, General_ID).empty()) ToReturn+=__T(" containerFormatId=\"")+MI.Get(Stream_General, 0, General_ID)+__T("\""); ToReturn+=__T(">\n"); if (Version >= Version_1_6) { ToReturn += __T("\t\t\t\t=Version_1_6 && !MI.Get(Stream_General, 0, General_Format_Profile).empty()) // ToReturn+=__T(" containeFormatProfile=\"")+MI.Get(Stream_General, 0, General_Format_Profile)+__T("\""); ToReturn += __T("/>\n"); } if (!MI.Get(Stream_General, 0, General_CodecID).empty() || (!MI.Get(Stream_General, 0, General_Format_Commercial_IfAny).empty())) { ToReturn+=__T("\t\t\t\t\n"); if (!MI.Get(Stream_General, 0, General_CodecID).empty()) { ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+MI.Get(Stream_General, 0, General_CodecID)+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Format_Commercial_IfAny).empty()) ToReturn+=__T("\t\t\t\t\t")+MI.Get(Stream_General, 0, General_Format_Commercial_IfAny)+__T("\n"); ToReturn+=__T("\t\t\t\t\n"); } //format - containerFormat - technicalAttributeString - AS11ShimName if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ShimName")).empty()) { ToReturn+=__T("\t\t\t\t=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(" typeLabel=\"AS11ShimName\">")+MI.Get(Stream_Other, As11_Core_Pos, __T("ShimName"))+__T("=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(">\n"); } //format - containerFormat - technicalAttributeString - AS11ShimVersion if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ShimVersion")).empty()) { ToReturn+=__T("\t\t\t\t=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(" typeLabel=\"AS11ShimVersion\">")+MI.Get(Stream_Other, As11_Core_Pos, __T("ShimVersion"))+__T("=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(">\n"); } //format - containerFormat - technicalAttributeString - Format_Profile if (!MI.Get(Stream_General, 0, __T("Format_Profile")).empty()) { ToReturn+=__T("\t\t\t\t=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(" typeLabel=\"FormatProfile\">")+MI.Get(Stream_General, 0, __T("Format_Profile"))+__T("=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(">\n"); } //format - containerFormat - technicalAttributeString - Format_Settings if (!MI.Get(Stream_General, 0, __T("Format_Profile")).empty()) { ToReturn+=__T("\t\t\t\t=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(" typeLabel=\"FormatSettings\">")+MI.Get(Stream_General, 0, __T("Format_Settings"))+__T("=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(">\n"); } //format - containerFormat - technicalAttributeString - Encoded_Application if (!MI.Get(Stream_General, 0, __T("Encoded_Application")).empty()) { ToReturn+=__T("\t\t\t\t=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(" typeLabel=\"WrittingApplication\">")+MI.Get(Stream_General, 0, __T("Encoded_Application"))+__T("=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(">\n"); } //format - containerFormat - technicalAttributeString - Encoded_Library if (!MI.Get(Stream_General, 0, __T("Encoded_Library/String")).empty()) { ToReturn+=__T("\t\t\t\t=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(" typeLabel=\"WrittingLibrary\">")+MI.Get(Stream_General, 0, __T("Encoded_Library/String"))+__T("=Version_1_6?__T("technicalAttributeString"):__T("comment"))+__T(">\n"); } ToReturn+=__T("\t\t\t\n"); //format - SigningPresent if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("SigningPresent")).empty()) { if (Version==Version_1_5) ToReturn+=__T("\t\t\t\n"); } //format - dataFormat for (size_t Pos=0; Pos\n"); ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); } //format - OpenCaptionsPresent if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OpenCaptionsPresent")).empty()) { ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); } //format - time codes for (size_t Pos=0; Pos\n"); ToReturn+=__T("\t\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("LineUpStart"))+__T("\n"); ToReturn+=__T("\t\t\t\n"); startDone=true; } //format - technicalAttributeString - IdentClockStart if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("IdentClockStart")).empty()) { if (Version==Version_1_5 && startDone) ToReturn+=__T("\t\t\t\n"); } //format - duration bool durationDone=false; if (!MI.Get(Stream_General, 0, General_Duration).empty()) { float64 DurationS=MI.Get(Stream_General, 0, General_Duration).To_float64()/1000; int64u DurationH=(int64u)(DurationS/60/60); DurationS-=DurationH*60*60; int64u DurationM=(int64u)(DurationS/60); DurationS-=DurationM*60; Ztring Duration; if (DurationH) Duration+=Ztring::ToZtring(DurationH)+__T('H'); if (DurationM) Duration+=Ztring::ToZtring(DurationM)+__T('M'); Duration+=Ztring::ToZtring(DurationS, 3)+__T('S'); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\tPT")+Duration+__T("\n"); ToReturn+=__T("\t\t\t\n"); durationDone=true; } //format - duration if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TotalProgrammeDuration")).empty()) { if (Version==Version_1_5 && durationDone) ToReturn+=__T("\t\t\t\n"); } //format - fileSize if (!MI.Get(Stream_General, 0, General_FileSize).empty()) ToReturn+=__T("\t\t\t")+MI.Get(Stream_General, 0, General_FileSize)+__T("\n"); //format - fileName if (!MI.Get(Stream_General, 0, General_FileName).empty()) { Ztring Name=MI.Get(Stream_General, 0, General_FileName); if (!MI.Get(Stream_General, 0, General_FileExtension).empty()) { Name+=__T('.'); Name+=MI.Get(Stream_General, 0, General_FileExtension); } ToReturn+=__T("\t\t\t")+XML_Encode(Name)+__T("\n"); } //format - locator if (!MI.Get(Stream_General, 0, General_CompleteName).empty()) { ToReturn+=__T("\t\t\t")+XML_Encode(MI.Get(Stream_General, 0, General_CompleteName))+__T("\n"); } //format - technicalAttributeString - AudioLoudnessStandard if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioLoudnessStandard")).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioLoudnessStandard"))+__T("\n"); } //format - technicalAttributeString - AudioDescriptionType if (!MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioDescriptionType")).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioDescriptionType"))+__T("\n"); } //format - technicalAttributeString - overallBitRate if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty()) { ToReturn+=__T("\t\t\t=Version_1_6?Ztring(__T(" unit=\"bps\"")):Ztring())+__T(">")+MI.Get(Stream_General, 0, General_OverallBitRate)+__T("\n"); } //format - technicalAttributeString - ProgrammeHasText if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("ProgrammeHasText")).empty()) { ToReturn+=__T("\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProgrammeHasText"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //format - technicalAttributeString - AudioDescriptionPresent if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("AudioDescriptionPresent")).empty()) { ToReturn+=__T("\t\t\t")+Ztring(MI.Get(Stream_Other, As11_UkDpp_Pos, __T("AudioDescriptionPresent"))==__T("Yes")?__T("true"):__T("false"))+__T("\n"); } //format - dateCreated if (!MI.Get(Stream_General, 0, General_Encoded_Date).empty()) { Ztring DateTime=MI.Get(Stream_General, 0, General_Encoded_Date); if (DateTime.size()>=4 && DateTime[0]==__T('U') && DateTime[1]==__T('T') && DateTime[2]==__T('C') && DateTime[3]==__T(' ')) { DateTime.erase(0, 4); DateTime+=__T('Z'); } Ztring Date=DateTime.substr(0, 10); Ztring Time=DateTime.substr(11); ToReturn+=__T("\t\t\t\n"); } //format - dateModified if (!MI.Get(Stream_General, 0, General_Tagged_Date).empty()) { Ztring DateTime=MI.Get(Stream_General, 0, General_Tagged_Date); if (DateTime.size()>=4 && DateTime[0]==__T('U') && DateTime[1]==__T('T') && DateTime[2]==__T('C') && DateTime[3]==__T(' ')) { DateTime.erase(0, 4); DateTime+=__T('Z'); } Ztring Date=DateTime.substr(0, 10); Ztring Time=DateTime.substr(11); ToReturn+=__T("\t\t\t\n"); } //format ToReturn+=__T("\t\t\n"); //identifier if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductionNumber")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProductionNumber"))+__T("\n"); ToReturn+=__T("\t\t\n"); } if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifier")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifier"))+__T("\n"); ToReturn+=__T("\t\t\n"); } if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifierType")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("OtherIdentifierType"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //format - PrimaryAudioLanguage if (As11_Core_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_Core_Pos, __T("PrimaryAudioLanguage")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_Core_Pos, __T("PrimaryAudioLanguage"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //format - SecondaryAudioLanguage if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("SecondaryAudioLanguage")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("SecondaryAudioLanguage"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //format - TertiaryAudioLanguage if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TertiaryAudioLanguage")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("TertiaryAudioLanguage"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //language if (As11_UkDpp_Pos!=(size_t)-1 && !MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProgrammeTextLanguage")).empty()) { ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+MI.Get(Stream_Other, As11_UkDpp_Pos, __T("ProgrammeTextLanguage"))+__T("\n"); ToReturn+=__T("\t\t\n"); } //part if (As11_Segmentation_Pos!=(size_t)-1) { size_t Pos=1; for (;;) { Ztring Content=MI.Get(Stream_Other, As11_Segmentation_Pos, Ztring::ToZtring(Pos)); if (Content.empty()) break; Ztring Begin=Content.SubString(Ztring(), __T(" + ")); Ztring Duration=Content.SubString(__T(" + "), __T(" = ")); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t")+Begin+__T("\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t")+Duration+__T("\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); Pos++; } } //coreMetadata ToReturn+=__T("\t\n"); //ebuCoreMain ToReturn+=__T("\n"); //Carriage return ToReturn.FindAndReplace(__T("\n"), EOL, 0, Ztring_Recursive); return ToReturn; } //*************************************************************************** // //*************************************************************************** } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/Export_reVTMD.cpp0000664000000000000000000000047412652076434021600 0ustar rootroot// reVTMD is disabled due to its non-free licensing. //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- MediaInfoLib/Source/MediaInfo/Export/Export_PBCore.cpp0000664000000000000000000003715512652076434021617 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PBCORE_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Export/Export_PBCore.h" #include "MediaInfo/File__Analyse_Automatic.h" #include 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(Ztring &ToReturn, MediaInfo_Internal &MI, stream_t StreamKind, size_t StreamPos) { //Menu: only if TimeCode if (StreamKind==Stream_Menu && MI.Get(Stream_Menu, StreamPos, Menu_Format)!=__T("TimeCode")) return; //essenceTrackType Ztring essenceTrackType; switch (StreamKind) { case Stream_Video: essenceTrackType=__T("Video"); break; case Stream_Audio: essenceTrackType=__T("Audio"); break; case Stream_Text: { Ztring Format=MI.Get(Stream_Text, StreamPos, Text_Format); if (Format==__T("EIA-608") || Format==__T("EIA-708")) essenceTrackType=__T("CC"); else essenceTrackType=__T("Text"); } break; case Stream_Menu: if (MI.Get(Stream_Menu, StreamPos, Menu_Format)==__T("TimeCode")) { essenceTrackType=__T("TimeCode"); break; } else return; //Not supported default: return; //Not supported } ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t")+essenceTrackType+__T("\n"); //essenceTrackIdentifier if (!MI.Get(StreamKind, StreamPos, __T("ID")).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(StreamKind, StreamPos, __T("ID"))+__T("\n"); ToReturn+=__T("\t\t\tID (Mediainfo)\n"); } else if (!MI.Get(StreamKind, StreamPos, __T("UniqueID")).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(StreamKind, StreamPos, __T("UniqueID"))+__T("\n"); ToReturn+=__T("\t\t\tUniqueID (Mediainfo)\n"); } else if (!MI.Get(StreamKind, StreamPos, __T("StreamKindID")).empty()) { ToReturn+=__T("\t\t\t")+MI.Get(StreamKind, StreamPos, __T("StreamKindID"))+__T("\n"); ToReturn+=__T("\t\t\tStreamKindID (Mediainfo)\n"); } //essenceTrackStandard if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_Standard).empty()) ToReturn+=__T("\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Standard)+__T("\n"); //essenceTrackEncoding if (!MI.Get(StreamKind, StreamPos, __T("Format")).empty()) { ToReturn+=__T("\t\t\t"); 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("\n"); } //essenceTrackDataRate if (!MI.Get(StreamKind, StreamPos, __T("BitRate")).empty()) { ToReturn+=__T("\t\t\t"); 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("\n"); } //essenceTrackFrameRate if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_FrameRate).empty()) { ToReturn+=__T("\t\t\t"); 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("\n"); } //essenceTrackSamplingRate if (StreamKind==Stream_Audio && !MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate).empty()) ToReturn+=__T("\t\t\t")+MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate)+__T("\n"); //essenceTrackBitDepth if (!MI.Get(StreamKind, StreamPos, __T("BitDepth")).empty()) ToReturn+=__T("\t\t\t")+MI.Get(StreamKind, StreamPos, __T("BitDepth"))+__T("\n"); //essenceTrackFrameSize if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_Width).empty()) ToReturn+=__T("\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_Width)+__T('x')+MI.Get(Stream_Video, StreamPos, Video_Height)+__T("\n"); //essenceTrackAspectRatio if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio).empty()) ToReturn+=__T("\t\t\t")+MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio)+__T("\n"); //essenceTrackDuration if (!MI.Get(StreamKind, StreamPos, __T("Duration")).empty()) ToReturn+=__T("\t\t\t")+MI.Get(StreamKind, StreamPos, __T("Duration"))+__T("\n"); //essenceTrackLanguage if (!MI.Get(StreamKind, StreamPos, __T("Language")).empty()) ToReturn+=__T("\t\t\t")+MediaInfoLib::Config.Iso639_2_Get(MI.Get(StreamKind, StreamPos, __T("Language")))+__T("\n"); //essenceTrackAnnotation - all fields (except *_String*) separated by | Ztring Temp; for (size_t Pos=0; Pos"); ToReturn+=Temp; ToReturn+=__T("\n"); } ToReturn+=__T("\t\t\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("\n"); ToReturn+=__T("\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\t***\n"); ToReturn+=__T("\t\t***\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\t***\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\t***\n"); ToReturn+=__T("\t\t***\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\t\n"); //pbcoreFormatID ToReturn+=__T("\t\t\n"); //formatIdentifier ToReturn+=__T("\t\t\t")+MI.Get(Stream_General, 0, General_FileName)+__T("\n"); //formatIdentifierSource ToReturn+=__T("\t\t\tFile Name\n"); ToReturn+=__T("\t\t\n"); //formatDigital if (!MI.Get(Stream_General, 0, General_InternetMediaType).empty()) { ToReturn+=__T("\t\t"); ToReturn+=MI.Get(Stream_General, 0, General_InternetMediaType); ToReturn+=__T("\n"); } else { //TODO: how to implement formats without Media Type? ToReturn+=__T("\t\t"); 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("\n"); } //formatLocation ToReturn+=__T("\t\t")+MI.Get(Stream_General, 0, General_CompleteName)+__T("\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+__T("\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+__T("\n"); } //formatMediaType if (!PBCore_MediaType(MI).empty()) ToReturn+=__T("\t\t")+PBCore_MediaType(MI)+__T("\n"); else ToReturn+=__T("\t\tapplication/octet-stream\n"); //formatGenerations ToReturn+=__T("\t\t\n"); //formatFileSize if (!MI.Get(Stream_General, 0, General_FileSize).empty()) ToReturn+=__T("\t\t")+MI.Get(Stream_General, 0, General_FileSize)+__T("\n"); //formatTimeStart if (!MI.Get(Stream_Video, 0, Video_Delay_Original_String3).empty()) ToReturn+=__T("\t\t")+MI.Get(Stream_Video, 0, Video_Delay_Original_String3)+__T("\n"); else if (!MI.Get(Stream_Video, 0, Video_Delay_String3).empty()) ToReturn+=__T("\t\t")+MI.Get(Stream_Video, 0, Video_Delay_String3)+__T("\n"); //formatDuration if (!MI.Get(Stream_General, 0, General_Duration_String3).empty()) ToReturn+=__T("\t\t")+MI.Get(Stream_General, 0, General_Duration_String3)+__T("\n"); //formatDataRate if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty()) { ToReturn+=__T("\t\t"); 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("\n"); } //formatTracks ToReturn+=__T("\t\t")+Ztring::ToZtring(MI.Count_Get(Stream_Video)+MI.Count_Get(Stream_Audio)+MI.Count_Get(Stream_Image)+MI.Count_Get(Stream_Text))+__T("\n"); //Streams for (size_t StreamKind=Stream_General+1; StreamKind\n"); ToReturn+=__T("\n"); //Carriage return ToReturn.FindAndReplace(__T("\n"), EOL, 0, Ztring_Recursive); return ToReturn; } //*************************************************************************** // //*************************************************************************** } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Export/Export_Mpeg7.cpp0000664000000000000000000022446712652076434021470 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_MPEG7_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Export/Export_Mpeg7.h" #include "MediaInfo/File__Analyse_Automatic.h" #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern MediaInfo_Config Config; //--------------------------------------------------------------------------- //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- Ztring Mpeg7_XML_Encode(const Ztring& Data) { Ztring Result; wstring::size_type Pos; for (Pos = 0; Pos'): Result += __T("≶"); break; default: Result += Data[Pos]; } } return Result; } //--------------------------------------------------------------------------- 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 Sec=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+=(Sec<10?__T("0"):__T(""))+Ztring::ToZtring(Sec)+__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 Sec=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+=(Sec<10?__T("0"):__T(""))+Ztring::ToZtring(Sec)+__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 Sec=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(Sec)+__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 Sec=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(Sec)+__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 Sec=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(Sec)+__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\n"); //Format ToReturn+=__T("\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_VisualCodingFormatCS_Name((VisualCodingFormatCS_termID/10000)*10000, MI, StreamPos); ToReturn+=__T("\n"); if (VisualCodingFormatCS_termID%10000) { ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_VisualCodingFormatCS_Name((VisualCodingFormatCS_termID/100)*100, MI, StreamPos); ToReturn+=__T("\n"); if (VisualCodingFormatCS_termID%100) { ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_VisualCodingFormatCS_Name(VisualCodingFormatCS_termID, MI, StreamPos); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\t\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\n"); } //Frame ToReturn+=__T("\t\t\t\t\t\t\t\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 \n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\tLuminance\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\tChrominanceBlueDifference\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\tChrominanceRedDifference\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\tLuminance\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\tChrominanceBlueDifference\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\tChrominanceRedDifference\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\n"); return ToReturn; } //--------------------------------------------------------------------------- Ztring Mpeg7_Transform_Audio(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos) { ToReturn+=__T("\t\t\t\t\t\t\t\n"); //Format ToReturn+=__T("\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_AudioCodingFormatCS_Name((AudioCodingFormatCS_termID/10000)*10000, MI, StreamPos); ToReturn+=__T("\n"); if (AudioCodingFormatCS_termID%10000) { ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_AudioCodingFormatCS_Name((AudioCodingFormatCS_termID/100)*100, MI, StreamPos); ToReturn+=__T("\n"); if (AudioCodingFormatCS_termID%100) { ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_AudioCodingFormatCS_Name(AudioCodingFormatCS_termID, MI, StreamPos); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\t\n"); //AudioChannels ToReturn+=__T("\t\t\t\t\t\t\t\t"); ToReturn+=MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_); ToReturn+=__T("\n"); //Sample ToReturn+=__T("\t\t\t\t\t\t\t\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_AudioEmphasis(MI, StreamPos)+__T("\n"); //Presentation int32u AudioPresentationCS_termID=Mpeg7_AudioPresentationCS_termID(MI, StreamPos); if (AudioPresentationCS_termID) { ToReturn+=__T("\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t")+Mpeg7_AudioPresentationCS_Name(AudioPresentationCS_termID, MI, StreamPos)+__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\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("\n"); ToReturn+=__T("\n"); ToReturn+=__T("\n"); //Description - DescriptionMetadata { ToReturn+=__T("\t\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")+FileName+__T("\n"); ToReturn+=__T("\t\t")+TimeS+__T("\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\t\t")+MediaInfoLib::Config.Info_Version_Get()+__T("\n"); ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\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\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\t\t\n"); if (!MI.Get(Stream_General, 0, General_Movie).empty()) ToReturn+=__T("\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Movie))+__T("\n"); if (!MI.Get(Stream_General, 0, General_Track).empty()) ToReturn+=__T("\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Title))+__T("\n"); if (!MI.Get(Stream_General, 0, General_Album).empty()) ToReturn+=__T("\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Album))+__T("\n"); if (!MI.Get(Stream_General, 0, General_WrittenBy).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_WrittenBy))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Performer).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Performer))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_ExecutiveProducer).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_ExecutiveProducer))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Producer).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Producer))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Director).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Director))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Composer).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Composer))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_CostumeDesigner).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_CostumeDesigner))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_ProductionDesigner).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_ProductionDesigner))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Publisher).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Publisher))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_DistributedBy).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_DistributedBy))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } if (!MI.Get(Stream_General, 0, General_Encoded_Library).empty()) { ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t")+Mpeg7_XML_Encode(MI.Get(Stream_General, 0, General_Encoded_Library))+__T("\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\n"); } //Description - ContentEntity ToReturn+=__T("\t\n"); //MultimediaContent ToReturn+=__T("\t\t\n"); //(Type) ToReturn+=__T("\t\t\t\n"); //MediaFormat header ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\n"); //Content ToReturn+=__T("\t\t\t\t\t\t\t=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"); ToReturn+=Mpeg7_ContentCS_Name(ContentCS_termID, MI); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\t\n"); //FileFormat if (!MI.Get(Stream_General, 0, General_Format).empty()) { ToReturn+=__T("\t\t\t\t\t\t\t=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"); ToReturn+=Mpeg7_FileFormatCS_Name((FileFormatCS_termID/10000)*10000, MI); ToReturn+=__T("\n"); if (FileFormatCS_termID%10000) { ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_FileFormatCS_Name((FileFormatCS_termID/100)*100, MI); ToReturn+=__T("\n"); if (FileFormatCS_termID%100) { ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_FileFormatCS_Name(FileFormatCS_termID, MI); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\t\t\n"); } //FileSize ToReturn+=__T("\t\t\t\t\t\t\t"); ToReturn+=MI.Get(Stream_General, 0, General_FileSize); ToReturn+=__T("\n"); //System if (!MI.Get(Stream_Video, 0, Video_Standard).empty()) { ToReturn+=__T("\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\t\t"); ToReturn+=Mpeg7_SystemCS_Name(SystemCS_termID); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\t\t\t\n"); } //BitRate if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty()) { ToReturn+=__T("\t\t\t\t\t\t\t"); ToReturn+=MI.Get(Stream_General, 0, General_OverallBitRate); ToReturn+=__T("\n"); } //xxxCoding for (size_t Pos=0; Pos\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\n"); ToReturn+=__T("\t\t\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t\t\n"); } ToReturn+=__T("\t\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\n"); if (MI.Count_Get(Stream_Video)==1 || MI.Count_Get(Stream_Audio)==1) { //MediaTimePoint ToReturn+=__T("\t\t\t\t\n"); ToReturn+=__T("\t\t\t\t\t")+Mpeg7_MediaTimePoint(MI)+__T("\n"); //MediaDuration ToReturn+=__T("\t\t\t\t\t"); ToReturn+=Mpeg7_MediaDuration(MI); ToReturn+=__T("\n"); ToReturn+=__T("\t\t\t\t\n"); } //Mpeg7 footer ToReturn+=__T("\t\t\t\n"); ToReturn+=__T("\t\t\n"); ToReturn+=__T("\t\n"); ToReturn+=__T("\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 //--------------------------------------------------------------------------- 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 > * Stream_, std::vector > * Stream_More_) #else //MEDIAINFO_TRACE void File__Base::Init (MediaInfo_Config_MediaInfo * Config_, std::vector > * Stream_, std::vector > * 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 >; Stream->resize(Stream_Max); Stream_More=new std::vector >; 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()+(StreamNumber>=(*Stream_More)[StreamKind].size()?0:(*Stream_More)[StreamKind][StreamNumber].size()) || KindOfInfo>=Info_Max) return MediaInfoLib::Config.EmptyString_Get(); //Parameter is unknown else if (ParameterInfo_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 #ifdef MEDIAINFO_DEBUG_WARNING_GET #include #endif //MEDIAINFO_DEBUG_WARNING_GET #ifdef MEDIAINFO_DEBUG_BUFFER #include "ZenLib/FileName.h" #include #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 (Config.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 (Config.File_Names[0].rfind(__T('\\'))!=string::npos) \ File_Temp=Config.File_Names[0].substr(Config.File_Names[0].rfind(__T('\\'))+1, string::npos); \ else if (Config.File_Names[0].rfind(__T('/'))!=string::npos) \ File_Temp=Config.File_Names[0].substr(Config.File_Names[0].rfind(__T('/'))+1, string::npos); \ else \ File_Temp=Config.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 (Config.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 (Config.File_Names[0].rfind(__T('\\'))!=string::npos) \ File_Temp=Config.File_Names[0].substr(Config.File_Names[0].rfind(__T('\\'))+1, string::npos); \ else if (Config.File_Names[0].rfind(__T('/'))!=string::npos) \ File_Temp=Config.File_Names[0].substr(Config.File_Names[0].rfind(__T('/'))+1, string::npos); \ else \ File_Temp=Config.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 (Config.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 (Config.File_Names[0].rfind(__T('\\'))!=string::npos) \ File_Temp=Config.File_Names[0].substr(Config.File_Names[0].rfind(__T('\\'))+1, string::npos); \ else if (Config.File_Names[0].rfind(__T('/'))!=string::npos) \ File_Temp=Config.File_Names[0].substr(Config.File_Names[0].rfind(__T('/'))+1, string::npos); \ else \ File_Temp=Config.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::iterator F_Stream=Debug_Output_Value_Stream.find(ValueH); \ if (F_Stream!=Debug_Output_Value_Stream.end()) \ { \ map::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 (_POSOpened_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=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])) { #if defined(MEDIAINFO_REFERENCES_YES) string Dxw; if (Config.File_CheckSideCarFiles_Get() && !Config.File_IsReferenced_Get()) { FileName Test(Config.File_Names[0]); Ztring FileExtension=Test.Extension_Get(); FileExtension.MakeLowerCase(); if (FileExtension!=__T("cap")) { Test.Extension_Set(__T("cap")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("dfxp")) { Test.Extension_Set(__T("dfxp")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("sami")) { Test.Extension_Set(__T("sami")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("sc2")) { Test.Extension_Set(__T("sc2")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("scc")) { Test.Extension_Set(__T("scc")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("smi")) { Test.Extension_Set(__T("smi")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("srt")) { Test.Extension_Set(__T("srt")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("stl")) { Test.Extension_Set(__T("stl")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("ttml")) { Test.Extension_Set(__T("ttml")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("ssa")) { Test.Extension_Set(__T("ssa")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("ass")) { Test.Extension_Set(__T("ass")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("vtt")) { Test.Extension_Set(__T("vtt")); if (File::Exists(Test)) Dxw+=" \r\n"; } if (FileExtension!=__T("xml")) { Test.Extension_Set(__T("xml")); if (File::Exists(Test)) { 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(Test); 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) { Ztring Format=MI.Get(Stream_General, 0, General_Format); if (Format==__T("TTML")) Dxw+=" \r\n"; } } } Ztring Name=Test.Name_Get(); Ztring BaseName=Name.SubString(Ztring(), __T("_")); if (!BaseName.empty()) { ZtringList List; List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_audio.mp4"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.dfxp"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.sami"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.sc2"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.scc"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.smi"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.srt"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.stl"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_sub.vtt"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.dfxp"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.sami"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.sc2"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.scc"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.smi"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.srt"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.stl"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_forcesub.vtt"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.dfxp"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.sami"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.sc2"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.scc"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.smi"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.srt"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.stl"), Dir::Include_Files); List+=Dir::GetAllFileNames(Test.Path_Get()+PathSeparator+BaseName+__T("_*_cc.vtt"), Dir::Include_Files); for (size_t Pos=0; Pos\r\n"; } if (!Dxw.empty()) { Dxw.insert(0, "\r\n" "\r\n" " \r\n"); Dxw.append("\r\n"); Config.File_FileNameFormat_Set(__T("Dxw")); } } if (Dxw.empty()) { 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]); } else { Open_Buffer_Init(Dxw.size(), FileName(Config.File_Names[0]).Path_Get()+PathSeparator+FileName(Config.File_Names[0]).Name_Get()); Open_Buffer_Continue((const int8u*)Dxw.c_str(), Dxw.size()); #if MEDIAINFO_NEXTPACKET if (Config.NextPacket_Get()) return; #endif //MEDIAINFO_NEXTPACKET Open_Buffer_Finalize(); } #else //defined(MEDIAINFO_REFERENCES_YES) 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]); #endif //defined(MEDIAINFO_REFERENCES_YES) #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 (Config.File_Names.size()<=1) //If analyzing multiple files, theses members are adapted in File_Reader.cpp { if (File_Size_!=(int64u)-1) Config.File_Size=Config.File_Current_Size=File_Size_; } if (Info==NULL) { Ztring ForceParser = Config.File_ForceParser_Get(); if (!ForceParser.empty()) { CS.Leave(); SelectFromExtension(ForceParser); CS.Enter(); } if (Info==NULL) { 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_); if (File_Name.empty()) { #if MEDIAINFO_EVENTS { struct MediaInfo_Event_General_Start_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_Start_0); Event.StreamIDs_Size=0; Event.Stream_Size=File_Size_; Event.FileName=NULL; Event.FileName_Unicode=NULL; Config.Event_Send(NULL, (const int8u*)&Event, sizeof(MediaInfo_Event_General_Start_0)); } #endif //MEDIAINFO_EVENTS } 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 (Config.File_Names.size()<=1) //If analyzing multiple files, theses members are adapted in File_Reader.cpp { if (File_Size_!=(int64u)-1) Config.File_Size=Config.File_Current_Size=File_Size_; } 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; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Move_Done, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_Move_Done_0); Event.StreamIDs_Size=0; Event.StreamOffset=File_Offset_; Config.Event_Send(NULL, (const int8u*)&Event, sizeof(MediaInfo_Event_General_Move_Done_0)); } else { struct MediaInfo_Event_General_Start_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_Start_0); Event.StreamIDs_Size=0; Event.Stream_Size=File_Size_; Event.FileName=NULL; Event.FileName_Unicode=NULL; Config.Event_Send(NULL, (const int8u*)&Event, sizeof(MediaInfo_Event_General_Start_0)); } #endif //MEDIAINFO_EVENTS EXECUTE_SIZE_T(1, Debug+=__T("Open_Buffer_Init, will return 1");) } //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED2 size_t MediaInfo_Internal::Open_Buffer_SegmentChange () { MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=__T("Open_Buffer_SegmentChange")) Info->Open_Buffer_SegmentChange(); return 1; } #endif //MEDIAINFO_ADVANCED2 //--------------------------------------------------------------------------- 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_GoToFile_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; PosStatus[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(); } else #endif //defined(MEDIAINFO_READER_NO) { #if MEDIAINFO_NEXTPACKET Config.Demux_EventWasSent=false; #endif //MEDIAINFO_NEXTPACKET Open_Buffer_Continue(NULL, 0); #if MEDIAINFO_NEXTPACKET Demux_EventWasSent=Config.Demux_EventWasSent; if (!Demux_EventWasSent) #endif //MEDIAINFO_NEXTPACKET Open_Buffer_Finalize(); } } 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; PosStatus[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 (ParameterInfo_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 (ParameterRetrieve(StreamKind, StreamPos, "Encoded_Application/String").empty()) return Get(StreamKind, StreamPos, __T("Encoded_Application/String"), KindOfInfo, KindOfSearch); if (Parameter==__T("Encoded_Library") && Info && !Info->Retrieve(StreamKind, StreamPos, "Encoded_Library/String").empty()) return Get(StreamKind, StreamPos, __T("Encoded_Library/String"), 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; PosStatus[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 \""<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 && Info==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; PosOption_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; PosStatus[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); } //--------------------------------------------------------------------------- void MediaInfo_Internal::TestContinuousFileNames () { CriticalSectionLocker CSL(CS); if (Info) Info->TestContinuousFileNames(); } //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS void MediaInfo_Internal::Event_Prepare (struct MediaInfo_Event_Generic* Event) { CriticalSectionLocker CSL(CS); if (Info) Info->Event_Prepare(Event); } #endif // MEDIAINFO_EVENTS } //NameSpace MediaInfoLib/Source/MediaInfo/File__Analyze_MinimizeSize.h0000664000000000000000000020654512652076434022526 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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_OutOfBand ( const int8u* Buffer, size_t Buffer_Size) {File__Analyze::Buffer=Buffer; File__Analyze::Buffer_Size=Buffer_Size; Element_Offset=0; Element_Size=Buffer_Size; Read_Buffer_OutOfBand(); File__Analyze::Buffer=NULL; File__Analyze::Buffer_Size=0; Element_Offset=0; Element_Size=0;} void Open_Buffer_OutOfBand (File__Analyze* Sub, const int8u* Buffer, size_t Buffer_Size); void Open_Buffer_OutOfBand (File__Analyze* Sub) {if (Element_Offset<=Element_Size) Open_Buffer_OutOfBand(Sub, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); Element_Offset=Element_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, bool IsNewPacket=true, float64 Ratio=1.0); void Open_Buffer_Continue (File__Analyze* Sub, size_t Buffer_Size) {if (Element_Offset+Buffer_Size<=Element_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) {if (Element_Offset<=Element_Size) 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 #if MEDIAINFO_ADVANCED2 void Open_Buffer_SegmentChange(); #endif //MEDIAINFO_ADVANCED2 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]; void Event_Prepare (struct MediaInfo_Event_Generic* Event); #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX int8u Demux_Level; //bit 0=frame, bit 1=container, bit 2=elementary (eg MPEG-TS), bit 3=ancillary (e.g. DTVCC), default with frame set bool Demux_random_access; bool Demux_UnpacketizeContainer; bool Demux_IntermediateItemFound; size_t Demux_Offset; int64u Demux_TotalBytes; File__Analyze* Demux_CurrentParser; #endif //MEDIAINFO_DEMUX Ztring File_Name_WithoutDemux; bool PTS_DTS_Needed; enum ts_type { TS_NONE=0, TS_PTS=1, TS_DTS=2, TS_ALL=TS_PTS|TS_DTS, }; void TS_Clear(ts_type Type=TS_ALL); void TS_Set(int64s Ticks, ts_type Type=TS_ALL); void TS_Set(File__Analyze* Parser, ts_type Type=TS_ALL); void TS_Add(int64s Ticks, ts_type Type=TS_ALL); void TS_Ajust(int64s Ticks); int64s Frequency_c; //Frequency of the timestamp of the container (e.g. 90000 for MPEG-PS) int64s Frequency_b; //Frequency of the timestamp of the bitstream (e.g. 48000 for AC-3) #if MEDIAINFO_ADVANCED2 static const int64s NoTs=0x8000000000000000LL; int64s PTSb; //In 1/Frequency_b if sub, in 1/(Frequency_c*Frequency_b) if in a container int64s DTSb; //In 1/Frequency_b if sub, in 1/(Frequency_c*Frequency_b) if in a container #endif //MEDIAINFO_ADVANCED2 struct frame_info { int64u Buffer_Offset_End; int64u PCR; //In nanoseconds int64u PTS; //In nanoseconds int64u DTS; //In nanoseconds int64u DUR; //In nanoseconds #if MEDIAINFO_ADVANCED2 int64s PTSc; //In 1/Frequency_c int64s DTSc; //In 1/Frequency_c int64u Frame_Count_AfterLastTimeStamp; #endif //MEDIAINFO_ADVANCED2 frame_info() { Buffer_Offset_End=(int64u)-1; PCR=(int64u)-1; PTS=(int64u)-1; DTS=(int64u)-1; DUR=(int64u)-1; #if MEDIAINFO_ADVANCED2 PTSc=NoTs; DTSc=NoTs; Frame_Count_AfterLastTimeStamp=0; #endif //MEDIAINFO_ADVANCED2 } }; frame_info FrameInfo; frame_info FrameInfo_Previous; frame_info FrameInfo_Next; std::vector Offsets_Stream; std::vector Offsets_Buffer; size_t Offsets_Pos; int8u* OriginalBuffer; size_t OriginalBuffer_Size; size_t OriginalBuffer_Capacity; #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) struct servicedescriptor { string language; }; typedef std::map servicedescriptors608; typedef std::map servicedescriptors708; struct servicedescriptors { #if defined(MEDIAINFO_EIA608_YES) std::map ServiceDescriptors608; #endif #if defined(MEDIAINFO_EIA708_YES) std::map ServiceDescriptors708; #endif }; servicedescriptors* ServiceDescriptors; #endif //Out int64u PTS_Begin; //In nanoseconds #if MEDIAINFO_ADVANCED2 int64u PTS_Begin_Segment; //In nanoseconds #endif //MEDIAINFO_ADVANCED2 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; int64u FrameNumber_PresentationOrder; bool Synched; //Data is synched bool UnSynched_IsNotJunk; //Data is actually 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_OutOfBand () {}; //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 #if MEDIAINFO_ADVANCED2 virtual void Read_Buffer_SegmentChange () {}; //Temp, should be in File__Base caller #endif //MEDIAINFO_ADVANCED2 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);}; #define Header_Fill_Code2(A,B) Header_Fill_Code(A) 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) #define Element_Parser(_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_BF2_ (float32 &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_BF2(Info, Name) Get_BF2_(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 //*************************************************************************** inline void Get_UUID (int128u &Info) {Get_B16_(Info);} inline void Get_UUID (int128u &Info, const char*) {Get_B16_(Info);} inline void Peek_UUID(int128u &Info) {Peek_B16(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(); inline void Skip_SE() {Skip_UE();} 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_6937_2 (int64u Bytes, Ztring &Info); void Get_ISO_8859_1 (int64u Bytes, Ztring &Info); void Get_ISO_8859_2 (int64u Bytes, Ztring &Info); void Get_ISO_8859_5 (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_6937_2 (int64u Bytes, Ztring &Info, const char*) {Get_ISO_6937_2(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_ISO_8859_5 (int64u Bytes, Ztring &Info, const char*) {Get_ISO_8859_5(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_ISO_6937_2(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_ISO_6937_2(_BYTES, _INFO, _NAME) Ztring _INFO; Info_ISO_6937_2(_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 //*************************************************************************** void Skip_XX(int64u Bytes); inline void Skip_XX(int64u Bytes, const char*) {Skip_XX(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_T4_ (int8u Bits, int32u &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_T4(Bits, Info, Name) Get_T4_(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_T4(int8u Bits, int32u &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_T4_(int8u Bits) {BT->Skip4(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_T4(Bits, Name) Skip_T4_(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_T4(_BITS, _INFO, _NAME) Skip_T4_(_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 (); bool Trusted_Get () {return !Element[Element_Level].UnTrusted;} //*************************************************************************** // 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); inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float64 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, (float32)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, (float32)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 (); static 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 (); //*************************************************************************** // 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 void CodecID_Fill (const Ztring &Value, stream_t StreamKind, size_t StreamPos, infocodecid_format_t Format, stream_t StreamKind_CodecID=Stream_Max); void PixelAspectRatio_Fill (const Ztring &Value, stream_t StreamKind, size_t StreamPos, size_t Parameter_Width, size_t Parameter_Height, size_t Parameter_PixelAspectRatio, size_t Parameter_DisplayAspectRatio); void DisplayAspectRatio_Fill(const Ztring &Value, stream_t StreamKind, size_t StreamPos, size_t Parameter_Width, size_t Parameter_Height, size_t Parameter_PixelAspectRatio, size_t Parameter_DisplayAspectRatio); //*************************************************************************** // 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_Other(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 Streams_Finish_HumanReadable(); void Streams_Finish_HumanReadable_PerStream(stream_t StreamKind, size_t StreamPos, size_t Parameter); 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); //*************************************************************************** // //*************************************************************************** protected : //Save for speed improvement 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 protected : //Buffer bool Open_Buffer_Continue_Loop(); const int8u* Buffer; public : //TO CHANGE size_t Buffer_Size; int64u Buffer_TotalBytes; int64u Buffer_TotalBytes_FirstSynched; int64u Buffer_TotalBytes_LastSynched; int64u Buffer_PaddingBytes; int64u Buffer_JunkBytes; 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: void TestContinuousFileNames(size_t CountOfFiles=24, Ztring FileExtension=Ztring(), bool SkipComputeDelay=false); 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; private : //NextCode std::map NextCode; //BookMarks size_t BookMark_Element_Level; int64u BookMark_GoTo; std::vector BookMark_Code; std::vector 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; bool CA_system_ID_MustSkipSlices; bool FillAllMergedStreams; class streamidentity { public: stream_t StreamKind; size_t StreamPos; streamidentity(stream_t StreamKind_, size_t StreamPos_) : StreamKind(StreamKind_) , StreamPos(StreamPos_) {} }; std::vector MergedStreams_Last; //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, const int8u* OriginalBuffer=NULL, size_t OriginalBuffer_Size=0); 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; //AES #if MEDIAINFO_AES AESdecrypt* AES; int8u* AES_IV; int8u* AES_Decrypted; size_t AES_Decrypted_Size; #endif //MEDIAINFO_AES //Hash #if MEDIAINFO_HASH HashWrapper* Hash; int64u Hash_ParseUpTo; #endif //MEDIAINFO_HASH #if MEDIAINFO_SEEK private: bool Seek_Duration_Detected; #endif //MEDIAINFO_SEEK #if MEDIAINFO_IBIUSAGE public: bool Config_Ibi_Create; int64u Ibi_SynchronizationOffset_Current; int64u Ibi_SynchronizationOffset_BeginOfFrame; ibi Ibi; //If Main only ibi::stream* IbiStream; //If sub only 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_IBIUSAGE 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_IBIUSAGE }; //Helpers #define DETAILS_INFO(_DATA) #endif MediaInfoLib/Source/MediaInfo/MediaInfo_Config_PerPackage.cpp0000664000000000000000000001143512652076434023056 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Config_PerPackage.h" #include "MediaInfo/MediaInfo_Config.h" #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** MediaInfo_Config_PerPackage::MediaInfo_Config_PerPackage() { #if MEDIAINFO_EVENTS Event_CallBackFunction=NULL; Event_UserHandler=NULL; #endif //MEDIAINFO_EVENTS CountOfPackages=(size_t)-1; } MediaInfo_Config_PerPackage::~MediaInfo_Config_PerPackage() { } //*************************************************************************** // Info //*************************************************************************** Ztring MediaInfo_Config_PerPackage::Option (const String &Option, const String &Value) { 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_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"); } //*************************************************************************** // Event //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS bool MediaInfo_Config_PerPackage::Event_CallBackFunction_IsSet () { CriticalSectionLocker CSL(CS); return Event_CallBackFunction?true:false; } #endif //MEDIAINFO_EVENTS //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS Ztring MediaInfo_Config_PerPackage::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 #endif // MEDIAINFO_DEBUG //--------------------------------------------------------------------------- namespace MediaInfoLib { #if MEDIAINFO_READTHREAD void Reader_File_Thread::Entry() { ReadSize_Max=Base->Buffer_Max>>3; for (;;) { Base->CS.Enter(); if (Base->Buffer_Begin==Base->Buffer_Max) { Base->IsLooping=false; Base->Buffer_End=Base->Buffer_End2; Base->Buffer_End2=0; Base->Buffer_Begin=0; } size_t ToRead; size_t Buffer_ToReadOffset; if (Base->IsLooping) { ToRead=Base->Buffer_Begin-Base->Buffer_End2; Buffer_ToReadOffset=Base->Buffer_End2; } else { ToRead=Base->Buffer_Max-Base->Buffer_End; Buffer_ToReadOffset=Base->Buffer_End; } Base->CS.Leave(); if (ToRead) { if (ToRead>ReadSize_Max) ToRead=ReadSize_Max; size_t BytesRead=Base->F.Read(Base->Buffer+Buffer_ToReadOffset, ToRead); if (!BytesRead) break; Base->CS.Enter(); if (Base->IsLooping) { Base->Buffer_End2+=BytesRead; } else { Base->Buffer_End+=BytesRead; if (Base->Buffer_End==Base->Buffer_Max) { Base->IsLooping=true; } } Base->CS.Leave(); #ifdef WINDOWS SetEvent(Base->Condition_WaitingForMoreData); #endif //WINDOWS } #ifdef WINDOWS else WaitForSingleObject(Base->Condition_WaitingForMorePlace, INFINITE); #endif //WINDOWS if (IsTerminating()) break; Yield(); } #ifdef WINDOWS SetEvent(Base->Condition_WaitingForMoreData); //Sending the last event in case the main threading is waiting for more data #endif //WINDOWS } #endif //MEDIAINFO_READTHREAD const size_t Buffer_NoJump=128*1024; //--------------------------------------------------------------------------- Reader_File::~Reader_File() { #if MEDIAINFO_READTHREAD if (ThreadInstance) { ThreadInstance->RequestTerminate(); SetEvent(Condition_WaitingForMorePlace); while (!ThreadInstance->IsExited()) Sleep(0); #ifdef WINDOWS CloseHandle(Condition_WaitingForMorePlace); CloseHandle(Condition_WaitingForMoreData); #endif //WINDOWS delete ThreadInstance; MI_Internal->Config.File_Buffer=NULL; MI_Internal->Config.File_Buffer_Size=0; MI_Internal->Config.File_Buffer_Size_Max=0; delete[] Buffer; } #endif //MEDIAINFO_READTHREAD } //--------------------------------------------------------------------------- size_t Reader_File::Format_Test(MediaInfo_Internal* MI, String File_Name) { //std::cout<Config.Event_Send(NULL, (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) { //Init MI_Internal=MI; #if MEDIAINFO_READTHREAD ThreadInstance=NULL; Buffer_End2=0; //Is also used for counting bytes before activating the thread #endif //MEDIAINFO_READTHREAD //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) { #if MEDIAINFO_ADVANCED if (MI->Config.File_IgnoreSequenceFileSize_Get()) { MI->Config.File_Size=(int64u)-1; } else #endif //MEDIAINFO_ADVANCED { for (size_t Pos=1; PosConfig.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) { if (MI == NULL) return 0; bool StopAfterFilled=MI->Config.File_StopAfterFilled_Get(); bool ShouldContinue=true; if (MI->Info) Status=MI->Info->Status; //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_READTHREAD if (ThreadInstance && !MI->Config.File_Buffer_Repeat) { CS.Enter(); Buffer_Begin+=MI->Config.File_Buffer_Size; #ifdef WINDOWS if (Buffer_Begin==Buffer_Max) { CS.Leave(); SetEvent(Condition_WaitingForMorePlace); } else #endif //WINDOWS CS.Leave(); } #endif //MEDIAINFO_READTHREAD #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<Open_Buffer_Continue_GoTo_Get(); Reader_File_BytesRead=0; Reader_File_Count++; #endif //MEDIAINFO_DEBUG #if MEDIAINFO_READTHREAD if (ThreadInstance) { ThreadInstance->RequestTerminate(); SetEvent(Condition_WaitingForMorePlace); while (!ThreadInstance->IsExited()) Sleep(0); #ifdef WINDOWS CloseHandle(Condition_WaitingForMorePlace); CloseHandle(Condition_WaitingForMoreData); #endif //WINDOWS delete ThreadInstance; ThreadInstance=NULL; MI->Config.File_Buffer=NULL; MI->Config.File_Buffer_Size=0; MI->Config.File_Buffer_Size_Max=0; Buffer_Max=0; delete[] Buffer; Buffer=NULL; Buffer_Begin=0; Buffer_End=0; Buffer_End2=0; IsLooping=false; } if (Buffer_End2!=(size_t)-1) Buffer_End2=0; #endif //MEDIAINFO_READTHREAD 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; #if MEDIAINFO_SEEK if (MI->Config.File_GoTo_IsFrameOffset) { Pos=(size_t)MI->Open_Buffer_Continue_GoTo_Get(); //File_GoTo is the frame offset in that case MI->Info->File_GoTo=(int64u)-1; MI->Config.File_GoTo_IsFrameOffset=false; GoTo=0; } else #endif //MEDIAINFO_SEEK { for (Pos=0; PosConfig.File_Names.size(); Pos++) { if (Pos==MI->Config.File_Sizes.size()) MI->Config.File_Sizes.push_back(F.Size_Get()); else if (MI->Config.File_Sizes[Pos]==(int64u)-1) MI->Config.File_Sizes[Pos]=F.Size_Get(); if (Pos>=MI->Config.File_Sizes.size() || MI->Config.File_Sizes[Pos]==(int64u)-1) break; if (GoToConfig.File_Sizes[Pos]) break; GoTo-=MI->Config.File_Sizes[Pos]; MI->Config.File_Current_Offset+=MI->Config.File_Sizes[Pos]; } if (Pos>=MI->Config.File_Sizes.size()) break; } if (Pos!=MI->Config.File_Names_Pos-1) { F.Close(); F.Open(MI->Config.File_Names[Pos]); if (Pos>=MI->Config.File_Sizes.size()) { MI->Config.File_Sizes.resize(Pos, (int64u)-1); MI->Config.File_Sizes.push_back(F.Size_Get()); } 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() && GoToOpen_Buffer_Init((int64u)-1, MI->Config.File_Current_Offset+F.Position_Get()-Partial_Begin); } } #if MEDIAINFO_READTHREAD if (ThreadInstance==NULL && Buffer_End2!=(size_t)-1 && Buffer_End2>=16*1024*1024) { if (!MI->Config.File_IsGrowing && MI->Config.File_Names.size()==1) { delete[] MI->Config.File_Buffer; MI->Config.File_Buffer=NULL; MI->Config.File_Buffer_Size_Max=0; Buffer_Max=MI->Config.File_Buffer_Read_Size_Get(); Buffer=new int8u[Buffer_Max]; Buffer_Begin=0; Buffer_End=0; Buffer_End2=0; IsLooping=false; #ifdef WINDOWS Condition_WaitingForMorePlace=CreateEvent(NULL, FALSE, FALSE, NULL); Condition_WaitingForMoreData=CreateEvent(NULL, FALSE, FALSE, NULL); #endif //WINDOWS ThreadInstance=new Reader_File_Thread(); ThreadInstance->Base=this; ThreadInstance->Run(); } else Buffer_End2=(size_t)-1; } #endif //MEDIAINFO_READTHREAD //Handling of hints if (MI->Config.File_Buffer_Size_ToRead==0) break; //Problem while config if ( #if MEDIAINFO_READTHREAD ThreadInstance==NULL && #endif //MEDIAINFO_READTHREAD 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]; } //Testing multiple file per stream if ( #if MEDIAINFO_READTHREAD ThreadInstance==NULL && #endif //MEDIAINFO_READTHREAD F.Position_Get()>=F.Size_Get()) { #if MEDIAINFO_ADVANCED2 MI->Open_Buffer_SegmentChange(); #endif //MEDIAINFO_ADVANCED2 if (MI->Config.File_Names_Pos && MI->Config.File_Names_PosConfig.File_Names.size()) { MI->Config.File_Current_Offset+=MI->Config.File_Names_Pos<=MI->Config.File_Sizes.size()?MI->Config.File_Sizes[MI->Config.File_Names_Pos-1]:F.Size_Get(); F.Close(); #if MEDIAINFO_EVENTS MI->Config.Event_SubFile_Start(MI->Config.File_Names[MI->Config.File_Names_Pos]); #endif //MEDIAINFO_EVENTS F.Open(MI->Config.File_Names[MI->Config.File_Names_Pos]); while (!F.Opened_Get()) { if (MI->Config.File_Names_Pos+1Config.File_Names.size()) { MI->Config.File_Names_Pos++; F.Open(MI->Config.File_Names[MI->Config.File_Names_Pos]); } } if (MI->Config.File_Names_Pos>=MI->Config.File_Sizes.size()) { MI->Config.File_Sizes.resize(MI->Config.File_Names_Pos, 0); MI->Config.File_Sizes.push_back(F.Size_Get()); } MI->Config.File_Names_Pos++; MI->Config.File_Current_Size+=F.Size_Get(); } } #if MEDIAINFO_READTHREAD if (ThreadInstance) { CS.Enter(); #ifdef WINDOWS if (Buffer_End2+Buffer_End-Buffer_BeginConfig.File_Buffer_Size=Buffer_End-Buffer_Begin; if (MI->Config.File_Buffer_Size) break; if (!ThreadInstance->IsExited()) { CS.Leave(); #ifdef WINDOWS WaitForSingleObject(Condition_WaitingForMoreData, INFINITE); #else //WINDOWS Sleep(0); #endif //WINDOWS CS.Enter(); } else { if (IsLooping) { IsLooping=false; Buffer_End=Buffer_End2; Buffer_End2=0; Buffer_Begin=0; } MI->Config.File_Buffer_Size=Buffer_End-Buffer_Begin; break; } } MI->Config.File_Buffer=Buffer+Buffer_Begin; CS.Leave(); if (MI->Config.File_Buffer_Size>MI->Config.File_Buffer_Size_ToRead) MI->Config.File_Buffer_Size=MI->Config.File_Buffer_Size_ToRead; } else #endif //MEDIAINFO_READTHREAD { 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()))); #if MEDIAINFO_READTHREAD if (ThreadInstance==NULL && Buffer_End2!=(size_t)-1) Buffer_End2+=MI->Config.File_Buffer_Size; #endif //MEDIAINFO_READTHREAD } /* High CPU usage #if MEDIAINFO_EVENTS if (MI->Config.File_Buffer_Size) { struct MediaInfo_Event_Global_BytesRead_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Global_BytesRead, 0); Event.EventSize=sizeof(struct MediaInfo_Event_Global_BytesRead_0); Event.StreamIDs_Size=0; Event.StreamOffset=F.Position_Get()-MI->Config.File_Buffer_Size; Event.Content_Size=MI->Config.File_Buffer_Size; Event.Content=MI->Config.File_Buffer; MI->Config.Event_Send(NULL, (const int8u*)&Event, sizeof(MediaInfo_Event_Global_BytesRead_0)); } #endif //MEDIAINFO_EVENTS */ //Testing growing files int64u Growing_Temp=(int64u)-1; if (MI->Config.ParseSpeed>=1.0 && !MI->Config.File_IsGrowing && MI->Config.File_Current_Offset+F.Position_Get()>=MI->Config.File_Size) { if (MI->Config.File_Names.size()==1) { Growing_Temp=F.Size_Get(); if (MI->Config.File_Size!=Growing_Temp) MI->Config.File_IsGrowing=true; } else if (MI->Config.File_TestContinuousFileNames_Get()) { Growing_Temp=MI->Config.File_Names.size(); MI->TestContinuousFileNames(); if (MI->Config.File_Names.size()!=Growing_Temp) 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 && (Growing_Temp!=(int64u)-1 || MI->Config.File_Current_Offset+F.Position_Get()>=MI->Config.File_Size)) { for (size_t CountOfSeconds=0; CountOfSeconds<(size_t)MI->Config.File_GrowingFile_Delay_Get(); CountOfSeconds++) { if (MI->Config.File_Names.size()==1) { Growing_Temp=F.Size_Get(); if (MI->Config.File_Size!=Growing_Temp) { MI->Config.File_Current_Size=MI->Config.File_Size=Growing_Temp; MI->Open_Buffer_Init(MI->Config.File_Size, MI->Config.File_Current_Offset+F.Position_Get()-MI->Config.File_Buffer_Size); break; } } else { Growing_Temp=MI->Config.File_Names.size(); MI->TestContinuousFileNames(); if (MI->Config.File_Names.size()!=Growing_Temp) { MI->Open_Buffer_Init(MI->Config.File_Size, MI->Config.File_Current_Offset+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); #if MEDIAINFO_READTHREAD if (ThreadInstance && !MI->Config.File_Buffer_Repeat) { CS.Enter(); Buffer_Begin+=MI->Config.File_Buffer_Size; #ifdef WINDOWS if (Buffer_Begin==Buffer_Max) { CS.Leave(); SetEvent(Condition_WaitingForMorePlace); } else #endif //WINDOWS CS.Leave(); } #endif //MEDIAINFO_READTHREAD if (MI->Config.File_Buffer_Size==0) { #if MEDIAINFO_EVENTS MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0xF0F00101, "File read error"); #endif //MEDIAINFO_EVENTS 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 } } //Deleting buffer #if MEDIAINFO_READTHREAD if (ThreadInstance) { ThreadInstance->RequestTerminate(); SetEvent(Condition_WaitingForMorePlace); while (!ThreadInstance->IsExited()) Sleep(0); #ifdef WINDOWS CloseHandle(Condition_WaitingForMorePlace); CloseHandle(Condition_WaitingForMoreData); #endif //WINDOWS delete ThreadInstance; ThreadInstance=NULL; MI->Config.File_Buffer=NULL; MI->Config.File_Buffer_Size=0; MI->Config.File_Buffer_Size_Max=0; Buffer_Max=0; delete[] Buffer; Buffer=NULL; Buffer_Begin=0; Buffer_End=0; Buffer_End2=0; IsLooping=false; } else #endif //MEDIAINFO_READTHREAD { delete[] MI->Config.File_Buffer; MI->Config.File_Buffer=NULL; MI->Config.File_Buffer_Size_Max=0; } #ifdef MEDIAINFO_DEBUG std::cout<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 MediaInfoLib/Source/MediaInfo/Reader/Reader_libcurl.h0000664000000000000000000000327012652076434021437 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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, 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 MediaInfoLib/Source/MediaInfo/Reader/Reader_libmms.h0000664000000000000000000000250612652076434021267 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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, String File_Name); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Reader/Reader__Base.h0000664000000000000000000000306012652076434021011 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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, 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 MediaInfoLib/Source/MediaInfo/Reader/Reader_libcurl_Include.h0000664000000000000000000012144312652076434023105 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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=) 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) #ifdef _UNICODE #define MEDIAINFODLL_NAME L"libcurl.dll" #else //_UNICODE #define MEDIAINFODLL_NAME "libcurl.dll" #endif //_UNICODE #elif defined(__APPLE__) && defined(__MACH__) #define MEDIAINFODLL_NAME "libcurl.4.dylib" #define __stdcall #else #define MEDIAINFODLL_NAME "libcurl.so.0" #define __stdcall #endif //!defined(_WIN32) || defined (WIN32) #ifdef MEDIAINFO_GLIBC #include static GModule* libcurl_Module=NULL; #elif defined (_WIN32) || defined (WIN32) #undef __TEXT #include static HMODULE libcurl_Module=NULL; #else #include 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 MediaInfoLib/Source/MediaInfo/Reader/Reader_libcurl.cpp0000664000000000000000000013273212652076434022000 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include //For Url #define MEDIAINFO_HMAC 1 #if MEDIAINFO_HMAC #include "hmac.h" #include "base64.h" #endif //MEDIAINFO_HMAC #include "ZenLib/File.h" using namespace ZenLib; using namespace std; #ifdef MEDIAINFO_DEBUG #include #endif // MEDIAINFO_DEBUG //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Helpers //*************************************************************************** namespace Http { //Helpers void CutHead(std::string &Input, std::string &Output, std::string Delimiter) { // Remove the delimiter and everything that precedes size_t Delimiter_Pos = Input.find(Delimiter); if (Delimiter_Pos != std::string::npos) { size_t Begin = Delimiter_Pos + Delimiter.size(); Output = Input.substr(0, Delimiter_Pos); Input = Input.substr(Begin, Input.size() - Begin); } } void CutTail(std::string &Input, std::string &Output, const std::string &Delimiter, bool KeepDelimiter=false) { // Remove the delimiter and everything that follows size_t Delimiter_Pos = Input.find(Delimiter); if (Delimiter_Pos != std::string::npos) { size_t Begin = Delimiter_Pos; if (!KeepDelimiter) Begin+=Delimiter.size(); size_t End = Input.size() - Begin; Output = Input.substr(Begin, End); Input = Input.substr(0, Delimiter_Pos); } } class Url { public: Url(const std::string &In) : Host(In) { CutHead (Host, Protocol, "://" ); CutTail (Host, Search, "?" ); CutHead (Host, User, "@" ); CutTail (Host, Path, "/", true); CutTail (User, Password, ":" ); CutTail (Host, Port, ":" ); std::transform(Protocol.begin(), Protocol.end(), Protocol.begin(), ::tolower); } // Members std::string Protocol; std::string User; std::string Password; std::string Host; std::string Port; std::string Path; std::string Search; }; } 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 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; bool Init_NotAFile; #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 #if MEDIAINFO_EVENTS int64u Stream_Offset; #endif //MEDIAINFO_EVENTS 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; Init_NotAFile=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 #if MEDIAINFO_EVENTS Stream_Offset=(int64u)-1; #endif //MEDIAINFO_EVENTS } }; //--------------------------------------------------------------------------- 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) { Http::Url File_URL=Http::Url(Ztring(((Reader_libcurl::curl_data*)data)->File_Name).To_UTF8()); if (File_URL.Protocol=="http" || File_URL.Protocol=="https") { long http_code = 0; if (curl_easy_getinfo (((Reader_libcurl::curl_data*)data)->Curl, CURLINFO_RESPONSE_CODE, &http_code)!=CURLE_OK || http_code != 200) { MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(((Reader_libcurl::curl_data*)data)->File_Name)+__T(", ")+Ztring().From_UTF8(string((char*)ptr, size*nmemb))); return size*nmemb; } } 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==0) { ((Reader_libcurl::curl_data*)data)->Init_NotAFile=true; return 0; //Great chances it is FTP file listing due to interogation mark in the file name } else 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); #if MEDIAINFO_EVENTS ((Reader_libcurl::curl_data*)data)->Stream_Offset=0; #endif //MEDIAINFO_EVENTS ((Reader_libcurl::curl_data*)data)->Init_AlreadyDone=true; } #if MEDIAINFO_EVENTS if (size*nmemb) { struct MediaInfo_Event_Global_BytesRead_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Global_BytesRead, 0); Event.EventSize=sizeof(struct MediaInfo_Event_Global_BytesRead_0); Event.StreamIDs_Size=0; Event.StreamOffset=((Reader_libcurl::curl_data*)data)->Stream_Offset; Event.Content_Size=size*nmemb; Event.Content=(int8u*)ptr; ((Reader_libcurl::curl_data*)data)->MI->Config.Event_Send(NULL, (const int8u*)&Event, sizeof(MediaInfo_Event_Global_BytesRead_0)); ((Reader_libcurl::curl_data*)data)->Stream_Offset+=size*nmemb; } #endif //MEDIAINFO_EVENTS //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; } 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, 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(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 { string File_Name_Local=Ztring(File_Name).To_Local(); wstring File_Name_Unicode=Ztring(File_Name).To_Unicode(); struct MediaInfo_Event_General_Start_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_General_Start_0)); Event.StreamIDs_Size=0; Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0); Event.Stream_Size=(int64u)-1; Event.FileName=File_Name_Local.c_str(); Event.FileName_Unicode=File_Name_Unicode.c_str(); MI->Config.Event_Send(NULL, (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_PrivateKeyFileName = "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; 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; PosHttpHeader=curl_slist_append(Curl_Data->HttpHeader, HttpHeaderStrings[Pos].To_Local().c_str()); } Http::Url File_URL=Http::Url(Ztring(File_Name).To_UTF8()); if (!File_URL.Protocol.empty()) { // Amazon S3 specific credentials if ((File_URL.Protocol=="http" || File_URL.Protocol=="https") && !File_URL.User.empty() && !File_URL.Password.empty()) { //Exploding the path const string Amazon_AWS_Host(".amazonaws.com"); const size_t Amazon_AWS_Host_Size=14; size_t Amazon_Host_Pos=File_URL.Host.find(Amazon_AWS_Host); if (Amazon_Host_Pos+Amazon_AWS_Host_Size==File_URL.Host.size()) { string Amazon_S3_Bucket; string Amazon_S3_CanonicalizedResource; string Amazon_S3_Host(File_URL.Host, 0, File_URL.Host.size()-Amazon_AWS_Host_Size); size_t Amazon_S3_Host_Pos=Amazon_S3_Host.find('.'); if (Amazon_S3_Host_Pos!=(size_t)-1) { //Virtual-hostedstyle URL Amazon_S3_Bucket=Amazon_S3_Host.substr(0, Amazon_S3_Host_Pos); Amazon_S3_Host.erase(0, Amazon_S3_Host_Pos+1); Amazon_S3_CanonicalizedResource=File_URL.Path.substr(1); } else { //Path-style URL size_t Bucket_Size=File_URL.Path.find('/', 1); if (Bucket_Size!=(size_t)-1) { Amazon_S3_Bucket=File_URL.Path.substr(1, Bucket_Size-1); Amazon_S3_CanonicalizedResource=File_URL.Path.substr(Bucket_Size+1); } } size_t Region_Pos=Amazon_S3_Host.find('-'); if (Region_Pos!=(size_t)-1) Amazon_S3_Host.erase(Region_Pos); if (Amazon_S3_Host=="s3") { // Amazon S3, computing the Authorization value // See http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html Ztring File_Name2(Curl_Data->File_Name); File_Name2.FindAndReplace(Ztring().From_UTF8(File_URL.User+':'+File_URL.Password+'@'), Ztring()); Curl_Data->File_Name=File_Name2; char Amazon_S3_Date_Buffer[100]; time_t Amazon_S3_Date_Time=time(0); strftime(Amazon_S3_Date_Buffer, sizeof(Amazon_S3_Date_Buffer), "%a, %d %b %Y %H:%M:%S +0000", gmtime(&Amazon_S3_Date_Time)); string Amazon_S3_Date(Amazon_S3_Date_Buffer); string Amazon_S3_ToSign = "GET\n\n\n"+Amazon_S3_Date+"\n/"+Amazon_S3_Bucket+"/"+Amazon_S3_CanonicalizedResource; string Hmac_Result; Hmac_Result.resize(HASH_OUTPUT_SIZE); hmac_sha((int8u*)File_URL.Password.c_str(), (unsigned long)File_URL.Password.size(), (int8u*)Amazon_S3_ToSign.c_str(), (unsigned long)Amazon_S3_ToSign.size(), (int8u*)Hmac_Result.c_str(), HASH_OUTPUT_SIZE); string Amazon_S3_Authorization="AWS "+File_URL.User+":"+Base64::encode(Hmac_Result); Curl_Data->HttpHeader=curl_slist_append(Curl_Data->HttpHeader, ("Date: "+Amazon_S3_Date).c_str()); Curl_Data->HttpHeader=curl_slist_append(Curl_Data->HttpHeader, ("Authorization: "+Amazon_S3_Authorization).c_str()); } } } if (File_URL.Protocol=="sftp" || File_URL.Protocol=="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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->File_Name)+__T(", ")+MessageString); } Curl_Data->ErrorBuffer[0]='\0'; #endif //MEDIAINFO_EVENTS return 0; } } if (!Curl_Data->Ssh_IgnoreSecurity) { #if !defined(MEDIAINFO_LIBCURL_DLL_RUNTIME) #if LIBCURL_VERSION_NUM >= 0x071306 #define MEDIAINFO_LIBCURL_CURLOPT_SSH_KNOWNHOSTS #endif #else #define MEDIAINFO_LIBCURL_CURLOPT_SSH_KNOWNHOSTS #endif #ifdef MEDIAINFO_LIBCURL_CURLOPT_SSH_KNOWNHOSTS CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSH_KNOWNHOSTS, Curl_Data->Ssh_KnownHostsFileName.c_str()); #else //MEDIAINFO_LIBCURL_CURLOPT_SSH_KNOWNHOSTS const CURLcode Result=CURLE_UNKNOWN_TELNET_OPTION; #endif //MEDIAINFO_LIBCURL_CURLOPT_SSH_KNOWNHOSTS if (Result) { #if MEDIAINFO_EVENTS if (Result==CURLE_UNKNOWN_TELNET_OPTION) MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0xF1010102, Reader_libcurl_FileNameWithoutPassword(Curl_Data->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(Curl_Data->File_Name)+__T(", ")+MessageString); } Curl_Data->ErrorBuffer[0]='\0'; #endif //MEDIAINFO_EVENTS return 0; } } } if (File_URL.Protocol=="https" || File_URL.Protocol=="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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->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(Curl_Data->File_Name)+__T(", ")+MessageString); #endif //MEDIAINFO_EVENTS return 0; } } } } string FileName_String=Ztring(Curl_Data->File_Name).To_UTF8(); 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); curl_easy_setopt(Curl_Data->Curl, CURLOPT_HTTPHEADER, Curl_Data->HttpHeader); //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<File_Offset-Curl_Data->Debug_BytesRead<<" - "<File_Offset<<" : "<Debug_BytesRead<<" bytes"<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) { #if MEDIAINFO_EVENTS Curl_Data->Stream_Offset=Curl_Data->MI->Open_Buffer_Continue_GoTo_Get(); #endif //MEDIAINFO_EVENTS 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 (Result==CURLE_WRITE_ERROR && Curl_Data->Init_NotAFile) { //Not possible to get the file with UTF-8, trying local code page Curl_Data->Init_NotAFile=false; string FileName_String=Ztring(Curl_Data->File_Name).To_Local(); curl_easy_setopt(Curl_Data->Curl, CURLOPT_URL, FileName_String.c_str()); 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_WRITE_ERROR && Curl_Data->Init_NotAFile) { //Not possible to get the file with UTF-8, trying local code page Curl_Data->Init_NotAFile=false; string FileName_String=Ztring(Curl_Data->File_Name).To_Local(); curl_easy_setopt(Curl_Data->Curl, CURLOPT_URL, FileName_String.c_str()); 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<File_Offset-Curl_Data->Debug_BytesRead<<" - "<File_Offset<<" : "<Debug_BytesRead<<" bytes"<Debug_BytesRead_Total<<" bytes in "<Debug_Count<<" blocks"<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 MediaInfoLib/Source/MediaInfo/Reader/Reader_libmms.cpp0000664000000000000000000001227612652076434021627 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 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, 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 MediaInfoLib/Source/MediaInfo/Reader/Reader_Directory.h0000664000000000000000000000351712652076434021753 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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, 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 MediaInfoLib/Source/MediaInfo/Reader/Reader_File.h0000664000000000000000000000526012652076434020663 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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" #include "ZenLib/Thread.h" #include "ZenLib/CriticalSection.h" #if MEDIAINFO_READTHREAD #ifdef WINDOWS #undef __TEXT #include "Windows.h" #endif //WINDOWS #endif //MEDIAINFO_READTHREAD //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** /// @brief Reader_File //*************************************************************************** #if MEDIAINFO_READTHREAD class Reader_File; class Reader_File_Thread : public Thread { public: Reader_File* Base; size_t ReadSize_Max; void Entry(); }; #endif //MEDIAINFO_READTHREAD class Reader_File : public Reader__Base { public : //Constructor/Destructor virtual ~Reader_File(); //Format testing size_t Format_Test(MediaInfo_Internal* MI, 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; //Thread #if MEDIAINFO_READTHREAD Reader_File_Thread* ThreadInstance; int8u* Buffer; size_t Buffer_Max; size_t Buffer_Begin; size_t Buffer_End; size_t Buffer_End2; //Is also used for counting bytes before activating the thread bool IsLooping; #ifdef WINDOWS HANDLE Condition_WaitingForMorePlace; HANDLE Condition_WaitingForMoreData; #endif //WINDOWS #endif //MEDIAINFO_READTHREAD CriticalSection CS; MediaInfo_Internal* MI_Internal; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Reader/Reader_Directory.cpp0000664000000000000000000002153312652076434022304 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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" #include "ZenLib/FileName.h" using namespace ZenLib; //--------------------------------------------------------------------------- namespace MediaInfoLib { size_t Reader_Directory::Format_Test(MediaInfo_Internal* MI, 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_PosSelectFromExtension(__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_PosSelectFromExtension(__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='0' && Value[0]<='9' && Value[1]>='0' && Value[1]<='9' && Value[2]==':' && Value[3]>='0' && Value[3]<='9' && Value[4]>='0' && Value[4]<='9' && Value[5]==':' && Value[6]>='0' && Value[6]<='9' && Value[7]>='0' && Value[7]<='9' && (Value[8]==':' || Value[8]==';') && Value[9]>='0' && Value[9]<='9' && Value[10]>='0' && Value[10]<='9') { int64u ToReturn=(int64u)(Value[0]-'0')*10*60*60*1000000000 +(int64u)(Value[1]-'0') *60*60*1000000000 +(int64u)(Value[3]-'0') *10*60*1000000000 +(int64u)(Value[4]-'0') *60*1000000000 +(int64u)(Value[6]-'0') *10*1000000000 +(int64u)(Value[7]-'0') *1000000000 +(int64u)(Value[9]-'0') * 333333333 +(int64u)(Value[10]-'0') * 33333333; return ToReturn; } else return (int64u)-1; } //*************************************************************************** // 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; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_Scc::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { GoTo(0); Open_Buffer_Unsynch(); return 1; } #endif //MEDIAINFO_SEEK //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK void File_Scc::Read_Buffer_Unsynched() { if (Parser) Parser->Open_Buffer_Unsynch(); } #endif //MEDIAINFO_SEEK //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK void File_Scc::Read_Buffer_AfterParsing() { if (Parser && File_Offset+Buffer_Size==File_Size) Parser->Open_Buffer_Unsynch(); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Scc::Streams_Finish() { if (Parser && Parser->Status[IsAccepted]) { Finish(Parser); for (size_t Pos2=0; Pos2Count_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("SCC"); return false; } //Element_Size if (Buffer_SizeFrameInfo.DTS=Scc_str2timecode(TimeStamp.c_str()); 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; if (Parser->FrameInfo.DTS!=(int64u)-1) Parser->FrameInfo.DTS+=33333333; } } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_SCC_YES MediaInfoLib/Source/MediaInfo/Text/File_Ttml.h0000664000000000000000000000316512652076434020125 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about TTML files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_TtmlH #define MediaInfo_File_TtmlH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace tinyxml2 { class XMLDocument; class XMLElement; } namespace MediaInfoLib { //*************************************************************************** // Class File_Sami //*************************************************************************** class File_Ttml : public File__Analyze { public : File_Ttml(); #if MEDIAINFO_EVENTS int8u MuxingMode; #endif //MEDIAINFO_EVENTS private : //Streams management void Streams_Accept(); //Buffer - File header bool FileHeader_Begin(); //Buffer - Global 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(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Scte20.h0000664000000000000000000000417012652076434020242 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about SCTE 20 streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Scte20H #define MediaInfo_Scte20H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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_Init(); 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 Streams; size_t Streams_Count; bool Eia608_DisplayEmptyStream; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_N19.cpp0000664000000000000000000004321312652076434020105 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS 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 ""; } } //--------------------------------------------------------------------------- const char* N19_CharacterCodeTable(int16u CCT) { switch (CCT) { case 0x3030 : return "Latin, ISO 6937-2"; case 0x3031 : return "Latin/Cyrillic, ISO 8859-5"; case 0x3032 : return "Latin/Arabic, ISO 8859-6"; case 0x3033 : return "Latin/Greek, ISO 8859-7"; case 0x3034 : return "Latin/Hebrew, ISO 8859-8"; 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 ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_N19::File_N19() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_N19; StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS } //*************************************************************************** // 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)); Get_C2 ( CCT, "CCT - Character Code Table number"); Param_Info1(N19_CharacterCodeTable(CCT)); 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_Height, MNR.To_int32u()); Fill(Stream_Text, 0, Text_Language, N19_LanguageCode(LC)); //Init FirstFrame_TCI=(int64u)-1; #if MEDIAINFO_DEMUX Frame_Count=0; TCO_Latest=(int64u)-1; #endif //MEDIAINFO_DEMUX FILLING_END(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_N19::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { #if MEDIAINFO_DEMUX TCO_Latest=(int64u)-1; #endif //MEDIAINFO_DEMUX GoTo(0x400); Open_Buffer_Unsynch(); return 1; } #endif //MEDIAINFO_SEEK //*************************************************************************** // 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 Ztring TF; 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"); switch (CCT) { case 0x3030 : //Latin ISO 6937-2 Get_ISO_6937_2(112, TF, "TF - Text Field"); break; case 0x3031 : //Latin ISO 8859-5 Get_ISO_8859_5(112, TF, "TF - Text Field"); break; default: //Not yet supported, basic default Get_ISO_8859_1(112, TF, "TF - Text Field"); } #if MEDIAINFO_TRACE TF.FindAndReplace(__T("\x8A"), EOL, 0, Ztring_Recursive); TF.FindAndReplace(__T("\x8F"), Ztring(), 0, Ztring_Recursive); Param_Info1(TF); #endif //MEDIAINFO_TRACE 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 if (Config->ParseSpeed<1.0) //Jumping GoToFromEnd(128, "N19"); FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_N19_YES MediaInfoLib/Source/MediaInfo/Text/File_Pgs.h0000664000000000000000000000232212652076434017730 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Text/File_Pdf.h0000664000000000000000000000556712652076434017726 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PDF files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_PdfH #define MediaInfo_File_PdfH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Sami //*************************************************************************** class File_Pdf : public File__Analyze { public : File_Pdf(); private : //Streams management void Streams_Accept(); //Buffer - File header bool FileHeader_Begin(); void FileHeader_Parse(); //Buffer - Global void Read_Buffer_Continue(); //Buffer - Per element bool Header_Begin(); void Header_Parse(); void Data_Parse(); //Elements void obj(); void xref(); void trailer(); void startxref(); void eof(); void Object_Root(); void Object_Info(); void Object_Metadata(); //Helpers int64u SizeOfLine(); bool Get_Next(string &Key, Ztring &Value); //Returns true if it is an array //Temp enum state { State_ParsingElements, State_Parsing_xref, State_Parsing_startxref, State_Parsing_object, }; state State; //typedef std::map offsets; //offsets Offsets; //Key is offset //offsets::iterator Offsets_Current; typedef std::vector offsets; offsets Offsets; int32u Offsets_Max; enum type { Type_Root, Type_Info, Type_Metadata, Type_Other, }; struct object { int32u Offset; type Type; int32u TopObject; size_t BottomPos; std::vector Bottoms; object() : Offset((int32u)-1), #ifdef __BORLANDC__ Type(type::Type_Other), #else Type(Type_Other), #endif TopObject((int32u)-1), BottomPos((size_t)-1) { } }; typedef std::map objects; objects Objects; //Key is object number objects::iterator Objects_Current; size_t Catalog_Level; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Teletext.h0000664000000000000000000000521612652076434021002 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Teletext streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_TeletextH #define MediaInfo_File_TeletextH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include #include //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Teletext //*************************************************************************** class File_Teletext : public File__Analyze { public : File_Teletext(); ~File_Teletext(); //In #if defined(MEDIAINFO_MPEGPS_YES) bool FromMpegPs; #endif bool IsSubtitle; private : //Streams management void Streams_Fill(); void Streams_Finish(); //Buffer - Synchro bool Synchronize(); bool Synched_Test(); void Synched_Init(); //Buffer - Global void Read_Buffer_Unsynched(); void Read_Buffer_Continue(); //Buffer - Per element void Header_Parse(); void Data_Parse(); //Elements void Character_Fill(wchar_t Character); void HasChanged(); //Streams struct stream { vector CC_Displayed_Values; stream() { CC_Displayed_Values.resize(26); for (size_t PosY=0; PosY<26; ++PosY) CC_Displayed_Values[PosY].resize(40, L' '); } void Clear() { for (size_t PosY=0; PosY<26; ++PosY) for (size_t PosX=0; PosX<40; ++PosX) CC_Displayed_Values[PosY][PosX]=L' '; } }; typedef map streams; //Key is Magazine+PageNumber streams Streams; int16u Stream_HasChanged; //Temp int8u X; int8u Y; std::bitset<16> C; int8u PageNumber; int16u SubCode; int8u CharacterSubset; int64u End; //Ancillary #if defined(MEDIAINFO_MPEGPS_YES) File_Teletext* Parser; #endif }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Teletext.cpp0000664000000000000000000006377512652076434021353 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_TELETEXT_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Text/File_Teletext.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Teletext::File_Teletext() :File__Analyze() { //Configuration ParserName=__T("Teletext"); #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Teletext; StreamIDs_Width[0]=2; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_TRACE Trace_Layers_Update(8); //Stream #endif //MEDIAINFO_TRACE PTS_DTS_Needed=true; IsRawStream=true; MustSynchronize=true; //In #if defined(MEDIAINFO_MPEGPS_YES) FromMpegPs=false; Parser=NULL; #endif IsSubtitle=false; } //--------------------------------------------------------------------------- File_Teletext::~File_Teletext() { } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Teletext::Streams_Fill() { } //--------------------------------------------------------------------------- void File_Teletext::Streams_Finish() { for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { Stream_Prepare(Stream_Text); Fill(Stream_Text, StreamPos_Last, Text_Format, IsSubtitle?"Teletext Subtitle":"Teletext"); Fill(Stream_Text, StreamPos_Last, Text_ID, Ztring::ToZtring(Stream->first, 16)); } } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_Teletext::Synchronize() { //Synchronizing while (Buffer_Offset+3<=Buffer_Size) { while (Buffer_Offset+3<=Buffer_Size) { if (Buffer[Buffer_Offset ]==0x55 && Buffer[Buffer_Offset+1]==0x55 && Buffer[Buffer_Offset+2]==0x27) break; //while() Buffer_Offset++; } if (Buffer_Offset+3<=Buffer_Size) //Testing if size is coherant { if (Buffer_Offset+45==Buffer_Size) break; if (Buffer_Offset+45+3>Buffer_Size) return false; //Wait for more data if (Buffer[Buffer_Offset ]==0x55 && Buffer[Buffer_Offset+1]==0x55 && Buffer[Buffer_Offset+2]==0x27) break; //while() Buffer_Offset++; } } //Must have enough buffer for having header if (Buffer_Offset+3>=Buffer_Size) return false; //Synched is OK if (!Status[IsAccepted]) { //For the moment, we accept only if the file is in sync, the test is not strict enough if (Buffer_Offset) { Reject(); return false; } Accept(); } return true; } //--------------------------------------------------------------------------- bool File_Teletext::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+3>Buffer_Size) return false; //Quick test of synchro if (Buffer[Buffer_Offset ]!=0x55 || Buffer[Buffer_Offset+1]!=0x55 || Buffer[Buffer_Offset+2]!=0x27) { Synched=false; return true; } //We continue return true; } //--------------------------------------------------------------------------- void File_Teletext::Synched_Init() { //Stream Stream_HasChanged=0; //Temp PageNumber=0xFF; SubCode=0x3F7F; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Teletext::Read_Buffer_Unsynched() { for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { Stream_HasChanged=0; for (size_t PosY=0; PosY<26; ++PosY) for (size_t PosX=0; PosX<40; ++PosX) if (Stream->second.CC_Displayed_Values[PosY][PosX]!=L' ') { Stream->second.CC_Displayed_Values[PosY][PosX]=L' '; Stream_HasChanged=Stream->first; } if (Stream_HasChanged) { HasChanged(); Stream_HasChanged=0; } } } 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_Teletext::Read_Buffer_Continue() { #if defined(MEDIAINFO_MPEGPS_YES) if (FromMpegPs) { if (!Status[IsAccepted]) Accept(); Skip_B1( "data_identifier"); while (Element_OffsetMustSynchronize=false; Open_Buffer_Init(Parser); } Element_Code=data_unit_id; int8u Temp[2]; Temp[0]=0x55; Temp[1]=0x55; Demux(Temp, 2, ContentType_MainStream); Demux(Data, 43, ContentType_MainStream); Open_Buffer_Continue(Parser, Data, 43); Element_Offset+=43; } else Skip_XX(data_unit_length-1, "Data"); } } #endif } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Teletext::Header_Parse() { //Parsing if (MustSynchronize) Skip_B2( "Clock run-in"); Skip_B1( "Framing code"); //Magazine and Packet Number (for all packets) X=0, Y=0; bool P1, D1, P2, D2, P3, D3, P4, D4; bool B; BS_Begin_LE(); Element_Begin1("Magazine (X or M)"); Get_TB (P1, "Hamming 8/4"); Get_TB (D1, "Magazine 0"); if (D1) X|=1<<0; Get_TB (P2, "Hamming 8/4"); Get_TB (D2, "Magazine 1"); if (D2) X|=1<<1; Get_TB (P3, "Hamming 8/4"); Get_TB (D3, "Magazine 2"); if (D3) X|=1<<2; Element_Info1(X); Element_End0(); Element_Begin1("Packet Number (Y)"); Get_TB (P4, "Hamming 8/4"); Get_TB (D4, "Packet Number 0"); if (D4) Y|=1<<0; /* { //Hamming 8/4 bool A=P1^D1^D3^D4; bool B=D1^P2^D2^D4; bool C=D1^D2^P3^D3; bool D=P1^D1^P2^D2^P3^D3^P4^D4; if (A && B && C && D) { } else { } } */ Skip_TB( "Hamming 8/4"); Get_TB (B, "Packet Number 1"); if (B) Y|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "Packet Number 2"); if (B) Y|=1<<2; Skip_TB( "Hamming 8/4"); Get_TB (B, "Packet Number 3"); if (B) Y|=1<<3; Skip_TB( "Hamming 8/4"); Get_TB (B, "Packet Number 4"); if (B) Y|=1<<4; if (X==0) X=8; // A packet with a magazine value of 0 is referred to as belonging to magazine 8 Element_Info1(Y); Element_End0(); //Page header if (Y==0) { C.reset(); CharacterSubset=0; Element_Begin1("Page header"); int8u PU=0, PT=0; bool B; Element_Begin1("Page Units"); Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Units 0"); if (B) PU|=1<<0; Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Units 1"); if (B) PU|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Units 2"); if (B) PU|=1<<2; Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Units 3"); if (B) PU|=1<<3; Element_Info1(PU); Element_End0(); Element_Begin1("Page Tens"); Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Tens 0"); if (B) PT|=1<<0; Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Tens 1"); if (B) PT|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Tens 2"); if (B) PT|=1<<2; Skip_TB( "Hamming 8/4"); Get_TB (B, "Page Tens 3"); if (B) PT|=1<<3; Element_Info1(PT); Element_End0(); PageNumber=(PT<<4)|PU; Element_Info1(Ztring::ToZtring(PageNumber, 16)); int8u S1=0, S2=0, S3=0, S4=0; Element_Begin1("Page sub-code 1"); Skip_TB( "Hamming 8/4"); Get_TB (B, "S1 0"); if (B) S1|=1<<0; Skip_TB( "Hamming 8/4"); Get_TB (B, "S1 1"); if (B) S1|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "S1 2"); if (B) S1|=1<<2; Skip_TB( "Hamming 8/4"); Get_TB (B, "S1 3"); if (B) S1|=1<<3; Element_Info1(S1); Element_End0(); Element_Begin1("Page sub-code 2"); Skip_TB( "Hamming 8/4"); Get_TB (B, "S2 0"); if (B) S2|=1<<0; Skip_TB( "Hamming 8/4"); Get_TB (B, "S2 1"); if (B) S2|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "S2 2"); if (B) S2|=1<<2; Skip_TB( "Hamming 8/4"); Get_TB (B, "C4 - Erase Page"); if (B) C[4]=true; Element_Info1(S2); Element_End0(); Element_Begin1("Page sub-code 3"); Skip_TB( "Hamming 8/4"); Get_TB (B, "S3 0"); if (B) S3|=1<<0; Skip_TB( "Hamming 8/4"); Get_TB (B, "S3 1"); if (B) S3|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "S3 2"); if (B) S3|=1<<2; Skip_TB( "Hamming 8/4"); Get_TB (B, "S3 3"); if (B) S3|=1<<3; Element_Info1(S3); Element_End0(); Element_Begin1("Page sub-code 4"); Skip_TB( "Hamming 8/4"); Get_TB (B, "S4 0"); if (B) S4|=1<<0; Skip_TB( "Hamming 8/4"); Get_TB (B, "S4 1"); if (B) S4|=1<<1; Skip_TB( "Hamming 8/4"); Get_TB (B, "C5 - Newsflash"); if (B) C[5]=true; #if MEDIAINFO_TRACE if (B) Element_Info1("Newsflash"); #endif //MEDIAINFO_TRACE Skip_TB( "Hamming 8/4"); Get_TB (B, "C6 - Subtitle"); if (B) C[6]=true; Element_Info1(S4); Element_End0(); Element_Begin1("Control bits"); Skip_TB( "Hamming 8/4"); Get_TB (B, "C7 - Suppress Header"); if (B) C[7]=true; Skip_TB( "Hamming 8/4"); Get_TB (B, "C8 - Update Indicator"); if (B) C[8]=true; Skip_TB( "Hamming 8/4"); Get_TB (B, "C9 - Interrupted Sequence"); if (B) C[9]=true; Skip_TB( "Hamming 8/4"); Get_TB (B, "C10 - Inhibit Display"); if (B) C[10]=true; Skip_TB( "Hamming 8/4"); Get_TB (B, "C11 - Magazine Serial"); if (B) C[11]=true; Skip_TB( "Hamming 8/4"); Get_TB (B, "C12 - Character Subset"); if (B) CharacterSubset |= (1<<2); Skip_TB( "Hamming 8/4"); Get_TB (B, "C13 - Character Subset"); if (B) CharacterSubset |= (1<<1); Skip_TB( "Hamming 8/4"); Get_TB (B, "C14 - Character Subset"); if (B) CharacterSubset |= (1<<0); Element_End0(); SubCode=(S4<<12)|(S3<<8)|(S2<<4)|S1; Element_End0(); } BS_End_LE(); #if MEDIAINFO_TRACE if (C[4]) Element_Info1("Erase Page"); if (C[5]) Element_Info1("Newsflash"); if (C[6]) Element_Info1("Subtitle"); if (C[7]) Element_Info1("Suppress Header"); if (C[8]) Element_Info1("Update Indicator"); if (C[9]) Element_Info1("Interrupted Sequence"); if (C[10]) Element_Info1("Inhibit Display"); if (C[11]) Element_Info1("Magazine Serial"); Element_Info1(Ztring::ToZtring((X<<8)|PageNumber, 16)+__T(':')+Ztring().From_CC2(SubCode)); Element_Info1(Y); #endif // MEDIAINFO_TRACE Header_Fill_Size(45); if (Y==0) { if (Stream_HasChanged) { HasChanged(); Stream_HasChanged=0; } if (C[4]) { stream &Stream=Streams[(X<<8)|PageNumber]; for (size_t PosY=0; PosY<26; ++PosY) for (size_t PosX=0; PosX<40; ++PosX) if (Stream.CC_Displayed_Values[PosY][PosX]!=L' ') { Stream.CC_Displayed_Values[PosY][PosX]=L' '; Stream_HasChanged=(X<<8)|PageNumber; } } } } //--------------------------------------------------------------------------- void File_Teletext::Data_Parse() { if (PageNumber==0xFF) { Skip_XX(Y?40:32, "Junk"); } else if (Y>=26) { Skip_XX(40, "Special commands"); } else { Element_Begin1("Data bytes"); stream &Stream=Streams[(X<<8)|PageNumber]; size_t PosX=Y?0:8; for (; PosX<40; ++PosX) { int8u byte; Get_B1(byte, "Byte"); byte&=0x7F; if (byte<0x20) byte=0x20; Param_Info1(Ztring().From_Local((const char*)&byte, 1)); if (byte!=Stream.CC_Displayed_Values[Y][PosX] && (!C[7] || Y)) // C[7] is "Suppress Header", to be tested when Y==0 { Char Uni; switch (CharacterSubset) { case 0x00: //English switch(byte) { case 0x23: Uni = __T('\0xA3'); break; case 0x24: Uni = __T('$'); break; case 0x40: Uni = __T('@'); break; case 0x5B: Uni = __T('\x2190'); break; case 0x5C: Uni = __T('\xBD'); break; case 0x5D: Uni = __T('\x2192'); break; case 0x5E: Uni = __T('\x2191'); break; case 0x5F: Uni = __T('#'); break; case 0x60: Uni = __T('-'); break; case 0x7B: Uni = __T('\xBC'); break; case 0x7C: Uni = __T('|'); break; case 0x7D: Uni = __T('\xBE'); break; case 0x7E: Uni = __T('\xF7'); break; default: Uni=byte; } break; case 0x04: //French switch(byte) { case 0x23: Uni = __T('\xE9'); break; case 0x24: Uni = __T('\xEF'); break; case 0x40: Uni = __T('\xE0'); break; case 0x5B: Uni = __T('\xEB'); break; case 0x5C: Uni = __T('\xEA'); break; case 0x5D: Uni = __T('\xF9'); break; case 0x5E: Uni = __T('\xEE'); break; case 0x5F: Uni = __T('#'); break; case 0x60: Uni = __T('\xE8'); break; case 0x7B: Uni = __T('\xE2'); break; case 0x7C: Uni = __T('\xF4'); break; case 0x7D: Uni = __T('\xFB'); break; case 0x7E: Uni = __T('\xE7'); break; default: Uni=byte; } break; case 0x05: //Portuguese/Spanish switch(byte) { case 0x23: Uni = __T('\xE7'); break; case 0x24: Uni = __T('$'); break; case 0x40: Uni = __T('\xA1'); break; case 0x5B: Uni = __T('\xE1'); break; case 0x5C: Uni = __T('\xE9'); break; case 0x5D: Uni = __T('\xED'); break; case 0x5E: Uni = __T('\xF3'); break; case 0x5F: Uni = __T('\xFA'); break; case 0x60: Uni = __T('\xBF'); break; case 0x7B: Uni = __T('\xFC'); break; case 0x7C: Uni = __T('\xF1'); break; case 0x7D: Uni = __T('\xE8'); break; case 0x7E: Uni = __T('\xE0'); break; default: Uni=byte; } break; default: Uni=byte; } Stream.CC_Displayed_Values[Y][PosX]=Uni; Stream_HasChanged=(X<<8)|PageNumber; } } Element_End0(); } #if MEDIAINFO_TRACE if (PageNumber==0xFF) { Element_Name("Skip"); } else { Element_Name(Ztring::ToZtring((X<<8)|PageNumber, 16)+__T(':')+Ztring().From_CC2(SubCode)); Element_Info1(Y); if (Y<26) { Element_Info1(Ztring().From_Unicode(Streams[(X<<8)|PageNumber].CC_Displayed_Values[Y])); if (Y==0) { if (C[4]) Element_Info1("Erase Page"); if (C[5]) Element_Info1("Newsflash"); if (C[6]) Element_Info1("Subtitle"); if (C[7]) Element_Info1("Suppress Header"); if (C[8]) Element_Info1("Update Indicator"); if (C[9]) Element_Info1("Interrupted Sequence"); if (C[10]) Element_Info1("Inhibit Display"); if (C[11]) Element_Info1("Magazine Serial"); } } } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- void File_Teletext::HasChanged() { } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_TELETEXT_YES MediaInfoLib/Source/MediaInfo/Text/File_Eia708.h0000664000000000000000000001210312652076434020132 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PGS files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_Eia708H #define MediaInfo_File_Eia708H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include #include //--------------------------------------------------------------------------- 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 - Synchro bool Synchronize(); bool Synched_Test(); //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' '), Attribute(0x00) { } }; 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 > 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 Windows; struct data { vector > CC; }; data Minimal; int8u WindowID; stream() { WindowID=(int8u)-1; } ~stream() { for (size_t Pos=0; Pos Streams; int8u service_number; int8u block_size; bool HasContent; int64u DataDetected; //1 service per bit //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 MediaInfoLib/Source/MediaInfo/Text/File_AribStdB24B37.h0000664000000000000000000001061512652076434021257 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DVB Subtitle streams // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_AribStdB24B37H #define MediaInfo_File_AribStdB24B37H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_AribStdB24B37 //*************************************************************************** class File_AribStdB24B37 : public File__Analyze { public : //Constructor/Destructor File_AribStdB24B37(); ~File_AribStdB24B37(); //In bool HasCcis; bool ParseCcis; bool IsAncillaryData; //enums enum graphic_set { // Table 7-3 Classification of code set and Final Byte GS_Kanji = 0x42, //2-byte GS_Alphanumeric = 0x4A, GS_Hiragana = 0x30, GS_Katakana = 0x31, GS_Mosaic_A = 0x32, GS_Mosaic_B = 0x33, GS_Mosaic_C = 0x34, GS_Mosaic_D = 0x35, GS_PropAscii = 0x36, GS_PropHiragana = 0x37, GS_PropKatakana = 0x38, GS_JisX0201_Katakana = 0x49, GS_Jis_Kanji_Plane1 = 0x39, //2-byte GS_Jis_Kanji_Plane2 = 0x3A, //2-byte GS_AddSymbols = 0x3B, //2-byte GS_Macro = 0x70, GS_G = 0x0000, // G set GS_DRCS = 0x0100, // DRCS set }; private : //Streams management void Streams_Fill(); void Streams_Finish(); //Buffer - Per element void Read_Buffer_Continue(); void Read_Buffer_Unsynched(); //Buffer - Per element void Header_Parse(); void Data_Parse(); //Elements void caption_management(); void caption_statement(); void data_unit_data(int64u End); void Character(int16u CharacterSet, int8u G_Value, int8u FirstByte, int8u SecondByte); void Add(Char Character); void Add(Ztring Character); void DefaultMacro(); void control_code(); void NUL(); void BEL(); void APB(); void APF(); void APD(); void APU(); void CS(); void APR(); void LS1(); void LS0(); void PAPF(); void CAN(); void SS2(); void ESC(); void APS(); void SS3(); void RS(); void US(); void xxF(); void xxZ(); void SZX(); void COL(); void FLC(); void CDC(); void POL(); void WMM(); void MACRO(); void HLC(); void RPC(); void SPL(); void STL(); void CSI(); void TIME(); //Stream struct stream { string ISO_639_language_code; int8u DMF_reception; int8u Format; int16u G[4]; int8u G_Width[4]; int8u GL; // Locked int8u GL_SS; // Single int8u GR; // Locked Ztring Line; stream() { DMF_reception=(int8u)-1; Format=(int8u)-1; // Table 8-2 Initial status G[0]=GS_Kanji; G[1]=GS_Alphanumeric; G[2]=GS_Hiragana; G[3]=GS_DRCS|GS_Macro; G_Width[0]=2; G_Width[1]=1; G_Width[2]=1; G_Width[3]=1; GL=0; GL_SS=0; GR=2; } }; typedef std::vector streams; streams Streams; //Temp void JIS (int8u Row, int8u Column); //Config int8u Caption_conversion_type; //Ancillary #if defined(MEDIAINFO_MPEGTS_YES) File__Analyze* Parser; #endif }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Sdp.cpp0000664000000000000000000002131312652076434020261 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_SDP_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Text/File_Sdp.h" #include "MediaInfo/Text/File_Teletext.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Sdp::File_Sdp() :File__Analyze() { //Configuration ParserName=__T("SDP"); #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Sdp; StreamIDs_Width[0]=2; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_TRACE Trace_Layers_Update(8); //Stream #endif //MEDIAINFO_TRACE PTS_DTS_Needed=true; MustSynchronize=true; } //--------------------------------------------------------------------------- File_Sdp::~File_Sdp() { } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Sdp::Streams_Fill() { Fill(Stream_General, 0, General_Format, "SDP"); } //--------------------------------------------------------------------------- void File_Sdp::Streams_Finish() { for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { if (Stream->second.Parser && Stream->first<0x80) //For the moment, we filter and use only field 1) { Finish(Stream->second.Parser); Merge(*Stream->second.Parser); //Fill(Stream_Text, StreamPos_Last, Text_ID, Ztring::ToZtring((Stream->first&0x80)?2:1)+__T('-')+Ztring::ToZtring(Stream->first&0x1F)+__T("-")+Stream->second.Parser->Get(Stream_Text, 0, Text_ID), true); Fill(Stream_Text, StreamPos_Last, Text_ID, Stream->second.Parser->Get(Stream_Text, 0, Text_ID), true); } } } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_Sdp::Synchronize() { //Synchronizing while (Buffer_Offset+2Buffer_Size) return false; //Wait for more data if (Buffer[Buffer_Offset+Buffer[Buffer_Offset+2] ]==0x51 && Buffer[Buffer_Offset+Buffer[Buffer_Offset+2]+1]==0x15) break; //while() Buffer_Offset++; } } //Must have enough buffer for having header if (Buffer_Offset+2>=Buffer_Size) return false; //Synched is OK if (!Status[IsAccepted]) { //For the moment, we accept only if the file is in sync, the test is not strict enough if (Buffer_Offset) { Reject(); return false; } Accept(); } return true; } //--------------------------------------------------------------------------- bool File_Sdp::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+3>Buffer_Size) return false; //Quick test of synchro if (Buffer[Buffer_Offset ]!=0x51 || Buffer[Buffer_Offset+1]!=0x15) { Synched=false; return true; } //We continue return true; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Sdp::Read_Buffer_Unsynched() { for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { if (Stream->second.Parser) { Stream->second.Parser->Open_Buffer_Unsynch(); } } } //*************************************************************************** // Buffer - Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Sdp::Header_Parse() { //Parsing int8u Length, FormatCode; Skip_B2( "Identifier"); Get_B1 (Length, "Length"); Get_B1 (FormatCode, "Format Code"); for (int8u Pos=0; Pos<5; Pos++) { FieldLines[Pos]=0; #if MEDIAINFO_TRACE Element_Begin1("Field/Line"); BS_Begin(); Info_SB( Field, "Field Number"); Info_S1(2, Reserved, "Reserved"); Info_S1(5, Line, "Line Number"); BS_End(); FieldLines[Pos]=((Field?1:0)<<7) |(Reserved<<5) | Line; //Removing field information ((Field?1:0)<<7) | if (FieldLines[Pos]) { Element_Info1(Field?2:1); Element_Info1(Line); } else Element_Info1("None"); Element_End0(); #else //MEDIAINFO_TRACE Get_B1(FieldLines[Pos], "Field/Line"); FieldLines[Pos]&=0x7F; //Removing field information #endif //MEDIAINFO_TRACE } if (IsSub) Header_Fill_Size(Buffer_Size); else Header_Fill_Size(Length); } //--------------------------------------------------------------------------- void File_Sdp::Data_Parse() { Element_Name("Packet"); for (int8u Pos=0; Pos<5; Pos++) { if (FieldLines[Pos]) { Element_Code=(int64u)-1; stream &Stream=Streams[0]; if (Stream.Parser==NULL) { Stream.Parser=new File_Teletext(); Stream.Parser->IsSubtitle=true; Open_Buffer_Init(Stream.Parser); } if (Stream.Parser->PTS_DTS_Needed) Stream.Parser->FrameInfo=FrameInfo; Demux(Buffer+Buffer_Offset+Element_Offset, 45, ContentType_MainStream); Open_Buffer_Continue(Stream.Parser, Buffer+Buffer_Offset+Element_Offset, 45); Element_Offset+=45; } } Element_Begin1("SDP Footer"); Skip_B1( "Footer ID"); Skip_B2( "Footer Sequence number"); Skip_B1( "SDP Cheksum"); if (Element_Offset regions; //Key is region_id }; struct subtitle_stream_data { std::map pages; //Key is page_id }; std::map subtitle_streams; //Key is subtitle_stream_id }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Ttml.cpp0000664000000000000000000002056012652076434020456 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_TTML_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Text/File_Ttml.h" #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #include "tinyxml2.h" #include using namespace tinyxml2; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Utils //*************************************************************************** int64u Ttml_str2timecode(const char* Value) { size_t Length=strlen(Value); if (Length>=8 && Value[0]>='0' && Value[0]<='9' && Value[1]>='0' && Value[1]<='9' && Value[2]==':' && Value[3]>='0' && Value[3]<='9' && Value[4]>='0' && Value[4]<='9' && Value[5]==':' && Value[6]>='0' && Value[6]<='9' && Value[7]>='0' && Value[7]<='9') { int64u ToReturn=(int64u)(Value[0]-'0')*10*60*60*1000000000 +(int64u)(Value[1]-'0') *60*60*1000000000 +(int64u)(Value[3]-'0') *10*60*1000000000 +(int64u)(Value[4]-'0') *60*1000000000 +(int64u)(Value[6]-'0') *10*1000000000 +(int64u)(Value[7]-'0') *1000000000; if (Length>=9 && (Value[8]=='.' || Value[8]==',')) { if (Length>9+9) Length=9+9; //Nanoseconds max const char* Value_End=Value+Length; Value+=9; int64u Multiplier=100000000; while (Value=2 && Value[Length-1]=='s') { return (int64u)(atof(Value)*1000000000); } else return (int64u)-1; } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Ttml::File_Ttml() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Ttml; StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS //Init Frame_Count=0; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Ttml::Streams_Accept() { Fill(Stream_General, 0, General_Format, "TTML"); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, "Format", "TTML"); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Ttml::Read_Buffer_Unsynched() { GoTo(0); } //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_Ttml::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { Open_Buffer_Unsynch(); return 1; } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Ttml::FileHeader_Begin() { //All should be OK... return true; } //--------------------------------------------------------------------------- void File_Ttml::Read_Buffer_Continue() { tinyxml2::XMLDocument document; if (!FileHeader_Begin_XML(document)) return; XMLElement* Root=document.FirstChildElement("tt"); if (!Root) { Reject(); return; } if (!Status[IsAccepted]) { Accept(); #if MEDIAINFO_EVENTS MuxingMode=(int8u)-1; if (StreamIDs_Size>=2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mpeg4) MuxingMode=11; //MPEG-4 if (StreamIDs_Size>2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mxf) //Only if referenced MXF MuxingMode=13; //MXF #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet()) return; // Waiting for NextPacket #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET } tinyxml2::XMLElement* div=NULL; #if MEDIAINFO_EVENTS tinyxml2::XMLElement* p=NULL; #endif //MEDIAINFO_EVENTS for (XMLElement* tt_element=Root->FirstChildElement(); tt_element; tt_element=tt_element->NextSiblingElement()) { //body if (!strcmp(tt_element->Value(), "body")) { for (XMLElement* body_element=tt_element->FirstChildElement(); body_element; body_element=body_element->NextSiblingElement()) { //div if (!strcmp(body_element->Value(), "div")) { for (XMLElement* div_element=body_element->FirstChildElement(); div_element; div_element=div_element->NextSiblingElement()) { //p if (!strcmp(div_element->Value(), "p")) { div=body_element; #if MEDIAINFO_EVENTS p=div_element; #endif //MEDIAINFO_EVENTS break; } } if (div) break; } } if (div) break; } } #if MEDIAINFO_DEMUX Demux(Buffer, Buffer_Size, ContentType_MainStream); #endif //MEDIAINFO_DEMUX // Output #if MEDIAINFO_EVENTS for (; p; p=p->NextSiblingElement()) { //p if (!strcmp(p->Value(), "p")) { const char* Attribute; int64u DTS_Begin=(int64u)-1; Attribute=p->Attribute("begin"); if (Attribute) DTS_Begin=Ttml_str2timecode(Attribute); int64u DTS_End=(int64u)-1; Attribute=p->Attribute("end"); if (Attribute) DTS_End=Ttml_str2timecode(Attribute); string ContentUtf8; XMLPrinter printer; p->Accept(&printer); ContentUtf8+=printer.CStr(); while (!ContentUtf8.empty() && (ContentUtf8[ContentUtf8.size()-1]=='\r' || ContentUtf8[ContentUtf8.size()-1]=='\n')) ContentUtf8.resize(ContentUtf8.size()-1); Ztring Content; if (p->FirstChild()) Content.From_UTF8(p->FirstChild()->Value()); Frame_Count++; } } #endif //MEDIAINFO_EVENTS Buffer_Offset=Buffer_Size; } } //NameSpace #endif //MEDIAINFO_TTML_YES MediaInfoLib/Source/MediaInfo/Text/File_TimedText.cpp0000664000000000000000000001006112652076434021440 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_TIMEDTEXT_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Text/File_TimedText.h" #include "tinyxml2.h" using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_TimedText::File_TimedText() { //Configuration ParserName=__T("Timed Text"); //Temp #ifdef MEDIAINFO_MPEG4_YES IsChapter=false; #endif //MEDIAINFO_MPEG4_YES } //*************************************************************************** // Buffer - Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_TimedText::Header_Parse() { //Parsing int16u Size; Get_B2 (Size, "Size"); //Filling Header_Fill_Code(0, "Block"); Header_Fill_Size(Element_Offset+Size); //TODO: if IsChapter, it may be UTF-16 (with BOM), it may also be followed by an encd atom (e.g. for UTF-8 00 00 00 0C 65 6E 63 64 00 00 01 00) } //--------------------------------------------------------------------------- void File_TimedText::Data_Parse() { //Parsing Ztring Value; Get_UTF8 (Element_Size, Value, "Value"); FILLING_BEGIN(); if (!Status[IsAccepted]) { Accept(); #ifdef MEDIAINFO_MPEG4_YES if (IsChapter) { Stream_Prepare(Stream_Menu); } else #endif //MEDIAINFO_MPEG4_YES { Stream_Prepare(Stream_Text); } Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Timed Text"); #ifdef MEDIAINFO_MPEG4_YES if (IsChapter) Fill(StreamKind_Last, StreamPos_Last, Menu_Chapters_Pos_Begin, Count_Get(StreamKind_Last, StreamPos_Last), 10, true); #endif //MEDIAINFO_MPEG4_YES } #ifdef MEDIAINFO_MPEG4_YES if (IsChapter) { } else #endif //MEDIAINFO_MPEG4_YES { Finish(); } #ifdef MEDIAINFO_MPEG4_YES if (IsChapter && FrameInfo.DTS!=(int64u)-1 && Buffer_Offset==2) { Fill(Stream_Menu, StreamPos_Last, Ztring().Duration_From_Milliseconds(FrameInfo.DTS/1000000).To_UTF8().c_str(), Value); Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, StreamPos_Last), 10, true); } #endif //MEDIAINFO_MPEG4_YES FILLING_END(); Element_Offset=Buffer_Size-Buffer_Offset; //Buffer can also contain atoms after the text, ignoring them } } //NameSpace #endif //MEDIAINFO_TIMEDTEXT_YES MediaInfoLib/Source/MediaInfo/Text/File_Scte20.cpp0000664000000000000000000002771312652076434020605 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #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; PosParser && 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; Pos2Parser->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); } Ztring LawRating=Streams[Pos]->Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Streams[Pos]->Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } } //--------------------------------------------------------------------------- void File_Scte20::Streams_Finish() { Clear(Stream_Text); //Per stream for (size_t Pos=0; PosParser && 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_Init() { //Global information #if defined(MEDIAINFO_EIA608_YES) Config->File_Scte20_IsPresent=true; #endif //defined(MEDIAINFO_EIA608_YES) //Configuration Eia608_DisplayEmptyStream=Config->File_Eia608_DisplayEmptyStream_Get(); } //--------------------------------------------------------------------------- void File_Scte20::Read_Buffer_Unsynched() { //Parsing for (size_t Pos=0; PosParser) 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; PosParser==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(); FILLING_BEGIN(); //Filled if (!Status[IsAccepted] && Eia608_DisplayEmptyStream) { Accept("SCTE 20"); //TODO: merge duplicated content for (int8u cc_type=0; cc_type<2; cc_type++) { //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); Streams[cc_type]->Parser->Accept(); } } } FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_SCTE20_YES MediaInfoLib/Source/MediaInfo/Text/File_Cmml.h0000664000000000000000000000237712652076434020101 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Text/File_N19.h0000664000000000000000000000313412652076434017550 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about N19 files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_N19H #define MediaInfo_File_N19H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_N19 //*************************************************************************** class File_N19 : public File__Analyze { public : File_N19(); private : //Buffer - File header bool FileHeader_Begin(); void FileHeader_Parse(); //Buffer - Global #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(); //Temp int64u FirstFrame_TCI; int64u DFC; int16u CCT; #if MEDIAINFO_DEMUX int64u TCO_Latest; #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_DvbSubtitle.cpp0000664000000000000000000004307512652076434021773 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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::iterator subtitle_stream=subtitle_streams.begin(); subtitle_stream!=subtitle_streams.end(); ++subtitle_stream) for (std::map::iterator page=subtitle_stream->second.pages.begin(); page!=subtitle_stream->second.pages.end(); ++page) for (std::map::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) 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_OffsetBuffer_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 0x12 : CLUT_definition_segment(); break; case 0x13 : object_data_segment(); break; case 0x14 : display_definition_segment(); break; case 0x80 : end_of_display_set_segment(); break; case 0xFF : end_of_PES_data_field_marker(); return; default : if (Element_Code>=0x40 && Element_Code<=0x7F) reserved_for_future_use(); else if (Element_Code>=0x81 && Element_Code<=0xEF) private_data(); else 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_OffsetFrame_Count_Valid) { Fill(); Finish(); } } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_DVBSUBTITLE_YES MediaInfoLib/Source/MediaInfo/Text/File_TimedText.h0000664000000000000000000000256512652076434021117 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Timed Text (MPEG-4 Part 17) // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_TimedTextH #define MediaInfo_File_TimedTextH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Sami //*************************************************************************** class File_TimedText : public File__Analyze { public: //Constructor/Destructor File_TimedText(); #ifdef MEDIAINFO_MPEG4_YES bool IsChapter; #endif //MEDIAINFO_MPEG4_YES private : //Buffer - Per element void Header_Parse(); void Data_Parse(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Cdp.h0000664000000000000000000000523712652076434017715 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Caption Distribution Packet files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_CdpH #define MediaInfo_File_CdpH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.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 //--------------------------------------------------------------------------- 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(); //Buffer - Synchro bool Synchronize(); bool Synched_Test(); //Buffer - Per element void Header_Parse(); void Data_Parse(); //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 Streams; size_t Streams_Count; //Temp int8u cdp_frame_rate; int8u cdp_length; //Helpers void CreateStream(int8u Parser_Pos); //Tests int8u cdp_length_Min; int8u cdp_length_Max; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Cdp.cpp0000664000000000000000000006327612652076434020257 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #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; MustSynchronize=true; //In AspectRatio=0; //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; //Temp cdp_frame_rate=(int8u)-1; //Descriptors #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) ServiceDescriptors=new File__Analyze::servicedescriptors; #endif //cdp_length cdp_length_Min=(int8u)-1; cdp_length_Max=0; } //--------------------------------------------------------------------------- File_Cdp::~File_Cdp() { for (size_t Pos=0; PosParser && 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; Pos2Parser->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"); if (cdp_frame_rate!=(int8u)-1) Fill(Stream_Text, StreamPos_Last, Text_FrameRate, Cdp_cdp_frame_rate(cdp_frame_rate)); Fill(Stream_Text, StreamPos_Last, Text_ID, Streams[Pos]->Parser->Retrieve(Stream_Text, Pos2, Text_ID), true); //cdp_length if (cdp_length_Min<=cdp_length_Max) { Fill(Stream_Text, StreamPos_Last, "cdp_length_Min", cdp_length_Min, 10, true); Fill(Stream_Text, StreamPos_Last, "cdp_length_Max", cdp_length_Max, 10, true); (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("cdp_length_Min"), Info_Options)=__T("N NT"); (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("cdp_length_Max"), Info_Options)=__T("N NT"); } } Ztring LawRating=Streams[Pos]->Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Streams[Pos]->Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } } //--------------------------------------------------------------------------- void File_Cdp::Streams_Finish() { Clear(Stream_Text); //Per stream for (size_t Pos=0; PosParser && 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; PosParser) Streams[Pos]->Parser->Open_Buffer_Unsynch(); } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_Cdp::Synchronize() { //Synchronizing while (Buffer_Offset+3<=Buffer_Size) { while (Buffer_Offset+3<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x96 || Buffer[Buffer_Offset+1]!=0x69)) { Buffer_Offset++; while (Buffer_OffsetBuffer_Size) break; //CRC int8u CRC=0; int8u cdp_length=Buffer[Buffer_Offset+2]; //Must have enough buffer for having header if (Buffer_Offset+cdp_length>Buffer_Size) return false; const int8u* Buffer_Temp=Buffer+Buffer_Offset; const int8u* Buffer_End=Buffer+Buffer_Offset+cdp_length; while (Buffer_TempBuffer_Size) { if (Buffer_Offset+3==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x9669) Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x9669) Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x96) Buffer_Offset++; return false; } //Synched is OK return true; } //--------------------------------------------------------------------------- bool File_Cdp::Synched_Test() { //Must have enough buffer for having header if (Buffer_Offset+3>Buffer_Size) return false; //Quick test of synchro if (Buffer[Buffer_Offset ]!=0x96 || Buffer[Buffer_Offset+1]!=0x69) Synched=false; if (Synched) { //CRC int8u CRC=0; int8u cdp_length=Buffer[Buffer_Offset+2]; //Must have enough buffer for having header if (Buffer_Offset+cdp_length>Buffer_Size) return false; const int8u* Buffer_Temp=Buffer+Buffer_Offset; const int8u* Buffer_End=Buffer+Buffer_Offset+cdp_length; while (Buffer_TempElement_Size) End=Element_Size; while(Element_Offset=0x75 && section_id<=0xEF) future_section(); else Skip_XX(Element_Size-Element_Offset, "Unknown"); } } if (!IsSub) Element_End1("CDP"); } FILLING_BEGIN(); Frame_Count++; if (!IsSub && Config->ParseSpeed<1.0 && Frame_Count>=300) Finish(); FILLING_END(); } //--------------------------------------------------------------------------- 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(); } } //*************************************************************************** // Functions //*************************************************************************** //--------------------------------------------------------------------------- void File_Cdp::cdp_header() { Element_Begin1("cdp_header"); int16u cdp_identifier; Get_B2 ( cdp_identifier, "cdp_identifier"); Get_B1 ( cdp_length, "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(); //cdp_length if (cdp_length>cdp_length_Max) cdp_length_Max=cdp_length; if (cdp_length=2 && !Streams[2] && Config->File_Eia708_DisplayEmptyStream_Get()) CreateStream(2); #endif //MEDIAINFO_ADVANCED 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 //Stream creation if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream); #endif //MEDIAINFO_DEMUX 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) } #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser->ServiceDescriptors=ServiceDescriptors; #endif 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; PosServiceDescriptors708[caption_service_number].language=language; #endif } else { #if defined(MEDIAINFO_EIA708_YES) ServiceDescriptors->ServiceDescriptors608[line21_field?1:0].language=language; #endif } #endif //Stream creation int8u Parser_Pos; if (digital_cc) //line21 Parser_Pos = 2; else Parser_Pos= (line21_field ? 1 : 0); //cc_type 2 and 3 are for the same text if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); FILLING_END(); } 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(); } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- void File_Cdp::CreateStream(int8u Parser_Pos) { if (Streams[Parser_Pos]) return; //Already done //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; #endif //MEDIAINFO_DEMUX //Creation of the parser Streams[Parser_Pos]=new stream; #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (Parser_Pos<2) { #if defined(MEDIAINFO_EIA608_YES) Streams[Parser_Pos]->Parser=new File_Eia608(); ((File_Eia608*)Streams[Parser_Pos]->Parser)->cc_type=Parser_Pos; #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) } #else //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser=new File__Analyze(); #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) //Init Streams[Parser_Pos]->Parser->ServiceDescriptors=ServiceDescriptors; Open_Buffer_Init(Streams[Parser_Pos]->Parser); Streams[Parser_Pos]->Parser->Accept(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_CDP_YES MediaInfoLib/Source/MediaInfo/Text/File_Eia608.cpp0000664000000000000000000013423612652076434020500 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 ParserName=__T("EIA-608"); 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; } //--------------------------------------------------------------------------- File_Eia608::~File_Eia608() { for (size_t Pos=0; PosFile_Eia608_DisplayEmptyStream_Get() && Streams.size()<2) Streams.resize(2); if (!HasContent && ServiceDescriptors && ServiceDescriptors->ServiceDescriptors608.find(cc_type)!=ServiceDescriptors->ServiceDescriptors608.end()) { TextMode=0; DataChannelMode=0; Special_14(0x20); //CC1/CC3 fake RCL - Resume Caption Loading } for (size_t Pos=0; PosFile_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=Pos<2?"CC":"T"; ID+='1'+(cc_type*2)+(Pos%2); Fill(Stream_Text, StreamPos_Last, Text_ID, ID); Fill(Stream_Text, StreamPos_Last, "CaptionServiceName", ID); (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("CaptionServiceName"), Info_Options)=__T("N NT"); } if (Config->ParseSpeed>=1.0) { Fill(Stream_Text, StreamPos_Last, "CaptionServiceContent_IsPresent", DataDetected[Pos+1]?"Yes":"No", Unlimited, true, true); //1 bit per service, starting at 1 (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("CaptionServiceContent_IsPresent"), Info_Options)=__T("N NT"); } if (ServiceDescriptors) { servicedescriptors608::iterator ServiceDescriptor=ServiceDescriptors->ServiceDescriptors608.find(cc_type); if (ServiceDescriptor!=ServiceDescriptors->ServiceDescriptors608.end()) { if (Pos==0 && Retrieve(Stream_Text, StreamPos_Last, Text_Language).empty()) //Only CC1/CC3 Fill(Stream_Text, StreamPos_Last, Text_Language, ServiceDescriptor->second.language, true); Fill(Stream_Text, StreamPos_Last, "CaptionServiceDescriptor_IsPresent", "Yes", Unlimited, true, true); (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("CaptionServiceDescriptor_IsPresent"), Info_Options)=__T("N NT"); } else //ServiceDescriptors pointer is for the support by the transport layer of the info { Fill(Stream_Text, StreamPos_Last, "CaptionServiceDescriptor_IsPresent", "No", Unlimited, true, true); (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("CaptionServiceDescriptor_IsPresent"), Info_Options)=__T("N NT"); } } } } //--------------------------------------------------------------------------- void File_Eia608::Streams_Finish() { } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- void File_Eia608::Read_Buffer_Unsynched() { for (size_t StreamPos=0; StreamPosCC_Displayed.size(); Pos_Y++) { for (size_t Pos_X=0; Pos_XCC_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; #if MEDIAINFO_EVENTS TextMode=true; DataChannelMode=true; HasChanged(); TextMode=true; DataChannelMode=false; HasChanged(); TextMode=false; DataChannelMode=true; HasChanged(); TextMode=false; DataChannelMode=false; HasChanged(); #endif //MEDIAINFO_EVENTS } //*************************************************************************** // 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=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=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; DataDetected[5]=true; //bit 5=XDS } //--------------------------------------------------------------------------- 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 } Clear(Stream_General, 0, General_LawRating); int8u a1a0=(XDS_Data[XDS_Level][2]>>3)&0x3; const char* ContentAdvisory=NULL; string ContentDescriptors; switch (a1a0) { case 0: case 2: switch (XDS_Data[XDS_Level][2]&0x7) //r2r1r0 { case 0 : ContentAdvisory="N/A"; break; case 1 : ContentAdvisory="G"; break; case 2 : ContentAdvisory="PG"; break; case 3 : ContentAdvisory="PG-13"; break; case 4 : ContentAdvisory="R"; break; case 5 : ContentAdvisory="NC-17"; break; case 6 : ContentAdvisory="C"; break; default: ; } break; case 1: switch (XDS_Data[XDS_Level][3]&0x7) //g2g1g0 { case 0 : ContentAdvisory="None"; break; case 1 : ContentAdvisory="TV-Y"; break; case 2 : ContentAdvisory="TV-Y7"; break; case 3 : ContentAdvisory="TV-G"; break; case 4 : ContentAdvisory="TV-PG"; break; case 5 : ContentAdvisory="TV-14"; break; case 6 : ContentAdvisory="TV-MA"; break; case 7 : ContentAdvisory="None"; break; default: ; } if (XDS_Data[XDS_Level][2]&0x20) //Suggestive dialogue ContentDescriptors+='D'; if (XDS_Data[XDS_Level][3]&0x8) //Coarse language ContentDescriptors+='L'; if (XDS_Data[XDS_Level][3]&0x10) //Sexual content ContentDescriptors+='S'; if (XDS_Data[XDS_Level][3]&0x20) //Violence { if ((XDS_Data[XDS_Level][3]&0x7)==2) //"TV-Y7" --> Fantasy Violence ContentDescriptors+="FV"; else ContentDescriptors+='V'; } break; case 3: if (XDS_Data[XDS_Level][3]&0x8) //a3 { ContentAdvisory="(Reserved)"; } else { if (XDS_Data[XDS_Level][2]&0x20) //a2 switch (XDS_Data[XDS_Level][3]&0x7) //g2g1g0 { case 0 : ContentAdvisory="E"; break; case 1 : ContentAdvisory="G"; break; case 2 : ContentAdvisory="8+"; break; case 3 : ContentAdvisory="13+"; break; case 4 : ContentAdvisory="16+"; break; case 5 : ContentAdvisory="18+"; break; default: ; } else switch (XDS_Data[XDS_Level][3]&0x7) //g2g1g0 { case 0 : ContentAdvisory="E"; break; case 1 : ContentAdvisory="C"; break; case 2 : ContentAdvisory="C8+"; break; case 3 : ContentAdvisory="G"; break; case 4 : ContentAdvisory="PG"; break; case 5 : ContentAdvisory="14+"; break; case 6 : ContentAdvisory="18+"; break; default: ; } } break; default: ; } if (ContentAdvisory) { string ContentAdvisory_String=ContentAdvisory; if (!ContentDescriptors.empty()) ContentAdvisory_String+=" ("+ContentDescriptors+')'; Fill(Stream_General, 0, General_LawRating, ContentAdvisory_String.c_str()); } } //--------------------------------------------------------------------------- void File_Eia608::XDS_Current_ProgramName() { string ValueS; for (size_t Pos=2; Pos=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 Captions2 Rows case 0x26 : //RU3 - Roll-Up Captions3 Rows case 0x27 : //RU4 - Roll-Up Captions4 Rows case 0x29 : //RDC - Resume Direct Captioning case 0x2A : //TR - Text Restart case 0x2B : //RTD - Resume Text Display case 0x2C : //EDM - Erase Displayed Memory TextMode=(cc_data_2&0xFE)==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; PosCC_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; PosCC_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; PosInBack?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 Captions2 Rows case 0x26 : //RU3 - Roll-Up Captions3 Rows case 0x27 : //RU4 - Roll-Up Captions4 Rows Streams[StreamPos]->RollUpLines=cc_data_2-0x25+2; Streams[StreamPos]->InBack=false; break; //RUx - Roll-Up Captionsx 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 (StreamPosCC_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; PosRollUpLines; Pos++) { if (Streams[StreamPos]->y>=Streams[StreamPos]->RollUpLines-Pos && Streams[StreamPos]->y-Streams[StreamPos]->RollUpLines+Pos+1CC_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_XCC_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_YCC_NonDisplayed.size(); Pos_Y++) for (size_t Pos_X=0; Pos_XCC_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; DataDetected[1+StreamPos]=true; } //--------------------------------------------------------------------------- void File_Eia608::HasChanged() { } //--------------------------------------------------------------------------- void File_Eia608::Illegal(int8u cc_data_1, int8u cc_data_2) { } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_EIA608_YES MediaInfoLib/Source/MediaInfo/Text/File_Eia608.h0000664000000000000000000001015012652076434020131 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PGS files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_Eia608H #define MediaInfo_File_Eia608H //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include #include //--------------------------------------------------------------------------- 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(); ~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 > 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' '), Attribute(0x00) { } }; void Character_Fill(wchar_t Character); void HasChanged(); void Illegal(int8u cc_data_1, int8u cc_data_2); struct stream { vector > CC_Displayed; vector > 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 Streams; int8u cc_data_1_Old; int8u cc_data_2_Old; bool HasContent; std::bitset<8> DataDetected; //1=CC1, 2=CC2, 3=T1, 4=T2, 5=XDS }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_SubRip.cpp0000664000000000000000000002043312652076434020741 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_SUBRIP_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Text/File_SubRip.h" #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Utils //*************************************************************************** int64u SubRip_str2timecode(const char* Value) { size_t Length=strlen(Value); if (Length>=8 && Value[0]>='0' && Value[0]<='9' && Value[1]>='0' && Value[1]<='9' && Value[2]==':' && Value[3]>='0' && Value[3]<='9' && Value[4]>='0' && Value[4]<='9' && Value[5]==':' && Value[6]>='0' && Value[6]<='9' && Value[7]>='0' && Value[7]<='9') { int64u ToReturn=(int64u)(Value[0]-'0')*10*60*60*1000000000 +(int64u)(Value[1]-'0') *60*60*1000000000 +(int64u)(Value[3]-'0') *10*60*1000000000 +(int64u)(Value[4]-'0') *60*1000000000 +(int64u)(Value[6]-'0') *10*1000000000 +(int64u)(Value[7]-'0') *1000000000; if (Length>=9 && (Value[8]=='.' || Value[8]==',')) { if (Length>9+9) Length=9+9; //Nanoseconds max const char* Value_End=Value+Length; Value+=9; int64u Multiplier=100000000; while (Value=2 && Value[Length-1]=='s') { return (int64u)(atof(Value)*1000000000); } else return (int64u)-1; } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_SubRip::File_SubRip() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_SubRip; StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS //Init Frame_Count=0; //Temp IsVTT=false; HasBOM=false; } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_SubRip::FileHeader_Begin() { if (!IsSub && (Buffer_Size65536?65536:Buffer_Size)-(HasBOM?3:0)); if (Temp.empty()) { Temp.From_Local((const char*)Buffer+(HasBOM?3:0), (Buffer_Size>65536?65536:Buffer_Size)-(HasBOM?3:0)); // Trying from local code page IsLocal=true; } Temp.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive); Temp.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive); List.Write(Temp); if (List(0, 0)==__T("WEBVTT FILE") || List(0, 0)==__T("WEBVTT")) IsVTT=true; if (!IsVTT) { size_t IsOk=0; size_t IsNok=0; for (size_t Pos=0; Pos22 && List(Pos, 1)[2]==__T(':') && List(Pos, 1)[5]==__T(':') && List(Pos, 1).find(__T(" --> "))!=string::npos) IsOk++; else IsNok++; } if (!IsOk || IsNok>IsOk/2) { Reject(); return true; } } if (!IsSub && File_Size!=(int64u)-1 && Buffer_Size!=File_Size) { Element_WaitForMoreData(); return false; } if (!Status[IsAccepted]) { Accept(); Fill(Stream_General, 0, General_Format, IsVTT?"WebVTT":"SubRip"); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, "Format", IsVTT?"WebVTT":"SubRip"); Fill(Stream_Text, 0, "Codec", IsVTT?"WebVTT":"SubRip"); } if (IsLocal) Temp.From_Local((const char*)Buffer+(HasBOM?3:0), Buffer_Size-(HasBOM?3:0)); else Temp.From_UTF8((const char*)Buffer+(HasBOM?3:0), Buffer_Size-(HasBOM?3:0)); Temp.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive); Temp.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive); List.Write(Temp); #if MEDIAINFO_DEMUX size_t Pos=0; for (;;) { if (Pos>=List.size()) break; if (List[Pos].size()>=3 || (IsVTT && List[Pos].size()>=2)) { Ztring PTS_Begin_String=List[Pos][IsVTT?0:1].SubString(Ztring(), __T(" --> ")); Ztring PTS_End_String=List[Pos][IsVTT?0:1].SubString(__T(" --> "), Ztring()); if (IsVTT) { size_t Extra_Pos=PTS_End_String.find(__T(' ')); if (Extra_Pos!=string::npos) PTS_End_String.resize(Extra_Pos); //Discarding positioning } item Item; Item.PTS_Begin=SubRip_str2timecode(PTS_Begin_String.To_UTF8().c_str()); Item.PTS_End=SubRip_str2timecode(PTS_End_String.To_UTF8().c_str()); for (size_t Pos2=IsVTT?1:2; Pos2=3)?3:0), ContentType_MainStream); #endif //MEDIAINFO_DEMUX Buffer_Offset=Buffer_Size; } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_SUBRIP_YES MediaInfoLib/Source/MediaInfo/Text/File_OtherText.cpp0000664000000000000000000001435212652076434021466 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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) { Element_WaitForMoreData(); return; } Element_Offset=File_Size-(File_Offset+Buffer_Offset); Ztring Format, FormatMore, Codec; Ztring File; ZtringList Lines; //Feed File and Lines File.From_UTF8((const char*)Buffer, Buffer_Size>65536?65536:Buffer_Size); if (File.empty()) File.From_Local((const char*)Buffer, Buffer_Size>65536?65536:Buffer_Size); // Trying from local code page 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 File.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive); File.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive); Lines.Separator_Set(0, __T("\n")); Lines.Write(File); Lines.resize(0x20); if (Lines[0]==__T("[Script Info]") && (Lines.Find(__T("ScriptType: v4.00"))!=Error || Lines.Find(__T("Script Type: 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("Script Type: 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 if (Lines[0].find(__T(""))==0) { Format=__T("SAMI"); } 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 MediaInfoLib/Source/MediaInfo/Text/File_DtvccTransport.h0000664000000000000000000000406212652076434022162 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Bar Data files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_DtvccTransportH #define MediaInfo_DtvccTransportH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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_Init(); 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 Streams; //Helpers void CreateStream(int8u Parser_Pos); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_Eia708.cpp0000664000000000000000000016452512652076434020505 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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; MustSynchronize=true; //In cc_type=(int8u)-1; AspectRatio=((float32)4)/3; //Default to 4:3 ParserName=__T("EIA-708"); //Stream service_number=(int8u)-1; //Temp StandAloneCommand=false; HasContent=false; DataDetected=0x0000000000000000LL; } //--------------------------------------------------------------------------- File_Eia708::~File_Eia708() { for (size_t Pos=0; PosFile_Eia708_DisplayEmptyStream_Get() && Streams.size()<2) Streams.resize(2); if (ServiceDescriptors) { for (servicedescriptors708::iterator ServiceDescriptor=ServiceDescriptors->ServiceDescriptors708.begin(); ServiceDescriptor!=ServiceDescriptors->ServiceDescriptors708.end(); ++ServiceDescriptor) { service_number=ServiceDescriptor->first; block_size=0; Service(); } } for (size_t Pos=0; PosFile_Eia708_DisplayEmptyStream_Get())) { Stream_Prepare(Stream_Text); Fill(Stream_Text, StreamPos_Last, Text_ID, Pos); Fill(Stream_Text, StreamPos_Last, "CaptionServiceName", Pos); (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("CaptionServiceName"), Info_Options)=__T("N NT"); 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"); if (Config->ParseSpeed>=1.0) { Fill(Stream_Text, StreamPos_Last, "CaptionServiceContent_IsPresent", (DataDetected&((int64u)1)<ServiceDescriptors708.find((int8u)Pos); if (ServiceDescriptor!=ServiceDescriptors->ServiceDescriptors708.end()) { Fill(Stream_Text, StreamPos_Last, Text_Language, ServiceDescriptor->second.language, true); Fill(Stream_Text, StreamPos_Last, "CaptionServiceDescriptor_IsPresent", "Yes", Unlimited, true, true); (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("CaptionServiceDescriptor_IsPresent"), Info_Options)=__T("N NT"); } else //ServiceDescriptors pointer is for the support by the transport layer of the info { Fill(Stream_Text, StreamPos_Last, "CaptionServiceDescriptor_IsPresent", "No", Unlimited, true, true); (*Stream_More)[Stream_Text][StreamPos_Last](Ztring().From_Local("CaptionServiceDescriptor_IsPresent"), Info_Options)=__T("N NT"); } } } } //--------------------------------------------------------------------------- void File_Eia708::Streams_Finish() { } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_Eia708::Synchronize() { if (IsSub && cc_type!=3) return false; //Waiting for sync from underlying layer if (!Status[IsAccepted]) Accept("EIA-708"); //Synched is OK return true; } //--------------------------------------------------------------------------- bool File_Eia708::Synched_Test() { if (cc_type==4) //Magic value saying that the buffer must be kept (this is only a point of synchro from the undelying layer) Buffer_Offset=Buffer_Size; //Sync point //We continue return true; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Eia708::Read_Buffer_Init() { } //--------------------------------------------------------------------------- void File_Eia708::Read_Buffer_Continue() { FrameInfo.PTS=FrameInfo.DTS; } //--------------------------------------------------------------------------- void File_Eia708::Read_Buffer_Unsynched() { for (service_number=1; service_numberWindows.size(); WindowID++) { window* Window=Streams[service_number]->Windows[WindowID]; if (Window) for (size_t Pos_Y=0; Pos_YMinimal.CC.size(); Pos_Y++) { for (size_t Pos_X=0; Pos_XMinimal.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_YMinimal.CC.size(); Pos_Y++) { for (size_t Pos_X=0; Pos_XMinimal.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; } } } #if MEDIAINFO_EVENTS for (service_number=1; 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=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_Yrow_count; Pos_Y++) for (size_t Pos_X=0; Pos_Xcolumn_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_YMinimal.CC.size() && Window->Minimal.Window_x+Pos_XMinimal.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_Yrow_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_Xcolumn_count; Pos_X++) Window->Minimal.CC[y][Pos_X]=character(); if (Window->visible) { //Updating global area for (int8u Pos_Y=0; Pos_Yrow_count; Pos_Y++) for (int8u Pos_X=0; Pos_Xcolumn_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_Xcolumn_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+Pos_X<(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_Yrow_count; Pos_Y++) for (size_t Pos_X=0; Pos_Xcolumn_count; Pos_X++) { if (Window->Minimal.Window_y+Pos_YMinimal.CC.size() && Window->Minimal.Window_x+Pos_XMinimal.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() { #if MEDIAINFO_TRACE Param_Info1("HideWindows"); Element_Level--; Element_Info1("HideWindows"); Element_Level++; #endif //MEDIAINFO_TRACE 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_Yrow_count; Pos_Y++) for (size_t Pos_X=0; Pos_Xcolumn_count; Pos_X++) { //Clearing window Window->Minimal.CC[Pos_Y][Pos_X]=character(); //Filling global area if (Window->Minimal.Window_y+Pos_YMinimal.CC.size() && Window->Minimal.Window_x+Pos_XMinimal.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() { #if MEDIAINFO_TRACE Param_Info1("ToggleWindows"); Element_Level--; Element_Info1("ToggleWindows"); Element_Level++; #endif //MEDIAINFO_TRACE 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_Yrow_count; Pos_Y++) for (size_t Pos_X=0; Pos_Xcolumn_count; Pos_X++) { if (Window->Minimal.Window_y+Pos_YMinimal.CC.size() && Window->Minimal.Window_x+Pos_XMinimal.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() { #if MEDIAINFO_TRACE Param_Info1("DeleteWindows"); Element_Level--; Element_Info1("DeleteWindows"); Element_Level++; #endif //MEDIAINFO_TRACE 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; //Fill(Stream_Text, 0, "Bug", "WindowID_Bug", Unlimited, true, 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_Yrow_count; Pos_Y++) for (size_t Pos_X=0; Pos_Xcolumn_count; Pos_X++) { //Clearing window Window->Minimal.CC[Pos_Y][Pos_X]=character(); //Filling global area if (Window->Minimal.Window_y+Pos_YMinimal.CC.size() && Window->Minimal.Window_x+Pos_XMinimal.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() { #if MEDIAINFO_TRACE Param_Info1("Set Pen Attributes"); Element_Level--; Element_Info1("Set Pen Attributes"); Element_Level++; #endif //MEDIAINFO_TRACE 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() { #if MEDIAINFO_TRACE Param_Info1("Set Pen Color"); Element_Level--; Element_Info1("Set Pen Color"); Element_Level++; #endif //MEDIAINFO_TRACE 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() { #if MEDIAINFO_TRACE Param_Info1("SetPenLocation"); Element_Level--; Element_Info1("SetPenLocation"); Element_Level++; #endif //MEDIAINFO_TRACE 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 (rowMinimal.CC.size() && columnMinimal.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() { #if MEDIAINFO_TRACE Param_Info1("SetWindowAttributes"); Element_Level--; Element_Info1("SetWindowAttributes"); Element_Level++; #endif //MEDIAINFO_TRACE 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_NoTrustError(); Mark_0_NoTrustError(); 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) { #if MEDIAINFO_TRACE Param_Info1("DefineWindow"); Param_Info1(WindowID); Element_Level--; Element_Info1("DefineWindow"); Element_Level++; #endif //MEDIAINFO_TRACE 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; if (relative_positioning) { Window->Minimal.Window_y=(int8u)(((float)15)*anchor_vertical/100); Window->Minimal.Window_x=(int8u)(24*AspectRatio*anchor_horizontal/100);; } else { Window->Minimal.Window_y=anchor_vertical/5; Window->Minimal.Window_x=anchor_horizontal/5; } 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_yMinimal.Window_y) Window->Minimal.Window_y-=offset_y; 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_xMinimal.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>15) { Window->row_count=15; //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_Yrow_count; Pos_Y++) Window->Minimal.CC[Pos_Y].resize(Window->column_count); if (Window->Minimal.Window_y+Window->row_count>15 || (AspectRatio && Window->Minimal.Window_x+Window->column_count>(int8u)(24*AspectRatio))) { //Correcting if (Window->Minimal.Window_y+Window->row_count>15) Window->Minimal.Window_y=15-Window->row_count; if (AspectRatio && Window->Minimal.Window_x+Window->column_count>(int8u)(24*AspectRatio)) Window->Minimal.Window_x=(int8u)(24*AspectRatio)-Window->column_count; } } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- void File_Eia708::Character_Fill(wchar_t Character) { Element_Level-=1; Element_Info1(Ztring().From_Unicode(&Character, 1)); Element_Level+=1; Param_Info1(Ztring().From_Unicode(&Character, 1)); //(Character) after new ZenLib release 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 (xcolumn_count && yrow_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; DataDetected|=((int64u)1)< #include using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Pdf::File_Pdf() :File__Analyze() { } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Pdf::Streams_Accept() { Fill(Stream_General, 0, General_Format, "PDF"); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, "Format", "PDF"); } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Pdf::FileHeader_Begin() { //Synchro if (5>Buffer_Size) return false; if (Buffer[0]!=0x25 //"%PDF-" || Buffer[1]!=0x50 || Buffer[2]!=0x44 || Buffer[3]!=0x46 || Buffer[4]!=0x2D) { Reject(); return false; } Accept(); //Temp Catalog_Level=0; Offsets_Max=0; //All should be OK... return true; } //--------------------------------------------------------------------------- void File_Pdf::FileHeader_Parse() { string PdfHeader; Get_String(SizeOfLine(), PdfHeader, "Header"); for (;;) { int64u CommentSize=SizeOfLine(); if (Buffer_Offset+Element_Offset>=Buffer_Size) { Element_WaitForMoreData(); return; } if (Buffer[Buffer_Offset+Element_Offset]!='%') break; Skip_String(CommentSize, "Comment"); } //Filling Fill(Stream_General, 0, General_Format_Version, PdfHeader.substr(5)); GoToFromEnd(9+2+10+2+5+2); // "startxref" + EOL + 10max digits + EOL + "%%EOF" + EOL State=State_Parsing_startxref; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Pdf::Read_Buffer_Continue() { switch (State) { case State_Parsing_xref : xref(); if (!Element_IsWaitingForMoreData()) trailer(); break; case State_Parsing_startxref : eof(); startxref(); break; case State_Parsing_object : break; //Using elements default : Finish(); } } //*************************************************************************** // Buffer - Per element //*************************************************************************** //--------------------------------------------------------------------------- bool File_Pdf::Header_Begin() { //Offsets_Current=Offsets.find(Objects_Current->second.Offset); //offsets::iterator Offsets_Next=Offsets_Current; //Offsets_Next++; //if (Offsets_Next!=Offsets.end() && Offsets_Next->first>File_Offset+Buffer_Size) //{ // Element_WaitForMoreData(); // return false; //} return true; } //--------------------------------------------------------------------------- void File_Pdf::Header_Parse() { offsets::iterator Offsets_Next=upper_bound(Offsets.begin(), Offsets.end(), (int32u)(File_Offset+Buffer_Offset)); if (Offsets_Next!=Offsets.end() && *Offsets_Next>File_Offset+Buffer_Size) { Element_WaitForMoreData(); return; } int64u Size; //if (Offsets_Current==Offsets.end()) // Size=Offsets_Max-(File_Offset+Buffer_Offset); //else // Size=Offsets_Current->first-(File_Offset+Buffer_Offset); if (Offsets_Next==Offsets.end()) Size=Offsets_Max-(File_Offset+Buffer_Offset); else Size=*Offsets_Next-(File_Offset+Buffer_Offset); Header_Fill_Size(Size); } //--------------------------------------------------------------------------- void File_Pdf::Data_Parse() { Element_Name("Object"); string Line; Get_String(SizeOfLine(), Line, "Header"); size_t Space_Pos=Line.find(' '); int32u ObjectNumber=Ztring().From_UTF8(Line.substr(0, Space_Pos)).To_int32u(); Element_Info1(ObjectNumber); objects::iterator Object=Objects.find(ObjectNumber); if (Object==Objects.end()) Skip_XX(Element_Size-Element_Offset, "Data"); else switch(Object->second.Type) { case Type_Root : Object_Root(); break; case Type_Info : Object_Info(); break; case Type_Metadata : Object_Metadata(); break; default : Skip_XX(Element_Size-Element_Offset, "Data"); } for (;;) { Objects_Current->second.BottomPos++; if (Objects_Current->second.BottomPos>=Objects_Current->second.Bottoms.size()) { if (Objects_Current->first==(int32u)-1) { //No more to parse Objects_Current=Objects.end(); Objects.clear(); Finish(); break; } Objects_Current=Objects.find(Objects_Current->second.TopObject); continue; } Objects_Current=Objects.find(Objects_Current->second.Bottoms[Objects_Current->second.BottomPos]); GoTo(Objects_Current->second.Offset); break; } } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Pdf::xref() { //Parsing Element_Begin1("Cross-Reference Table"); Element_Begin1("Cross-Reference Section"); string FirstLine; Skip_String(SizeOfLine(), "Object name"); Element_Begin1("Cross-Reference SubSection"); Get_String(SizeOfLine(), FirstLine, "Header"); size_t FirstLine_Space=FirstLine.find(' '); int32u Base=atoi((const char*)FirstLine.c_str()); int32u Count=0; if (FirstLine_Space!=string::npos) Count=atoi((const char*)FirstLine.c_str()+FirstLine_Space+1); if (0x10000+20*Count>Buffer_Size && File_Offset+Buffer_Size100) Element_Offset+=20; else { Skip_String(18, "Entry"); Param_Info1(Base+Pos); Element_Offset+=2; //Skipping spaces at end and line return } } Element_End0(); Element_End0(); Element_End0(); if (File_Offset+Buffer_Offset>Offsets_Max) Offsets_Max=(int32u)(File_Offset+Buffer_Offset); } //--------------------------------------------------------------------------- void File_Pdf::trailer() { Element_Begin1("Trailer"); //Parsing int32u Prev=(int32u)-1; string Key; Ztring Value; Skip_String(SizeOfLine(), "Object name"); while (Element_Offsetsecond.Bottoms[0]); GoTo(Objects_Current->second.Offset); State=State_Parsing_object; } //--------------------------------------------------------------------------- void File_Pdf::startxref() { //We need to find the exact begin Buffer_Offset=Buffer_Size-1; while (Buffer_Offset && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) Buffer_Offset--; Buffer_Offset-=5; // "%%EOF" while (Buffer_Offset && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) Buffer_Offset--; while (Buffer_Offset && Buffer[Buffer_Offset]>='0' && Buffer[Buffer_Offset]<='9') // Value Buffer_Offset--; while (Buffer_Offset && (Buffer[Buffer_Offset]=='\r' || Buffer[Buffer_Offset]=='\n')) Buffer_Offset--; Buffer_Offset-=8; //Parsing Element_Begin1("Cross-Reference Table Offset"); string xrefOffsetS; Skip_String(SizeOfLine(), "Object name"); Get_String (SizeOfLine(), xrefOffsetS, "xref Offset"); while (Buffer_OffsetOffsets_Max) Offsets_Max=xref_Offset; GoTo (xref_Offset); State=State_Parsing_xref; } //--------------------------------------------------------------------------- void File_Pdf::eof() { if (File_Size!=(int64u)-1 && File_Offset+Buffer_Sizefirst; Objects[Objects_Current->first].Bottoms.push_back(ObjectNumber); Param_Info1(__T("Metadata is at offset 0x"+Ztring().From_Number(Objects[ObjectNumber].Offset))); } } continue; } if (Key.empty()) break; } } //--------------------------------------------------------------------------- void File_Pdf::Object_Info() { Element_Info1("Info"); //Parsing string Key; Ztring Value; while (Element_Offset')) while (Element_Offset' && Buffer[End+1]=='>')) End++; return End-(Buffer_Offset+(size_t)Element_Offset); } //--------------------------------------------------------------------------- bool File_Pdf::Get_Next(string &Key, Ztring &Value) { Key.clear(); Value.clear(); string Line; //Removig end of lines while (Element_Offset=Element_Size) return true; //Testing Catalog Peek_String (2, Line); if (Line=="<<") { Element_Offset+=2; Catalog_Level++; return true; } else if (Line==">>") { Element_Offset+=2; Catalog_Level--; return true; } //Getting a complete line Peek_String (SizeOfLine(), Line); //Testing Catalog size_t Catalog_End=Line.find(">>"); if (Catalog_End!=String::npos) Line.resize(Catalog_End); //Testing stream if (Line=="stream") { Skip_String(Line.size(), "Stream, Header"); Key=Line; return false; } if (Line=="endstream") { Skip_String(Line.size(), "Stream, Footer"); Key=Line; return false; } //Testing object if (Line=="endobj") { Skip_String(Line.size(), "Footer"); Key=Line; return false; } //Base int64u Line_Base=Element_Offset; //Testing next key size_t Line_End=0; size_t Line_Begin=Line_End; // Key-Value if (Line_BeginParser && 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; Pos2Parser->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); } Ztring LawRating=Streams[Pos]->Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Streams[Pos]->Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } } //--------------------------------------------------------------------------- void File_DtvccTransport::Streams_Finish() { Clear(Stream_Text); if (ServiceDescriptors) { if (ServiceDescriptors->ServiceDescriptors608.find(0)!=ServiceDescriptors->ServiceDescriptors608.end()) CreateStream(0); if (ServiceDescriptors->ServiceDescriptors608.find(1)!=ServiceDescriptors->ServiceDescriptors608.end()) CreateStream(1); if (!ServiceDescriptors->ServiceDescriptors708.empty()) CreateStream(2); } //Per stream for (size_t Pos=0; PosParser && 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_Init() { //Global information #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Config->File_DtvccTransport_Stream_IsPresent=true; #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) } //--------------------------------------------------------------------------- void File_DtvccTransport::Read_Buffer_Unsynched() { //Parsing for (size_t Pos=0; PosParser) 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; PosElement_Size) break; //Found one stream with bad cc_count, we discard cc_count without flagging the stream as untrusted for the moment 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 MEDIAINFO_ADVANCED if (cc_type>=2 && !Streams[2] && Config->File_Eia708_DisplayEmptyStream_Get()) CreateStream(2); #endif //MEDIAINFO_ADVANCED 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 //Stream creation if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream); #endif //MEDIAINFO_DEMUX 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) Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 0); ((File_Eia708*)Streams[2]->Parser)->cc_type=3; } } else { } #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser->ServiceDescriptors=ServiceDescriptors; #endif Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2); Element_Show(); Element_Offset+=2; } else Skip_XX(2, "Data"); Element_End0(); } else Skip_XX(2, "Junk"); Element_End0(); } FILLING_BEGIN(); if (!Status[IsAccepted]) Accept("DTVCC Transport"); FILLING_END(); } 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_OffsetParser=new File_Eia608(); ((File_Eia608*)Streams[Parser_Pos]->Parser)->cc_type=Parser_Pos; #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) } #else //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser=new File__Analyze(); #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) //Init Streams[Parser_Pos]->Parser->ServiceDescriptors=ServiceDescriptors; Open_Buffer_Init(Streams[Parser_Pos]->Parser); Streams[Parser_Pos]->Parser->Accept(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_DTVCCTRANSPORT_YES MediaInfoLib/Source/MediaInfo/Text/File_SubRip.h0000664000000000000000000000321112652076434020401 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about SubRip files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_SubRipH #define MediaInfo_File_SubRipH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_SubRip //*************************************************************************** class File_SubRip : public File__Analyze { public : File_SubRip(); private : //Buffer - File header bool FileHeader_Begin(); //Buffer - Global #if MEDIAINFO_SEEK size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID); #endif //MEDIAINFO_SEEK void Read_Buffer_Continue(); //Temp bool IsVTT; bool HasBOM; #if MEDIAINFO_DEMUX struct item { int64u PTS_Begin; int64u PTS_End; Ztring Content; }; std::vector Items; #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Text/File_AribStdB24B37.cpp0000664000000000000000000016450412652076434021621 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_ARIBSTDB24B37_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Text/File_AribStdB24B37.h" #if defined(MEDIAINFO_MPEGTS_YES) #include "MediaInfo/Multiple/File_MpegTs.h" #endif #include #ifdef __WINDOWS__ #undef __TEXT #include "windows.h" #endif // __WINDOWS__ //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** //--------------------------------------------------------------------------- const char* AribStdB24B37_Caption_conversion_type(int8u Caption_conversion_type) { switch (Caption_conversion_type) { case 0 : return "Analog"; case 1 : return "HD side panel"; case 2 : return "SD (4:3)"; case 3 : return "SD wide side panel"; case 4 : return "Mobile closed caption"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_Caption_DataIdentifier(int8u DataIdentifier) { switch (DataIdentifier) { case 0 : return "Exchange format data (closed caption data label)"; case 1 : return "Exchange format data (program management information)"; case 2 : return "Exchange format data (page information 1)"; case 3 : return "Exchange format data (page information 2)"; case 4 : return "Short form data (closed caption management data)"; case 5 : return "Short form data (closed caption text data)"; case 6 : return "Undefined"; case 7 : return "Dummy data"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_DRCS_conversion_type(int8u DRCS_conversion_type) { switch (DRCS_conversion_type) { case 0 : return "DRCS conversion mode A"; case 1 : return "DRCS conversion mode B"; case 2 : return "Mobile DRCS"; case 3 : return "DRCS conversion not possible"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_data_group_id(int8u data_group_id) { switch (data_group_id) { case 0 : return "Caption management"; case 1 : return "Caption statement (1st)"; case 2 : return "Caption statement (2nd)"; case 3 : return "Caption statement (3rd)"; case 4 : return "Caption statement (4th)"; case 5 : return "Caption statement (5th)"; case 6 : return "Caption statement (6th)"; case 7 : return "Caption statement (7th)"; case 8 : return "Caption statement (8th)"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_TMD(int8u TMD) { switch (TMD) { case 0 : return "Free"; case 1 : return "Real time"; case 2 : return "Offset time"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_DMF_reception(int8u DMF_reception) { switch (DMF_reception) { case 0 : return "Automatic display when received"; case 1 : return "Non-displayed automatically when received"; case 2 : return "Selectable display when received"; case 3 : return "Automatic display/non-display under specific condition when received"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_DMF_recording(int8u DMF_recording) { switch (DMF_recording) { case 0 : return "Automatic display when recording and playback"; case 1 : return "Non- displayed automatically when recording and playback"; case 2 : return "Selectable display when recording and playback"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_format(int8u format) { switch (format) { case 0 : return "Horizontal writing in standard density"; case 1 : return "Vertical writing in standard density"; case 2 : return "Horizontal writing in high density"; case 3 : return "Vertical writing in high density"; case 4 : return "Horizontal writing of Western language"; case 5 : return "Horizontal writing in 1920 x 1080"; case 6 : return "Vertical writing in 1920 x 1080"; case 7 : return "Horizontal writing in 960 x 540"; case 8 : return "Vertical writing in 960 x 540"; case 9 : return "Horizontal writing in 1280 x 720"; case 10 : return "Vertical writing in 1280 x 720"; case 11 : return "Horizontal writing in 720 x 480"; case 12 : return "Vertical writing in 720 x 480"; default : return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_TCS(int8u TCS) { switch (TCS) { case 0 : return "8-bit character codes"; case 1 : return "UCS"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_rollup_mode(int8u rollup_mode) { switch (rollup_mode) { case 0 : return "Non-roll up"; case 1 : return "Roll up"; default: return ""; } } //--------------------------------------------------------------------------- const char* AribStdB24B37_data_unit_parameter(int8u data_unit_parameter) { switch (data_unit_parameter) { case 0x20 : return "Texts"; case 0x28 : return "Geometric graphics"; case 0x2C : return "Synthesized sound"; case 0x30 : return "1 byte DRCS"; case 0x31 : return "2 byte DRCS"; case 0x34 : return "color map"; case 0x35 : return "Bit map"; default : return ""; } } //--------------------------------------------------------------------------- // Table 7-18 Default macro code strings static const int8u AribStdB24B37_DefaultMacros[][19] = { { 0x1B, 0x24, 0x42, 0x1B, 0x29, 0x4A, 0x1B, 0x2A, 0x30, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x24, 0x42, 0x1B, 0x29, 0x31, 0x1B, 0x2A, 0x30, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x24, 0x42, 0x1B, 0x29, 0x20, 0x41, 0x1B, 0x2A, 0x30, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x32, 0x1B, 0x29, 0x34, 0x1B, 0x2A, 0x35, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x32, 0x1B, 0x29, 0x33, 0x1B, 0x2A, 0x35, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x32, 0x1B, 0x29, 0x20, 0x41, 0x1B, 0x2A, 0x35, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x20, 0x41, 0x1B, 0x29, 0x20, 0x42, 0x1B, 0x2A, 0x20, 0x43, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x20, 0x44, 0x1B, 0x29, 0x20, 0x45, 0x1B, 0x2A, 0x20, 0x46, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x20, 0x47, 0x1B, 0x29, 0x20, 0x48, 0x1B, 0x2A, 0x20, 0x49, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x20, 0x4A, 0x1B, 0x29, 0x20, 0x4B, 0x1B, 0x2A, 0x20, 0x4C, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x20, 0x4D, 0x1B, 0x29, 0x20, 0x4E, 0x1B, 0x2A, 0x20, 0x4F, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x24, 0x42, 0x1B, 0x29, 0x20, 0x42, 0x1B, 0x2A, 0x30, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x24, 0x42, 0x1B, 0x29, 0x20, 0x43, 0x1B, 0x2A, 0x30, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x24, 0x42, 0x1B, 0x29, 0x20, 0x44, 0x1B, 0x2A, 0x30, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x31, 0x1B, 0x29, 0x30, 0x1B, 0x2A, 0x4A, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, { 0x1B, 0x28, 0x4A, 0x1B, 0x29, 0x32, 0x1B, 0x2A, 0x20, 0x41, 0x1B, 0x2B, 0x20, 0x70, 0x0F, 0x1B, 0x7D }, }; //--------------------------------------------------------------------------- static const int8u AribStdB24B37_DefaultMacros_size[] = { 16, 16, 17, 16, 16, 17, 19, 19, 19, 19, 19, 17, 17, 17, 16, 17, }; //--------------------------------------------------------------------------- // CRC_CCIT_Xmodem_Table // A CRC is computed like this: // Init: int16u CRC_CCIT_Xmodem = 0x0000; // for each data byte do // CRC_CCIT_Xmodem=(CRC_CCIT_Xmodem<<8) ^ CRC_CCIT_Xmodem_Table[(CRC_CCIT_Xmodem>>8)^(data_byte)]; // Array built with the help of http://www.sanity-free.com/133/crc_16_ccitt_in_csharp.html int16u AribStdB24B37_CRC_CCIT_Xmodem_Table[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0, }; //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_AribStdB24B37::File_AribStdB24B37() :File__Analyze() { //Configuration #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_AribStdB24B37; StreamIDs_Width[0]=1; #endif //MEDIAINFO_EVENTS PTS_DTS_Needed=true; //In HasCcis=false; ParseCcis=false; IsAncillaryData=false; //Config Caption_conversion_type=(int8u)-1; //Ancillary #if defined(MEDIAINFO_MPEGTS_YES) Parser=NULL; #endif } //--------------------------------------------------------------------------- File_AribStdB24B37::~File_AribStdB24B37() { #if defined(MEDIAINFO_MPEGTS_YES) delete Parser; #endif } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_AribStdB24B37::Streams_Fill() { for (size_t Pos=0; Pos6) { Skip_XX(245, "Dummy"); } else if (DataIdentifier<4) { Skip_XX(245, "Exchange format data, not supported"); } else { Element_Begin1("Short form data"); int8u LEN, Label_01, Label_3A, Data_Length; Get_B1(LEN, "LEN"); Element_Begin1("display timing"); Get_B1(Label_01, "Label (01)"); BS_Begin(); Skip_S1(6, "Undefined"); Skip_S1(2, "Data-type identifier"); Skip_S1(6, "Undefined"); Skip_S1(2, "Timing-type identifier"); Skip_S1(6, "Undefined"); Skip_S1(2, "Timing-direction identifier"); Skip_B5( "Display timing value"); BS_End(); Element_End0(); Element_Begin1("closed caption data"); Get_B1(Label_3A, "Label (3A)"); Get_B1(Data_Length, "Data Length"); #if defined(MEDIAINFO_MPEGTS_YES) if (Parser==NULL) { Parser=new File_MpegTs; ((File_MpegTs*)Parser)->FromAribStdB24B37=true; Open_Buffer_Init(Parser); } if (FrameInfo.PTS==(int64u)-1) FrameInfo.PTS=FrameInfo.DTS; Parser->FrameInfo=FrameInfo; Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, 188); Element_Offset+=188; #else Skip_XX(188, "TS data"); #endif if (Data_Length==192) { Skip_B2( "Group-A CRC"); Skip_B2( "Group-B CRC"); } else if (Data_Length>188) Skip_XX(Data_Length-188, "Unknown"); Element_End0(); if (LEN>203) Skip_XX(LEN-204, "User Data"); if (LEN<244) Skip_XX(244-LEN, "Unused"); Skip_XX(Element_Size-Element_Offset-6, "Format data"); Element_End0(); } Skip_B6( "ECC"); return; } if (ParseCcis) { int32u CCIS_code; Get_C4 ( CCIS_code, "CCIS_code"); if (CCIS_code==0xFFFFFFFF) { Skip_XX(Element_Size, "?"); return; } Get_B1 ( Caption_conversion_type, "Caption_conversion_type"); Param_Info1(AribStdB24B37_Caption_conversion_type(Caption_conversion_type)); BS_Begin(); Info_S1(2, DRCS_conversion_type, "DRCS_conversion_type"); Param_Info1(AribStdB24B37_DRCS_conversion_type(DRCS_conversion_type)); Skip_S1(6, "reserved"); BS_End(); Skip_B2( "reserved"); Skip_B8( "reserved"); ParseCcis=false; return; } Skip_B1( "Data_identifier"); Skip_B1( "Private_stream_id"); BS_Begin(); Skip_S1(4, "reserved"); Skip_S1(4, "PES_data_packet_header_length"); BS_End(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::Read_Buffer_Unsynched() { #if defined(MEDIAINFO_MPEGTS_YES) if (Parser) Parser->Open_Buffer_Unsynch(); #endif } //*************************************************************************** // Buffer - Per element //*************************************************************************** //--------------------------------------------------------------------------- void File_AribStdB24B37::Header_Parse() { //Parsing int16u data_group_size; int8u data_group_id; BS_Begin(); Skip_SB( "data_group_id (update part)"); Get_S1 (5, data_group_id, "data_group_id"); Param_Info1(AribStdB24B37_data_group_id(data_group_id)); Skip_S1(2, "data_group_version"); BS_End(); Skip_B1( "data_group_link_number"); Skip_B1( "last_data_group_link_number"); Get_B2 (data_group_size, "data_group_size"); //Filling Header_Fill_Code(data_group_id, AribStdB24B37_data_group_id(data_group_id)); Header_Fill_Size(Element_Offset+data_group_size+2); } //--------------------------------------------------------------------------- void File_AribStdB24B37::Data_Parse() { //CRC int16u CRC_CCIT_Xmodem=0x0000; const int8u* CRC_CCIT_Xmodem_Buffer=Buffer+Buffer_Offset-Header_Size; //data_group_id position while(CRC_CCIT_Xmodem_Buffer>8)^(*CRC_CCIT_Xmodem_Buffer)]; CRC_CCIT_Xmodem_Buffer++; } if (CRC_CCIT_Xmodem) { Skip_XX(Element_Size, "Data"); Trusted_IsNot("CRC error"); return; } Element_Size-=2; switch (Element_Code) { case 0 : caption_management(); break; case 1 : case 2 : case 3 : case 4 : case 5 : case 6 : case 7 : case 8 : if (Streams.empty()) { Skip_XX(Element_Size, "Waiting for caption_management"); break; } if (Element_Code>Streams.size()) { Skip_XX(Element_Size, "Unknown service"); Trusted_IsNot("Invalid service number"); break; } Streams[(size_t)(Element_Code-1)].Line.clear(); caption_statement(); Streams[(size_t)(Element_Code-1)].Line.clear(); break; default: Skip_XX(Element_Size, "Unknown"); } Element_Size+=2; Skip_B2( "CRC_16"); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_AribStdB24B37::caption_management() //caption_management_data() { //Parsing int32u data_unit_loop_length; int8u TMD, num_languages; BS_Begin(); Get_S1 (2, TMD, "TMD"); Param_Info1(AribStdB24B37_TMD(TMD)); Skip_S1(6, "Reserved"); if (TMD==2) { Skip_S5(36, "OTM"); //Note: time offset (HHMMSSmmm in BCD format) is currently not supported Skip_S5( 4, "Reserved"); } BS_End(); Get_B1 (num_languages, "num_languages"); Streams.clear(); Streams.resize(num_languages); for (int8u pos_languages=0; pos_languages>1) + (Row<=94?112:176); if (Row%2) ShiftJIS[1]=Column+31+(Column>=96); else ShiftJIS[1]=Column+126; wchar_t Temp[2]; int CharSize=MultiByteToWideChar(932, 0, ShiftJIS, 2, Temp, 2); //932 = Shift-JIS (Windows-31J) if (CharSize>0) { Temp[CharSize]=__T('\0'); Param_Info1(Ztring().From_Unicode(Temp)); Add (Ztring().From_Unicode(Temp)); } #else // __WINDOWS__ //TODO #endif // __WINDOWS__ } //--------------------------------------------------------------------------- void File_AribStdB24B37::Add (Char Character) { Streams[(size_t)(Element_Code-1)].Line+=Character; } //--------------------------------------------------------------------------- void File_AribStdB24B37::Add (Ztring Character) { Streams[(size_t)(Element_Code-1)].Line+=Character; } //--------------------------------------------------------------------------- void File_AribStdB24B37::DefaultMacro() { Element_Begin1("Default Macro"); int8u control_code; Get_B1 (control_code, "control_code"); if ((control_code&0xF0)==0x60) //Known macros { //Buffer const int8u* Save_Buffer=Buffer; size_t Save_Buffer_Offset=Buffer_Offset; size_t Save_Buffer_Size=Buffer_Size; int64u Save_Element_Offset=Element_Offset; int64u Save_Element_Size=Element_Size; Buffer=AribStdB24B37_DefaultMacros[control_code&0x0F]; Buffer_Offset=0; Buffer_Size=AribStdB24B37_DefaultMacros_size[control_code&0x0F]; Element_Offset=0; Element_Size=Buffer_Size; data_unit_data(Element_Size); Buffer=Save_Buffer; Save_Buffer=NULL; Buffer_Offset=Save_Buffer_Offset; Buffer_Size=Save_Buffer_Size; Element_Offset=Save_Element_Offset; Element_Size=Save_Element_Size; } else { Element_Info1("Unknown"); Param_Info1("Unknown"); } Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::Character (int16u CharacterSet, int8u G_Value, int8u FirstByte, int8u SecondByte) { int16u Value=(FirstByte<<8) | SecondByte; //ARIB STD B24/B37 provide numbers with 2 number (Row and Colupmn) a shift of 32 (b00100000) #define Compute(f,s) (((f+32)<<8) | (s+32)) switch (CharacterSet) { case GS_Kanji: Skip_B2( "Character"); if (Value<=Compute(84, 6)) JIS(FirstByte, SecondByte); else switch (Value) { case Compute(92, 1): JIS( 35, 42); break; case Compute(92, 2): JIS( 35, 43); break; case Compute(92, 3): JIS( 35, 44); break; case Compute(92, 4): JIS( 35, 45); break; case Compute(93, 79): JIS( 40, 110); break; case Compute(93, 88): Param_Info1(Ztring().From_UTF8("\xE2\x99\xAB")+__T(" (not exact)")); Add (Ztring().From_UTF8("\xE2\x99\xAB")); break; //Ending music note? case Compute(93, 89): Param_Info1(Ztring().From_UTF8("\xE2\x99\xAB")+__T(" (not exact)")); Add (Ztring().From_UTF8("\xE2\x99\xAB")); break; //Opening music note? case Compute(93, 90): Param_Info1(Ztring().From_UTF8("\xE2\x99\xAB")); Add (Ztring().From_UTF8("\xE2\x99\xAB")); break; //Music note default: Param_Info1("(Unsupported)"); //empty in spec or not yet mapped } break; case GS_Hiragana: case GS_PropHiragana: Skip_C1( "Character"); switch (FirstByte) { case 0x74: case 0x75: case 0x76: Param_Info1("(Unsupported)"); break; //empty in spec case 0x77: JIS( 33, 53); break; case 0x78: JIS( 33, 54); break; case 0x79: JIS( 33, 60); break; case 0x7A: JIS( 33, 35); break; case 0x7B: JIS( 33, 86); break; case 0x7C: JIS( 33, 87); break; case 0x7D: JIS( 33, 34); break; case 0x7E: JIS( 33, 38); break; default : JIS( 36, FirstByte); } break; case GS_Katakana: case GS_PropKatakana: Skip_C1( "Character"); switch (FirstByte) { case 0x77: JIS( 33, 41); break; case 0x78: JIS( 33, 42); break; case 0x79: JIS( 33, 51); break; case 0x7A: JIS( 33, 33); break; case 0x7B: JIS( 33, 86); break; case 0x7C: JIS( 33, 87); break; case 0x7D: JIS( 33, 34); break; case 0x7E: JIS( 33, 38); break; default : JIS( 37, FirstByte); break; } break; case GS_Alphanumeric: case GS_PropAscii: Skip_C1( "Character"); Add(FirstByte); break; case GS_DRCS|GS_Macro : DefaultMacro(); break; default : ; switch (Streams[(size_t)(Element_Code-1)].G_Width[G_Value]) { case 1 : Skip_C1("Character (unsupported)"); break; case 2 : Skip_C2("Character (unsupported)"); break; default: Skip_XX(Streams[(size_t)(Element_Code-1)].G_Width[G_Value], "Character (unsupported)"); } } } //--------------------------------------------------------------------------- void File_AribStdB24B37::control_code() { int8u control_code; Peek_B1(control_code); switch (control_code) { // Table 7-15 C0 control set case 0x00 : NUL(); break; case 0x07 : BEL(); break; case 0x08 : APB(); break; case 0x09 : APF(); break; case 0x0A : APD(); break; case 0x0B : APU(); break; case 0x0C : CS(); break; case 0x0D : APR(); break; case 0x0E : LS1(); break; case 0x0F : LS0(); break; case 0x16 : PAPF(); break; case 0x18 : CAN(); break; case 0x19 : SS2(); break; case 0x1B : ESC(); break; case 0x1C : APS(); break; case 0x1D : SS3(); break; case 0x1E : RS(); break; case 0x1F : US(); break; // Table 7-16 C1 control set case 0x80: //BKF case 0x81: //RDF case 0x82: //GRF case 0x83: //YLF case 0x84: //BLF case 0x85: //MGF case 0x86: //CNF case 0x87: //WHF xxF(); break; case 0x88: //SSZ case 0x89: //MSZ case 0x8A: //NSZ xxZ(); break; case 0x8B : SZX(); break; case 0x90 : COL(); break; case 0x91 : FLC(); break; case 0x92 : CDC(); break; case 0x93 : POL(); break; case 0x94 : WMM(); break; case 0x95 : MACRO(); break; case 0x97 : HLC(); break; case 0x98 : RPC(); break; case 0x99 : SPL(); break; case 0x9A : STL(); break; case 0x9B : CSI(); break; case 0x9D : TIME(); break; // Unknown default : Skip_XX(Element_Size-Element_Offset, "Unknown"); } } //--------------------------------------------------------------------------- void File_AribStdB24B37::NUL() { Element_Begin1("NUL - Empty"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::BEL() { Element_Begin1("BEL - Bell"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::APB() { Element_Begin1("APB - Active position backward"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::APF() { Element_Begin1("APF - Active position forwards"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::APD() { Element_Begin1("APD - Active position down"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::APU() { Element_Begin1("APU - Active position up"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::CS() { Element_Begin1("CS - Clear Screen"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::APR() { Element_Begin1("APR - Line return at operation position"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::LS1() { Element_Begin1("LS1 - Locking shift 1"); Skip_B1( "control_code"); Element_End0(); Streams[(size_t)(Element_Code-1)].GL=1; } //--------------------------------------------------------------------------- void File_AribStdB24B37::LS0() { Element_Begin1("LS0 - Locking shift 0"); Skip_B1( "control_code"); Element_End0(); Streams[(size_t)(Element_Code-1)].GL=0; } //--------------------------------------------------------------------------- void File_AribStdB24B37::PAPF() { Element_Begin1("PAPF - Move forwards at specified operation position"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::CAN() { Element_Begin1("CAN - Cancel"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::SS2() { Element_Begin1("SS2 - Single shift 2"); Skip_B1( "control_code"); Element_End0(); Streams[(size_t)(Element_Code-1)].GL_SS=3; } //--------------------------------------------------------------------------- void File_AribStdB24B37::ESC() { Element_Begin1("ESC - Escape"); int8u P1; Skip_B1( "control_code"); Get_B1 (P1, "P1"); switch (P1) { // Table 7-2 Designation of graphic sets case 0x24 : { int8u P2; Get_B1 (P2, "P2"); switch (P2) { case 0x28 : { int8u P3; Get_B1 (P3, "P3"); switch (P3) { case 0x20 : { int8u P4; Get_B1 (P4, "P4"); Streams[(size_t)(Element_Code-1)].G[0]=GS_DRCS|P4; Streams[(size_t)(Element_Code-1)].G_Width[0]=2; } break; case 0x29 : case 0x2A : case 0x2B : default : Streams[(size_t)(Element_Code-1)].G[0]=P2; Streams[(size_t)(Element_Code-1)].G_Width[0]=2; } } break; case 0x29 : case 0x2A : case 0x2B : { int8u P3; Get_B1 (P3, "P3"); if (P3==0x20) { int8u P4; Get_B1 (P4, "P4"); Streams[(size_t)(Element_Code-1)].G[P2-0x28]=GS_DRCS|P4; } else Streams[(size_t)(Element_Code-1)].G[P2 - 0x28]=P3; Streams[(size_t)(Element_Code-1)].G_Width[P2-0x28]=2; } break; default : Streams[(size_t)(Element_Code-1)].G[0]=P2; Streams[(size_t)(Element_Code-1)].G_Width[0]=2; } } break; case 0x28 : case 0x29 : case 0x2A : case 0x2B : { int8u P2; Get_B1 (P2, "P2"); if (P2==0x20) { int8u P3; Get_B1 (P3, "P3"); Streams[(size_t)(Element_Code-1)].G[P1-0x28]=GS_DRCS|P3; } else Streams[(size_t)(Element_Code-1)].G[P1 - 0x28]=P2; Streams[(size_t)(Element_Code-1)].G_Width[P1-0x28]=1; } break; // Table 7-1 Invocation of code elements (locking shift) case 0x6E : Streams[(size_t)(Element_Code-1)].GL=2; break; case 0x6F : Streams[(size_t)(Element_Code-1)].GL=3; break; case 0x7C : Streams[(size_t)(Element_Code-1)].GR=3; break; case 0x7D : Streams[(size_t)(Element_Code-1)].GR=2; break; case 0x7E : Streams[(size_t)(Element_Code-1)].GR=1; break; default : ; //Problem? } Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::APS() { Element_Begin1("APS - Specify operation position"); Skip_B1( "control_code"); Skip_B1( "P1"); Skip_B1( "P2"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::SS3() { Element_Begin1("SS3 - Single shift 3"); Skip_B1( "control_code"); Element_End0(); Streams[(size_t)(Element_Code-1)].GL_SS=3; } //--------------------------------------------------------------------------- void File_AribStdB24B37::RS() { Element_Begin1("RS - Record separator"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::US() { Element_Begin1("US - Unit separator"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::xxF() { Element_Begin1("xxF - foreground"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::xxZ() { Element_Begin1("xxZ - size"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::SZX() { Element_Begin1("SZX - Specified size"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::COL() { Element_Begin1("COL - Color specification"); int8u P1; Skip_B1( "control_code"); Get_B1 (P1, "P1"); if (P1==0x20) Skip_B1( "P2"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::FLC() { Element_Begin1("FLC - Flashing control"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::CDC() { Element_Begin1("CDC - Conceal Display Controls"); int8u P1; Skip_B1( "control_code"); Get_B1 (P1, "P1"); if (P1==0x20) Skip_B1( "P2"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::POL() { Element_Begin1("POL - Pattern polarity"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::WMM() { Element_Begin1("WMM - Modification of write mode"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::MACRO() { Element_Begin1("MACRO - Macro specification"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); //TODO: save macros } //--------------------------------------------------------------------------- void File_AribStdB24B37::HLC() { Element_Begin1("HLC - Enclosure control"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::RPC() { Element_Begin1("RPC - Character repeat"); Skip_B1( "control_code"); Skip_B1( "P1"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::SPL() { Element_Begin1("SPL - End of underline and mosaic separation"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::STL() { Element_Begin1("STL - Start of underline and mosaic separation"); Skip_B1( "control_code"); Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::CSI() { Element_Begin1("CSI - Extended Control Codes"); Skip_B1( "control_code"); vector Params; Params.push_back(0); size_t Pos=0; while (Element_Offset+Pos<=Element_Size) { int8u Value=Buffer[Buffer_Offset+Element_Offset+Pos]; Pos++; if (Value==0x3B) Params.push_back(0); else if (Value>=0x30 && Value<0x3A) { Params[Params.size()-1]*=10; Params[Params.size()-1]+=Value&0x0F; } else if (Value>=0x40 && Value<0x80) { Pos--; Skip_Local(Pos, "Values"); Get_B1(Value, "Delimiter"); switch (Value) { case 0x3B: Element_Info1("SRC - Raster Colour Designation"); break; case 0x42: Element_Info1("GSM - Character deformation"); break; case 0x53: Element_Info1("SWF - Set Writing Format"); if (!Params.empty() && Params[0]<0x100) Streams[(size_t)(Element_Code-1)].Format=(int8u)Params[0]; break; case 0x54: Element_Info1("CCC - Composite Character Composition"); break; case 0x56: Element_Info1("SDF - Set Display Format"); break; case 0x57: Element_Info1("SSM - Character composition dot designation"); break; case 0x58: Element_Info1("SHS - Set Horizontal Spacing"); break; case 0x59: Element_Info1("SVS - Set Vertical Spacing"); break; case 0x5B: Element_Info1("PLD - Partially Line Down"); break; case 0x5C: Element_Info1("PLU - Partialyl Line Up"); break; case 0x5D: Element_Info1("GAA - Colouring block"); break; case 0x5F: Element_Info1("SDF - Set Display Position"); break; case 0x61: Element_Info1("ACPS - Active Coordinate Position Set"); //TODO: positioning break; case 0x62: Element_Info1("TCC - Switching control"); // Also Table 5-3 break; case 0x63: Element_Info1("ORN - Ornament Control"); break; case 0x64: Element_Info1("MDF - Font"); break; case 0x65: Element_Info1("CFS - Character Font Set"); break; case 0x66: Element_Info1("XCS - External Character Set"); break; case 0x67: Element_Info1("SCR - Scroll designation"); // Also Table 5-4 break; case 0x68: Element_Info1("PRA - Built-in sound replay"); break; case 0x69: Element_Info1("ACS - Alternative Character Set"); break; case 0x6E: Element_Info1("RCS - Raster Colour command"); break; case 0x6F: Element_Info1("SCS - Skip Character Set"); break; default: ; //Unknown } break; } } Element_End0(); } //--------------------------------------------------------------------------- void File_AribStdB24B37::TIME() { Element_Begin1("TIME - Time"); Skip_B1( "control_code"); Skip_B1( "P1"); Skip_B1( "P2"); Element_End0(); // if P1 is 0x20, there should be a delay } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_ARIBSTDB24B37_YES MediaInfoLib/Source/MediaInfo/Text/File_Cmml.cpp0000664000000000000000000000743612652076434020435 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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(""), __T("")); if (!Value.empty()) Fill(Stream_Text, 0, Text_Title, Value.SubString(__T(""), __T(""))); if (Data.find(__T(" streams; streams Streams; int8u FieldLines[5]; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/MediaInfo.cpp0000664000000000000000000002047612652076434017514 0ustar rootroot// MediaInfo - All info about media files //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo.h" #include "MediaInfo/MediaInfo_Internal.h" #if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64) #include // needed for _set_FMA3_enable() #endif 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(); // FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). // See https://connect.microsoft.com/VisualStudio/feedback/details/987093/x64-log-function-uses-vpsrlq-avx-instruction-without-regard-to-operating-system-so-it-crashes-on-vista-x64 // Hotfix: we disable it for MSVC2013. #if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64) _set_FMA3_enable(0); #endif } //--------------------------------------------------------------------------- MediaInfo::~MediaInfo() { delete Internal; //Internal=NULL; } //*************************************************************************** // Files //*************************************************************************** //--------------------------------------------------------------------------- size_t MediaInfo::Open(const String &File_Name_) { return 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 Internal->Open(Begin, Begin_Size, End, End_Size, (File_SizeOpen_Buffer_Init(File_Size, File_Offset); } //--------------------------------------------------------------------------- size_t MediaInfo::Open_Buffer_Continue (const int8u* ToAdd, size_t ToAdd_Size) { return Internal->Open_Buffer_Continue(ToAdd, ToAdd_Size).to_ulong(); } //--------------------------------------------------------------------------- int64u MediaInfo::Open_Buffer_Continue_GoTo_Get () { return Internal->Open_Buffer_Continue_GoTo_Get(); } //--------------------------------------------------------------------------- size_t MediaInfo::Open_Buffer_Finalize () { return Internal->Open_Buffer_Finalize(); } //--------------------------------------------------------------------------- size_t MediaInfo::Open_NextPacket () { return Internal->Open_NextPacket().to_ulong(); } //--------------------------------------------------------------------------- size_t MediaInfo::Save() { return 0; //Not yet implemented } //--------------------------------------------------------------------------- void MediaInfo::Close() { return Internal->Close(); } //*************************************************************************** // Get File info //*************************************************************************** //--------------------------------------------------------------------------- String MediaInfo::Inform(size_t) { return Internal->Inform(); } //--------------------------------------------------------------------------- String MediaInfo::Get(stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo) { return 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 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 Internal->Output_Buffer_Get(Value); } //--------------------------------------------------------------------------- size_t MediaInfo::Output_Buffer_Get (size_t Pos) { return Internal->Output_Buffer_Get(Pos); } //*************************************************************************** // Information //*************************************************************************** //--------------------------------------------------------------------------- String MediaInfo::Option (const String &Option, const String &Value) { return 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 Internal->Count_Get(StreamKind, StreamPos); } //--------------------------------------------------------------------------- size_t MediaInfo::State_Get () { return Internal->State_Get(); } } //NameSpace MediaInfoLib/Source/MediaInfo/File_Unknown.cpp0000664000000000000000000000343112652076434020247 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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"); } //--------------------------------------------------------------------------- void File_Unknown::Read_Buffer_Continue() { Element_Offset=File_Size; Finish("Unknown"); } //*************************************************************************** // //*************************************************************************** } //NameSpace #endif //MEDIAINFO_UNKNOWN_YES MediaInfoLib/Source/MediaInfo/MediaInfo_Config.cpp0000664000000000000000000025536412652076434021007 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Global configuration of MediaInfo // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Debug #ifdef MEDIAINFO_DEBUG #include #include namespace MediaInfo_Config_Debug { FILE* F; std::string Debug; SYSTEMTIME st_In; void Debug_Open(bool Out) { F=fopen("C:\\Temp\\MediaInfo_Debug.txt", "a+t"); Debug.clear(); SYSTEMTIME st; GetLocalTime( &st ); char Duration[100]; if (Out) { FILETIME ft_In; if (SystemTimeToFileTime(&st_In, &ft_In)) { FILETIME ft_Out; if (SystemTimeToFileTime(&st, &ft_Out)) { ULARGE_INTEGER UI_In; UI_In.HighPart=ft_In.dwHighDateTime; UI_In.LowPart=ft_In.dwLowDateTime; ULARGE_INTEGER UI_Out; UI_Out.HighPart=ft_Out.dwHighDateTime; UI_Out.LowPart=ft_Out.dwLowDateTime; ULARGE_INTEGER UI_Diff; UI_Diff.QuadPart=UI_Out.QuadPart-UI_In.QuadPart; FILETIME ft_Diff; ft_Diff.dwHighDateTime=UI_Diff.HighPart; ft_Diff.dwLowDateTime=UI_Diff.LowPart; SYSTEMTIME st_Diff; if (FileTimeToSystemTime(&ft_Diff, &st_Diff)) { sprintf(Duration, "%02hd:%02hd:%02hd.%03hd", st_Diff.wHour, st_Diff.wMinute, st_Diff.wSecond, st_Diff.wMilliseconds); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else { st_In=st; strcpy(Duration, " "); } fprintf(F," %02hd:%02hd:%02hd.%03hd %s", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, Duration); } void Debug_Close() { Debug += "\r\n"; fwrite(Debug.c_str(), Debug.size(), 1, F); \ fclose(F); } } using namespace MediaInfo_Config_Debug; #define MEDIAINFO_DEBUG1(_NAME,_TOAPPEND) \ Debug_Open(false); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #define MEDIAINFO_DEBUG2(_NAME,_TOAPPEND) \ Debug_Open(true); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #else // MEDIAINFO_DEBUG #define MEDIAINFO_DEBUG1(_NAME,__TOAPPEND) #define MEDIAINFO_DEBUG2(_NAME,__TOAPPEND) #endif // MEDIAINFO_DEBUG //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Config.h" #include "ZenLib/ZtringListListF.h" #include "ZenLib/File.h" #include using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- const Char* MediaInfo_Version=__T("MediaInfoLib - v0.7.82"); const Char* MediaInfo_Url=__T("http://MediaArea.net/MediaInfo"); 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_CodecID_Other_Mpeg4 (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_Other (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; #if MEDIAINFO_ADVANCED VariableGopDetection_Occurences=4; VariableGopDetection_GiveUp=false; InitDataNotRepeated_Occurences=(int64u)-1; //Disabled by default InitDataNotRepeated_GiveUp=false; #endif //MEDIAINFO_ADVANCED MpegTs_MaximumOffset=64*1024*1024; MpegTs_MaximumScanDuration=30000000000LL; MpegTs_ForceStreamDisplay=false; #if MEDIAINFO_ADVANCED MpegTs_VbrDetection_Delta=0; MpegTs_VbrDetection_Occurences=4; MpegTs_VbrDetection_GiveUp=false; #endif //MEDIAINFO_ADVANCED 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; Compat=70778; Trace_TimeSection_OnlyFirstOccurrence=false; Trace_Format=Trace_Format_Tree; Language_Raw=false; ReadByHuman=true; Legacy=true; LegacyStreamDisplay=true; SkipBinaryData=false; 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) { CS.Enter(); SubFile_Config(Option)=Value_Raw; CS.Leave(); 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("legacy")) { Legacy_Set(Value.To_int8u()?true:false); return Ztring(); } else if (Option_Lower==__T("legacy_get")) { return Legacy_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("skipbinarydata")) { SkipBinaryData_Set(Value.To_int8u()?true:false); return Ztring(); } else if (Option_Lower==__T("skipbinarydata_get")) { return SkipBinaryData_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_Get(); } else if (Option_Lower==__T("details")) //Legacy for trace_level { if (Value == __T("0")) Trace_Level=0; 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); if (Inform_Get()==__T("MAXML")) Trace_Format_Set(Trace_Format_XML); // All must be XML if (Inform_Get()==__T("XML") || Inform_Get()==__T("MAXML")) { Inform_Set(Ztring()); Trace_Format_Set(Trace_Format_XML); // TODO: better coherency in options } 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 if (NewValue_Lower==__T("xml") || NewValue_Lower==__T("MAXML")) Trace_Format_Set(Trace_Format_XML); 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; PosTo_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("variablegopdetection_occurences")) { #if MEDIAINFO_ADVANCED VariableGopDetection_Occurences_Set(Value.To_int64u()); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("variablegopdetection_occurences_get")) { #if MEDIAINFO_ADVANCED return Ztring::ToZtring(VariableGopDetection_Occurences_Get()); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("variablegopdetection_giveup")) { #if MEDIAINFO_ADVANCED VariableGopDetection_GiveUp_Set(Value.To_int8u()?true:false); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("variablegopdetection_giveup_get")) { #if MEDIAINFO_ADVANCED return VariableGopDetection_GiveUp_Get()?__T("1"):__T("0"); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("initdatanotrepeated_occurences")) { #if MEDIAINFO_ADVANCED InitDataNotRepeated_Occurences_Set(Value.To_int64u()); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("initdatanotrepeated_occurences_get")) { #if MEDIAINFO_ADVANCED return Ztring::ToZtring(InitDataNotRepeated_Occurences_Get()); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("initdatanotrepeated_giveup")) { #if MEDIAINFO_ADVANCED InitDataNotRepeated_GiveUp_Set(Value.To_int8u()?true:false); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("initdatanotrepeated_giveup_get")) { #if MEDIAINFO_ADVANCED return InitDataNotRepeated_GiveUp_Get()?__T("1"):__T("0"); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } 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_vbrdetection_delta")) { #if MEDIAINFO_ADVANCED MpegTs_VbrDetection_Delta_Set(Value.To_float64()); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("mpegts_vbrdetection_delta_get")) { #if MEDIAINFO_ADVANCED return Ztring::ToZtring(MpegTs_VbrDetection_Delta_Get(), 9); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("mpegts_vbrdetection_occurences")) { #if MEDIAINFO_ADVANCED MpegTs_VbrDetection_Occurences_Set(Value.To_int64u()); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("mpegts_vbrdetection_occurences_get")) { #if MEDIAINFO_ADVANCED return Ztring::ToZtring(MpegTs_VbrDetection_Occurences_Get()); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("mpegts_vbrdetection_giveup")) { #if MEDIAINFO_ADVANCED MpegTs_VbrDetection_GiveUp_Set(Value.To_int8u()?true:false); return Ztring(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("mpegts_vbrdetection_giveup_get")) { #if MEDIAINFO_ADVANCED return MpegTs_VbrDetection_GiveUp_Get()?__T("1"):__T("0"); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } 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("maxml_streamkinds")) { #if MEDIAINFO_ADVANCED return MAXML_StreamKinds_Get(); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } else if (Option_Lower==__T("maxml_fields")) { #if MEDIAINFO_ADVANCED return MAXML_Fields_Get(Value); #else // MEDIAINFO_ADVANCED return __T("advanced features are disabled due to compilation options"); #endif // MEDIAINFO_ADVANCED } 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 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::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=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 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) { if (Value.size()<7 || Value.find(__T("/String"))+7!=Value.size()) return Language.Get(Value); Ztring Temp(Value); Temp.resize(Value.size()-7); return Language.Get(Temp); } ZtringList List; List.Separator_Set(0, __T(" / ")); List.Write(Value); //Per value for (size_t Pos=0; Pos=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 if (Trace_Level_Get() && NewValue.Read(0, 0)==__T("XML")) { Trace_Format_Set(Trace_Format_XML); // TODO: better coherency in options return; } else { if (NewValue.Read(0, 0)==__T("MAXML")) Trace_Format_Set(Trace_Format_XML); //All must be XML else Trace_Format_Set(Trace_Format_Tree); // TODO: better coherency in options 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; Pos1 && 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=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; case Stream_Other : switch (Format) { case InfoCodecID_Format_Mpeg4 : MediaInfo_Config_CodecID_Other_Mpeg4(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::Iso639_Translate (const Ztring Value) { Ztring Code(Value); if (Code.size()==3 && !MediaInfoLib::Config.Iso639_1_Get(Code).empty()) Code=MediaInfoLib::Config.Iso639_1_Get(Code); if (Code.size()>3 && !MediaInfoLib::Config.Iso639_Find(Code).empty()) Code=MediaInfoLib::Config.Iso639_Find(Code); if (Code.size()>3) return Value; Ztring Language_Translated=MediaInfoLib::Config.Language_Get(__T("Language_")+Code); if (Language_Translated.find(__T("Language_"))==0) return Value; //No translation found return Language_Translated; } //--------------------------------------------------------------------------- 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_Other : MediaInfo_Config_Other(Info[Stream_Other]); Language_Set(Stream_Other); 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_Other : MediaInfo_Config_Other(Info[Stream_Other]); Language_Set(Stream_Other); 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_Other : MediaInfo_Config_Other(Info[Stream_Other]); Language_Set(Stream_Other); 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 (bool Complete) { CS.Enter(); //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_Other(Info[Stream_Other]); 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; StreamKindsecond.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; } #if MEDIAINFO_ADVANCED void MediaInfo_Config::VariableGopDetection_Occurences_Set (int64u Value) { CriticalSectionLocker CSL(CS); VariableGopDetection_Occurences=Value; } int64u MediaInfo_Config::VariableGopDetection_Occurences_Get () { CriticalSectionLocker CSL(CS); return VariableGopDetection_Occurences; } #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void MediaInfo_Config::VariableGopDetection_GiveUp_Set (bool Value) { CriticalSectionLocker CSL(CS); VariableGopDetection_GiveUp=Value; } bool MediaInfo_Config::VariableGopDetection_GiveUp_Get () { CriticalSectionLocker CSL(CS); return VariableGopDetection_GiveUp; } #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void MediaInfo_Config::InitDataNotRepeated_Occurences_Set (int64u Value) { CriticalSectionLocker CSL(CS); InitDataNotRepeated_Occurences=Value; } int64u MediaInfo_Config::InitDataNotRepeated_Occurences_Get () { CriticalSectionLocker CSL(CS); return InitDataNotRepeated_Occurences; } #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void MediaInfo_Config::InitDataNotRepeated_GiveUp_Set (bool Value) { CriticalSectionLocker CSL(CS); InitDataNotRepeated_GiveUp=Value; } bool MediaInfo_Config::InitDataNotRepeated_GiveUp_Get () { CriticalSectionLocker CSL(CS); return InitDataNotRepeated_GiveUp; } #endif // MEDIAINFO_ADVANCED 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; } #if MEDIAINFO_ADVANCED void MediaInfo_Config::MpegTs_VbrDetection_Delta_Set (float64 Value) { CriticalSectionLocker CSL(CS); MpegTs_VbrDetection_Delta=Value; } float64 MediaInfo_Config::MpegTs_VbrDetection_Delta_Get () { CriticalSectionLocker CSL(CS); return MpegTs_VbrDetection_Delta; } #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void MediaInfo_Config::MpegTs_VbrDetection_Occurences_Set (int64u Value) { CriticalSectionLocker CSL(CS); MpegTs_VbrDetection_Occurences=Value; } int64u MediaInfo_Config::MpegTs_VbrDetection_Occurences_Get () { CriticalSectionLocker CSL(CS); return MpegTs_VbrDetection_Occurences; } #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void MediaInfo_Config::MpegTs_VbrDetection_GiveUp_Set (bool Value) { CriticalSectionLocker CSL(CS); MpegTs_VbrDetection_GiveUp=Value; } bool MediaInfo_Config::MpegTs_VbrDetection_GiveUp_Get () { CriticalSectionLocker CSL(CS); return MpegTs_VbrDetection_GiveUp; } #endif // MEDIAINFO_ADVANCED 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; } #if MEDIAINFO_ADVANCED Ztring MediaInfo_Config::MAXML_StreamKinds_Get () { ZtringList List; CriticalSectionLocker CSL(CS); for (size_t StreamKind=0; StreamKind=Stream_Max) return Ztring(); ZtringList List; for (size_t FieldPos = 0; FieldPos < Info[StreamKind].size(); FieldPos++) if (Info_Options < Info[StreamKind][FieldPos].size() && InfoOption_ShowInXml < Info[StreamKind][FieldPos][Info_Options].size() && Info[StreamKind][FieldPos][Info_Options][InfoOption_ShowInXml]==__T('Y')) List.push_back(Xml_Name_Escape_0_7_78(Info[StreamKind][FieldPos][Info_Name])); List.Separator_Set(0, __T(",")); return List.Read(); } #endif // MEDIAINFO_ADVANCED //*************************************************************************** // 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 >::iterator PerFormat=CustomMapping.find(Format); if (PerFormat==CustomMapping.end()) return false; std::map::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 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() { size_t BS_Size; if (Element_Offset>=Element_Size) BS_Size=0; else if (Buffer_Offset+Element_Size<=Buffer_Size) BS_Size=(size_t)(Element_Size-Element_Offset); else if (Buffer_Offset+Element_Offset<=Buffer_Size) BS_Size=Buffer_Size-(size_t)(Buffer_Offset+Element_Offset); else BS_Size=0; BS->Attach(Buffer+Buffer_Offset+(size_t)Element_Offset, BS_Size); } //--------------------------------------------------------------------------- void File__Analyze::BS_Begin_LE() { size_t BS_Size; if (Buffer_Offset+Element_Size<=Buffer_Size) BS_Size=(size_t)(Element_Size-Element_Offset); else if (Buffer_Offset+Element_Offset<=Buffer_Size) BS_Size=Buffer_Size-(size_t)(Buffer_Offset+Element_Offset); else BS_Size=0; 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; } //--------------------------------------------------------------------------- // Big Endian - float 16 bits // TODO: remove it when Linux version of ZenLib is updated float32 BigEndian2float16corrected(const char* Liste) { //sign 1 bit //exponent 5 bit //significand 10 bit //Retrieving data int16u Integer=BigEndian2int16u(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-=0x0F; //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; } inline float32 BigEndian2float16corrected (const int8u* List) {return BigEndian2float16corrected ((const char*)List);} //--------------------------------------------------------------------------- void File__Analyze::Get_BF2_(float32 &Info) { INTEGRITY_SIZE_ATLEAST_INT(4); Info=BigEndian2float16corrected(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; } //--------------------------------------------------------------------------- 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<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(InfoDRemain()>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)<Remain()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()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_6937_2(int64u Bytes, Ztring &Info) { INTEGRITY_SIZE_ATLEAST_STRING(Bytes); Info.clear(); size_t End = Buffer_Offset + (size_t)Element_Offset + (size_t)Bytes; for (size_t Pos=Buffer_Offset+(size_t)Element_Offset; PosRemain()) 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_T4_(int8u Bits, int32u &Info) { INTEGRITY_INT(Bits<=BT->Remain()) Info=BT->Get4(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_T4(int8u Bits, int32u &Info) { INTEGRITY_INT(Bits<=BT->Remain()) Info=BT->Peek4(Bits); } //--------------------------------------------------------------------------- void File__Analyze::Peek_T8(int8u Bits, int64u &Info) { INTEGRITY_INT(Bits<=BT->Remain()) Info=BT->Peek8(Bits); } } //NameSpace #endif //MEDIAINFO_TRACE MediaInfoLib/Source/MediaInfo/File_Unknown.h0000664000000000000000000000242512652076434017716 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/MediaInfo_Config_MediaInfo.cpp0000664000000000000000000027605212652076434022717 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Config.h" #include "ZenLib/ZtringListListF.h" #if MEDIAINFO_EVENTS #include "ZenLib/FileName.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_IBI || MEDIAINFO_AES #include "base64.h" #endif //MEDIAINFO_IBI || MEDIAINFO_AES #include #if MEDIAINFO_DEMUX #include #endif //MEDIAINFO_DEMUX using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Debug #ifdef MEDIAINFO_DEBUG #include #include namespace MediaInfo_Config_MediaInfo_Debug { FILE* F; std::string Debug; SYSTEMTIME st_In; void Debug_Open(bool Out) { F=fopen("C:\\Temp\\MediaInfo_Debug.txt", "a+t"); Debug.clear(); SYSTEMTIME st; GetLocalTime( &st ); char Duration[100]; if (Out) { FILETIME ft_In; if (SystemTimeToFileTime(&st_In, &ft_In)) { FILETIME ft_Out; if (SystemTimeToFileTime(&st, &ft_Out)) { ULARGE_INTEGER UI_In; UI_In.HighPart=ft_In.dwHighDateTime; UI_In.LowPart=ft_In.dwLowDateTime; ULARGE_INTEGER UI_Out; UI_Out.HighPart=ft_Out.dwHighDateTime; UI_Out.LowPart=ft_Out.dwLowDateTime; ULARGE_INTEGER UI_Diff; UI_Diff.QuadPart=UI_Out.QuadPart-UI_In.QuadPart; FILETIME ft_Diff; ft_Diff.dwHighDateTime=UI_Diff.HighPart; ft_Diff.dwLowDateTime=UI_Diff.LowPart; SYSTEMTIME st_Diff; if (FileTimeToSystemTime(&ft_Diff, &st_Diff)) { sprintf(Duration, "%02hd:%02hd:%02hd.%03hd", st_Diff.wHour, st_Diff.wMinute, st_Diff.wSecond, st_Diff.wMilliseconds); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else { st_In=st; strcpy(Duration, " "); } fprintf(F," %02hd:%02hd:%02hd.%03hd %s", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, Duration); } void Debug_Close() { Debug += "\r\n"; fwrite(Debug.c_str(), Debug.size(), 1, F); \ fclose(F); } } using namespace MediaInfo_Config_MediaInfo_Debug; #define MEDIAINFO_DEBUG1(_NAME,_TOAPPEND) \ Debug_Open(false); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #define MEDIAINFO_DEBUG2(_NAME,_TOAPPEND) \ Debug_Open(true); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #else // MEDIAINFO_DEBUG #define MEDIAINFO_DEBUG1(_NAME,__TOAPPEND) #define MEDIAINFO_DEBUG2(_NAME,__TOAPPEND) #endif // MEDIAINFO_DEBUG namespace MediaInfoLib { const size_t Buffer_NormalSize=/*188*7;//*/64*1024; //*************************************************************************** // Info //*************************************************************************** MediaInfo_Config_MediaInfo::MediaInfo_Config_MediaInfo() { FileIsSeekable=true; FileIsSub=false; FileIsDetectingDuration=false; FileIsReferenced=false; FileTestContinuousFileNames=true; FileKeepInfo=false; FileStopAfterFilled=false; FileStopSubStreamAfterFilled=false; Audio_MergeMonoStreams=false; File_Demux_Interleave=false; File_ID_OnlyRoot=false; #if MEDIAINFO_ADVANCED File_IgnoreSequenceFileSize=false; File_IgnoreSequenceFilesCount=false; File_SequenceFilesSkipFrames=0; File_DefaultFrameRate=0; File_Source_List=false; File_RiskyBitRateEstimation=false; File_MergeBitRateInfo=true; #if MEDIAINFO_DEMUX File_Demux_Unpacketize_StreamLayoutChange_Skip=false; #endif //MEDIAINFO_DEMUX #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_MD5 File_Md5=false; #endif //MEDIAINFO_MD5 #if defined(MEDIAINFO_REFERENCES_YES) File_CheckSideCarFiles=false; #endif //defined(MEDIAINFO_REFERENCES_YES) File_TimeToLive=0; File_Buffer_Size_Hint_Pointer=NULL; File_Buffer_Read_Size=64*1024*1024; #if MEDIAINFO_AES Encryption_Format=Encryption_Format_None; Encryption_Method=Encryption_Method_None; Encryption_Mode=Encryption_Mode_None; Encryption_Padding=Encryption_Padding_None; #endif //MEDIAINFO_AES #if MEDIAINFO_NEXTPACKET NextPacket=false; #endif //MEDIAINFO_NEXTPACKET #if MEDIAINFO_FILTER File_Filter_Audio=false; 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_PCM_20bitTo24bit=false; Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10=false; Demux_Hevc_Transcode_Iso14496_15_to_AnnexB=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_IBIUSAGE Ibi_UseIbiInfoIfAvailable=false; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE Ibi_Create=false; #endif //MEDIAINFO_IBIUSAGE //Specific File_MpegTs_ForceMenu=false; File_MpegTs_stream_type_Trust=true; File_MpegTs_Atsc_transport_stream_id_Trust=true; File_MpegTs_RealTime=false; File_Mxf_TimeCodeFromMaterialPackage=false; File_Mxf_ParseIndex=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; #if defined(MEDIAINFO_AC3_YES) File_Ac3_IgnoreCrc=false; #endif //defined(MEDIAINFO_AC3_YES) //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_IsImageSequence=false; #if defined(MEDIAINFO_EIA608_YES) File_Scte20_IsPresent=false; #endif //defined(MEDIAINFO_EIA608_YES) #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) File_DtvccTransport_Stream_IsPresent=false; File_DtvccTransport_Descriptor_IsPresent=false; #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) File_Current_Offset=0; File_Current_Size=(int64u)-1; File_IgnoreEditsBefore=0; File_IgnoreEditsAfter=(int64u)-1; File_EditRate=0; File_Size=(int64u)-1; ParseSpeed=MediaInfoLib::Config.ParseSpeed_Get(); #if MEDIAINFO_EVENTS Config_PerPackage=NULL; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Demux_EventWasSent=false; Demux_Offset_Frame=(int64u)-1; Demux_Offset_DTS=(int64u)-1; Demux_Offset_DTS_FromStream=(int64u)-1; Events_Delayed_CurrentSource=NULL; #if MEDIAINFO_SEEK Demux_IsSeeking=false; #endif //MEDIAINFO_SEEK #endif //MEDIAINFO_DEMUX #if MEDIAINFO_SEEK File_GoTo_IsFrameOffset=false; #endif //MEDIAINFO_SEEK } MediaInfo_Config_MediaInfo::~MediaInfo_Config_MediaInfo() { delete[] File_Buffer; //File_Buffer=NULL; #if MEDIAINFO_EVENTS for (events_delayed::iterator Event=Events_Delayed.begin(); Event!=Events_Delayed.end(); ++Event) for (size_t Pos=0; Possecond.size(); Pos++) delete Event->second[Pos]; //Event->second[Pos]=NULL; #endif //MEDIAINFO_EVENTS } //*************************************************************************** // 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_isdetectingduration")) { File_IsDetectingDuration_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_isdetectingduration_get")) { return File_IsDetectingDuration_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_testcontinuousfilenames")) { File_TestContinuousFileNames_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_testcontinuousfilenames_get")) { return File_TestContinuousFileNames_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_ignoresequencefilescount")) { #if MEDIAINFO_ADVANCED File_IgnoreSequenceFilesCount_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_sequencefilesskipframes") || Option_Lower==__T("file_sequencefileskipframes")) { #if MEDIAINFO_ADVANCED File_SequenceFilesSkipFrames_Set(Ztring(Value).To_int64u()); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_defaultframerate")) { #if MEDIAINFO_ADVANCED File_DefaultFrameRate_Set(Ztring(Value).To_float64()); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("File_DefaultFrameRate is disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_source_list")) { #if MEDIAINFO_ADVANCED File_Source_List_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("File_Source_List_Set is disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_riskybitrateestimation")) { #if MEDIAINFO_ADVANCED File_RiskyBitRateEstimation_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_mergebitrateinfo")) { #if MEDIAINFO_ADVANCED File_MergeBitRateInfo_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_demux_unpacketize_streamlayoutchange_skip")) { #if MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED File_Demux_Unpacketize_StreamLayoutChange_Skip_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED #else //MEDIAINFO_ADVANCED return __T("Advanced features disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_md5")) { #if MEDIAINFO_MD5 File_Md5_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_MD5 return __T("MD5 is disabled due to compilation options"); #endif //MEDIAINFO_MD5 } else if (Option_Lower==__T("file_hash")) { #if MEDIAINFO_HASH ZtringList List; List.Separator_Set(0, __T(",")); List.Write(Value); ZtringList ToReturn; ToReturn.Separator_Set(0, __T(",")); HashWrapper::HashFunctions Functions; for (size_t i=0; i=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_PCM_20bitTo24bit_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_PCM_20bitTo24bit=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo24bit_Get () { CriticalSectionLocker CSL(CS); return Demux_PCM_20bitTo24bit; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get () { CriticalSectionLocker CSL(CS); return Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_Hevc_Transcode_Iso14496_15_to_AnnexB=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get () { CriticalSectionLocker CSL(CS); return Demux_Hevc_Transcode_Iso14496_15_to_AnnexB; } //--------------------------------------------------------------------------- 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_IBIUSAGE //--------------------------------------------------------------------------- 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_UseIbiInfoIfAvailable_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Ibi_UseIbiInfoIfAvailable=NewValue; } bool MediaInfo_Config_MediaInfo::Ibi_UseIbiInfoIfAvailable_Get () { CriticalSectionLocker CSL(CS); return Ibi_UseIbiInfoIfAvailable; } #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE //--------------------------------------------------------------------------- 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_IBIUSAGE //*************************************************************************** // Encryption //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Format_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_format Encryption_Format_Temp=Encryption_Format_None; if (Data=="AES") Encryption_Format_Temp=Encryption_Format_Aes; CriticalSectionLocker CSL(CS); Encryption_Format=Encryption_Format_Temp; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Encryption_Format_Set (encryption_format Value) { CriticalSectionLocker CSL(CS); Encryption_Format=Value; } string MediaInfo_Config_MediaInfo::Encryption_Format_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Format) { case Encryption_Format_Aes: return "AES"; default: return string(); } } encryption_format MediaInfo_Config_MediaInfo::Encryption_Format_Get () { CriticalSectionLocker CSL(CS); return Encryption_Format; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Key_Set (const Ztring &Value) { string Data_Base64=Value.To_UTF8(); CriticalSectionLocker CSL(CS); Encryption_Key=Base64::decode(Data_Base64); } void MediaInfo_Config_MediaInfo::Encryption_Key_Set (const int8u* Value, size_t Value_Size) { CriticalSectionLocker CSL(CS); Encryption_Key=string((const char*)Value, Value_Size); } string MediaInfo_Config_MediaInfo::Encryption_Key_Get () { CriticalSectionLocker CSL(CS); return Encryption_Key; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Method_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_method Encryption_Method_Temp=Encryption_Method_None; if (Data=="Segment") Encryption_Method_Temp=Encryption_Method_Segment; CriticalSectionLocker CSL(CS); Encryption_Method=Encryption_Method_Temp; } void MediaInfo_Config_MediaInfo::Encryption_Method_Set (encryption_method Value) { CriticalSectionLocker CSL(CS); Encryption_Method=Value; } string MediaInfo_Config_MediaInfo::Encryption_Method_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Method) { case Encryption_Method_Segment: return "Segment"; default: return string(); } } encryption_method MediaInfo_Config_MediaInfo::Encryption_Method_Get () { CriticalSectionLocker CSL(CS); return Encryption_Method; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Mode_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_mode Encryption_Mode_Temp=Encryption_Mode_None; if (Data=="CBC") Encryption_Mode_Temp=Encryption_Mode_Cbc; CriticalSectionLocker CSL(CS); Encryption_Mode=Encryption_Mode_Temp; } void MediaInfo_Config_MediaInfo::Encryption_Mode_Set (encryption_mode Value) { CriticalSectionLocker CSL(CS); Encryption_Mode=Value; } string MediaInfo_Config_MediaInfo::Encryption_Mode_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Mode) { case Encryption_Mode_Cbc: return "CBC"; default: return string(); } } encryption_mode MediaInfo_Config_MediaInfo::Encryption_Mode_Get () { CriticalSectionLocker CSL(CS); return Encryption_Mode; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Padding_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_padding Encryption_Padding_Temp=Encryption_Padding_None; if (Data=="PKCS7") Encryption_Padding_Temp=Encryption_Padding_Pkcs7; CriticalSectionLocker CSL(CS); Encryption_Padding=Encryption_Padding_Temp; } void MediaInfo_Config_MediaInfo::Encryption_Padding_Set (encryption_padding Value) { CriticalSectionLocker CSL(CS); Encryption_Padding=Value; } string MediaInfo_Config_MediaInfo::Encryption_Padding_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Padding) { case Encryption_Padding_Pkcs7: return "PKCS7"; default: return string(); } } encryption_padding MediaInfo_Config_MediaInfo::Encryption_Padding_Get () { CriticalSectionLocker CSL(CS); return Encryption_Padding; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_InitializationVector_Set (const Ztring &Value) { if (Value==__T("Sequence number")) { CriticalSectionLocker CSL(CS); Encryption_InitializationVector="Sequence number"; } else { string Data_Base64=Value.To_UTF8(); CriticalSectionLocker CSL(CS); Encryption_InitializationVector=Base64::decode(Data_Base64); } } string MediaInfo_Config_MediaInfo::Encryption_InitializationVector_Get () { CriticalSectionLocker CSL(CS); return Encryption_InitializationVector; } #endif //MEDIAINFO_AES //*************************************************************************** // 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; PosFrameNumber!=(int64u)-1) Temp->FrameNumber+=Demux_Offset_Frame; if (Temp->FrameNumber_PresentationOrder!=(int64u)-1) Temp->FrameNumber_PresentationOrder+=Demux_Offset_Frame; } if (Demux_Offset_DTS!=(int64u)-1) { if (Temp->DTS!=(int64u)-1) Temp->DTS+=Demux_Offset_DTS; if (Temp->PTS!=(int64u)-1) Temp->PTS+=Demux_Offset_DTS; if (Demux_Offset_DTS_FromStream!=(int64u)-1) { if (Temp->DTS!=(int64u)-1) Temp->DTS-=Demux_Offset_DTS_FromStream; if (Temp->PTS!=(int64u)-1) Temp->PTS-=Demux_Offset_DTS_FromStream; } } if (File_IgnoreEditsBefore) { if (Temp->FrameNumber!=(int64u)-1) { if (Temp->FrameNumber>File_IgnoreEditsBefore) Temp->FrameNumber-=File_IgnoreEditsBefore; else Temp->FrameNumber=0; } if (Temp->DTS!=(int64u)-1) { if (File_IgnoreEditsBefore && File_EditRate) { int64u TimeOffset=float64_int64s(((float64)File_IgnoreEditsBefore)/File_EditRate*1000000000); if (Temp->DTS>TimeOffset) Temp->DTS-=TimeOffset; else Temp->DTS=0; } } if (Temp->PTS!=(int64u)-1) { if (File_IgnoreEditsBefore && File_EditRate) { int64u TimeOffset=float64_int64s(((float64)File_IgnoreEditsBefore)/File_EditRate*1000000000); if (Temp->PTS>TimeOffset) Temp->PTS-=TimeOffset; else Temp->PTS=0; } } } } if (Source) { event_delayed* Event=new event_delayed(Data_Content, Data_Size, File_Name); Events_Delayed[Source].push_back(Event); // Copying buffers int32u* EventCode=(int32u*)Data_Content; if (((*EventCode)&0x00FFFFFF)==((MediaInfo_Event_Global_Demux<<8)|4) && Data_Size==sizeof(MediaInfo_Event_Global_Demux_4)) { MediaInfo_Event_Global_Demux_4* Old=(MediaInfo_Event_Global_Demux_4*)Data_Content; MediaInfo_Event_Global_Demux_4* New=(MediaInfo_Event_Global_Demux_4*)Event->Data_Content; if (New->Content_Size) { int8u* Content=new int8u[New->Content_Size]; std::memcpy(Content, Old->Content, New->Content_Size*sizeof(int8u)); New->Content=Content; } if (New->Offsets_Size) { int64u* Offsets_Stream=new int64u[New->Offsets_Size]; std::memcpy(Offsets_Stream, Old->Offsets_Stream, New->Offsets_Size*sizeof(int64u)); New->Offsets_Stream=Offsets_Stream; int64u* Offsets_Content=new int64u[New->Offsets_Size]; std::memcpy(Offsets_Content, Old->Offsets_Content, New->Offsets_Size*sizeof(int64u)); New->Offsets_Content=Offsets_Content; } if (New->OriginalContent_Size) { int8u* OriginalContent=new int8u[New->OriginalContent_Size]; std::memcpy(OriginalContent, Old->OriginalContent, New->OriginalContent_Size*sizeof(int8u)); New->OriginalContent=OriginalContent; } } } else if (Event_CallBackFunction) { MEDIAINFO_DEBUG1( "CallBackFunction", Debug+=", EventID=";Debug+=Ztring::ToZtring(LittleEndian2int32u(Data_Content), 16).To_UTF8();) Event_CallBackFunction ((unsigned char*)Data_Content, Data_Size, Event_UserHandler); MEDIAINFO_DEBUG2( "CallBackFunction", ) } else if (!File_Name.empty()) { MediaInfo_Event_Generic* Event_Generic=(MediaInfo_Event_Generic*)Data_Content; if ((Event_Generic->EventCode&0x00FFFFFF)==((MediaInfo_Event_Global_Demux<<8)|0x04)) //Demux version 4 { if (!MediaInfoLib::Config.Demux_Get()) return; MediaInfo_Event_Global_Demux_4* Event=(MediaInfo_Event_Global_Demux_4*)Data_Content; Ztring File_Name_Final(File_Name); if (Event->StreamIDs_Size==0) File_Name_Final+=__T(".demux"); else for (size_t Pos=0; PosStreamIDs_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]) { Ztring ID; ID.From_Number(Event->StreamIDs[Pos], 16); while (ID.size()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); } } } void MediaInfo_Config_MediaInfo::Event_Accepted (File__Analyze* Source) { #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Demux_EventWasSent && NextPacket_Get()) { Events_Delayed_CurrentSource=Source; return; } #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET for (events_delayed::iterator Event=Events_Delayed.begin(); Event!=Events_Delayed.end(); ++Event) if (Event->first==Source) { for (size_t Pos=0; Possecond.size(); Pos++) if (Event->second[Pos]) { Event_Send(NULL, Event->second[Pos]->Data_Content, Event->second[Pos]->Data_Size, Event->second[Pos]->File_Name); int32u EventCode=*((int32u*)Event->second[Pos]->Data_Content); bool IsDemux=(EventCode&0x00FFFF00)==(MediaInfo_Event_Global_Demux<<8); if (IsDemux) { MediaInfo_Event_Global_Demux_4* Old=(MediaInfo_Event_Global_Demux_4*)Event->second[Pos]->Data_Content; delete[] Old->Content; Old->Content=NULL; if (Old->Offsets_Size) { delete[] Old->Offsets_Content; Old->Offsets_Content=NULL; } if (Old->Offsets_Size) { delete[] Old->OriginalContent; Old->OriginalContent=NULL; } } delete Event->second[Pos]; Event->second[Pos]=NULL; #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (IsDemux && NextPacket_Get()) { Demux_EventWasSent=true; Event->second.erase(Event->second.begin(), Event->second.begin()+Pos); Events_Delayed_CurrentSource=Source; return; } #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET } Events_Delayed.erase(Event->first); return; } } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Event_SubFile_Start(const Ztring &FileName_Absolute) { Ztring FileName_Relative; if (File_Names_RootDirectory.empty()) { FileName FN(FileName_Absolute); FileName_Relative=FN.Name_Get(); if (!FN.Extension_Get().empty()) { FileName_Relative+=__T('.'); FileName_Relative+=FN.Extension_Get(); } } else { Ztring Root=File_Names_RootDirectory+PathSeparator; FileName_Relative=FileName_Absolute; if (FileName_Relative.find(Root)==0) FileName_Relative.erase(0, Root.size()); } struct MediaInfo_Event_General_SubFile_Start_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(0, MediaInfo_Event_General_SubFile_Start, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_SubFile_Start_0); Event.StreamIDs_Size=0; std::string FileName_Relative_Ansi=FileName_Relative.To_UTF8(); std::wstring FileName_Relative_Unicode=FileName_Relative.To_Unicode(); std::string FileName_Absolute_Ansi=FileName_Absolute.To_UTF8(); std::wstring FileName_Absolute_Unicode=FileName_Absolute.To_Unicode(); Event.FileName_Relative=FileName_Relative_Ansi.c_str(); Event.FileName_Relative_Unicode=FileName_Relative_Unicode.c_str(); Event.FileName_Absolute=FileName_Absolute_Ansi.c_str(); Event.FileName_Absolute_Unicode=FileName_Absolute_Unicode.c_str(); Event_Send(NULL, (const int8u*)&Event, Event.EventSize); } #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_Mxf_TimeCodeFromMaterialPackage_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Mxf_TimeCodeFromMaterialPackage=NewValue; } bool MediaInfo_Config_MediaInfo::File_Mxf_TimeCodeFromMaterialPackage_Get () { CS.Enter(); bool Temp=File_Mxf_TimeCodeFromMaterialPackage; CS.Leave(); return Temp; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Mxf_ParseIndex_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Mxf_ParseIndex=NewValue; } bool MediaInfo_Config_MediaInfo::File_Mxf_ParseIndex_Get () { CS.Enter(); bool Temp=File_Mxf_ParseIndex; 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::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; } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_AC3_YES) void MediaInfo_Config_MediaInfo::File_Ac3_IgnoreCrc_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Ac3_IgnoreCrc=NewValue; } bool MediaInfo_Config_MediaInfo::File_Ac3_IgnoreCrc_Get () { CriticalSectionLocker CSL(CS); bool Temp=File_Ac3_IgnoreCrc; return Temp; } #endif //defined(MEDIAINFO_AC3_YES) //*************************************************************************** // 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 MediaInfoLib/Source/MediaInfo/MediaInfo_Internal_Const.h0000664000000000000000000001033112652076434022150 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Global configuration of MediaInfo // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Internal_ConstH #define MediaInfo_Internal_ConstH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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 #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 MediaInfoLib/Source/MediaInfo/MediaInfoList_Internal.h0000664000000000000000000001041112652076434021635 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Give information about a lot of media files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfoList_InternalH #define MediaInfoList_InternalH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo.h" #include "MediaInfo/MediaInfo_Internal.h" #include //--------------------------------------------------------------------------- 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 Info; std::queue ToParse; std::map 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 MediaInfoLib/Source/MediaInfo/Tag/0000775000000000000000000000000012652076434015657 5ustar rootrootMediaInfoLib/Source/MediaInfo/Tag/File_Id3v2.cpp0000664000000000000000000021301612652076434020214 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 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() { //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 if ((Buffer[Buffer_Offset ]==0x49 // "ID3" && Buffer[Buffer_Offset+1]==0x44 && Buffer[Buffer_Offset+2]==0x33) || (Buffer[Buffer_Offset ]==0x65 // "ea3", found in OpenMG && Buffer[Buffer_Offset+1]==0x61 && Buffer[Buffer_Offset+2]==0x33)) Tag_Found=true; else Tag_Found=false; //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"); if (!(Frame_ID&0xFF)) Frame_ID>>=8; 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"); } } //Hanlding Unsynchronisation if (Unsynchronisation_Global || Unsynchronisation_Frame) { if (Buffer_Offset+(size_t)Element_Offset+Size>Buffer_Size) { Element_WaitForMoreData(); return; } for (size_t Element_Offset_Unsynch=0; Element_Offset_Unsynch+2Buffer_Size) { Element_WaitForMoreData(); return; } } } //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 Unsynch_List; if (Unsynchronisation_Global || Unsynchronisation_Frame) { while (Element_Offset_Unsynch+2=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) 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_OffsetElement_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()) { if (Element_Values(1).find(__T("ExactAudioCopy"))==0) { Fill(Stream_General, 0, General_Encoded_Application, Element_Values(1)); return; } 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); break; 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); break; default: ; } 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"); string Owner; size_t Owner_Size=0; while (Element_Offset+Owner_Size=Element_Size) { Skip_XX(Element_Size-Element_Offset, "Unknown"); return; } Get_String(Owner_Size, Owner, "Owner identifier"); Skip_B1( "Null"); if (Owner=="com.apple.streaming.transportStreamTimestamp") { //http://tools.ietf.org/html/draft-pantos-http-live-streaming-13 int64u DTS; Get_B8 (DTS, "DTS"); FILLING_BEGIN(); if (DTS>=0x200000000LL) //33 bits { Fill(Stream_Audio, 0, Audio_Delay, DTS/90); FrameInfo.DTS=DTS*1000000/90; } FILLING_END(); } else { 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() { if (Element_Size<6) { Skip_XX(Element_Size, "(Problem)"); return; } 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 if (Element_Values(0)==__T("OMG_AGENR")) ; //Duplicate of Genre else if (Element_Values(0)==__T("OMG_ALBMS")) ; //Duplicate of Album else if (Element_Values(0)==__T("OMG_ASGTM")) ; //? else if (Element_Values(0)==__T("OMG_ATPE1")) ; //Duplicate of Title else if (Element_Values(0)==__T("OMG_TIT2S")) ; //Duplicate of Title else if (Element_Values(0)==__T("OMG_TPE1S")) ; //Duplicate of Artist else if (Element_Values(0)==__T("OMG_TRACK")) Fill(Stream_General, 0, General_Track_Position, Element_Values(1), true); else if (Element_Values(0)==__T("OMG_TRLDA")) ; //Duplicate of Date 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, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); 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 : Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); 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 MediaInfoLib/Source/MediaInfo/Tag/File_ApeTag.cpp0000664000000000000000000002167312652076434020474 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include 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 #include "tinyxml2.h" using namespace tinyxml2; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- const char* PropertyList_key(const string &key) { if (key=="director" || key=="directors") return "Director"; if (key=="codirector" || key=="codirectors") return "CoDirector"; if (key=="producer" || key=="producers") return "Producer"; if (key=="coproducer" || key=="coproducers") return "CoProducer"; if (key=="screenwriter" || key=="screenwriters") return "ScreenplayBy"; if (key=="studio" || key=="studios") return "ProductionStudio"; if (key=="cast") return "Actor"; return key.c_str(); } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_PropertyList::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; XMLElement* plist=document.FirstChildElement("plist"); if (!plist) { Reject("XMP"); return false; } XMLElement* dict=plist->FirstChildElement("dict"); if (!dict) { Reject("XMP"); return false; } Accept("PropertyList"); string key; for (XMLElement* dict_Item=dict->FirstChildElement(); dict_Item; dict_Item=dict_Item->NextSiblingElement()) { //key if (!strcmp(dict_Item->Value(), "key")) { const char* Text=dict_Item->GetText(); if (Text) key=Text; } //string if (!strcmp(dict_Item->Value(), "string")) { const char* Text=dict_Item->GetText(); if (Text) Fill(Stream_General, 0, PropertyList_key(key), Text); key.clear(); } //string if (!strcmp(dict_Item->Value(), "array")) { for (XMLElement* array_Item=dict_Item->FirstChildElement(); array_Item; array_Item=array_Item->NextSiblingElement()) { //dict if (!strcmp(array_Item->Value(), "dict")) { string key2; for (XMLElement* dict2_Item=array_Item->FirstChildElement(); dict2_Item; dict2_Item=dict2_Item->NextSiblingElement()) { //key if (!strcmp(dict2_Item->Value(), "key")) { const char* Text=dict2_Item->GetText(); if (Text) key2=Text; } //string if (!strcmp(dict2_Item->Value(), "string")) { const char* Text2=dict2_Item->GetText(); if (Text2) Fill(Stream_General, 0, key2=="name"?PropertyList_key(key):((string(PropertyList_key(key))+", "+key2).c_str()), Text2); key2.clear(); } } } } key.clear(); } } Finish(); return true; } } //NameSpace #endif //MEDIAINFO_PROPERTYLIST_YES MediaInfoLib/Source/MediaInfo/Tag/File_PropertyList.h0000664000000000000000000000231212652076434021445 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PropertyList files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_PropertyListH #define MediaInfo_File_PropertyListH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_PropertyList //*************************************************************************** class File_PropertyList : public File__Analyze { private : //Buffer - File header bool FileHeader_Begin(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Tag/File__Tags.cpp0000664000000000000000000006144012652076434020364 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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; 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; for (size_t Pos=0; PosStatus[File__Analyze::IsAccepted]) { #ifndef MEDIAINFO_ID3V2_YES const bool Priority=false; #else bool Priority=Parser_Streams_Fill_Priority[Pos]; #endif Parser_Streams_Fill[Pos]->Read_Buffer_Finalize(); Base->Merge(*(Parser_Streams_Fill[Pos]), Stream_General, 0, 0, Priority); Base->Merge(*(Parser_Streams_Fill[Pos]), Stream_Audio , 0, 0, Priority); } delete Parser_Streams_Fill[Pos]; //Parser_Streams_Fill[Pos]=NULL; } Parser_Streams_Fill.clear(); } //--------------------------------------------------------------------------- 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; } if (!Synchro_Offset) { if (!Synched_Test()) //Handling begin/intermediate Id3v2 return false; } //ID if (Base->Buffer_Offset+Synchro_Offset+8>Base->Buffer_Size) return false; int32u ID3=CC3(Base->Buffer+Base->Buffer_Offset+Synchro_Offset); int64u ID8=CC8(Base->Buffer+Base->Buffer_Offset+Synchro_Offset); if (ID3==0x494433 //"ID3" || ID8==0x4150455441474558LL //"APETAGEX" || ID8==0x4C59524943534245LL //"LYRICSBE" || ID3==0x544147) //"TAG" / "TAG+" Tag_Found=true; else Tag_Found=false; return true; } //--------------------------------------------------------------------------- bool File__Tags_Helper::Synched_Test() { if (SearchingForEndTags) return true; for (;;) { #ifdef MEDIAINFO_ID3V2_YES bool Priority=false; #else const bool Priority=false; #endif if (!Parser) { //Must have enough buffer for having header if (Base->Buffer_Offset+8>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); int64u ID8=CC8(Base->Buffer+Base->Buffer_Offset); if (ID==0x494433 || ID==0x656133) //"ID3" and "ea3" (found in OpenMG) { if (Base->Buffer_Offset+10>Base->Buffer_Size) return false; 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; if (Base->Buffer_Offset+Parser_Buffer_Size>Base->Buffer_Size) return false; if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_Size; if (Base->File_Offset_FirstSynched==(int64u)-1) Base->Buffer_TotalBytes_FirstSynched_Max+=Parser_Buffer_Size; #ifdef MEDIAINFO_ID3V2_YES Parser=new File_Id3v2; Priority=true; #else Parser=new File_Unknown; #endif Base->Element_Begin1("Id3v2"); } else if (ID8==0x4150455441474558LL) //"APETAGEX" { if (Base->Buffer_Offset+16>Base->Buffer_Size) return false; Parser_Buffer_Size=LittleEndian2int32u(Base->Buffer+Base->Buffer_Offset+12); if (LittleEndian2int32u(Base->Buffer+Base->Buffer_Offset+8)) Parser_Buffer_Size+=32; if (Base->Buffer_Offset+Parser_Buffer_Size>Base->Buffer_Size) return false; if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_Size; if (Base->File_Offset_FirstSynched==(int64u)-1) Base->Buffer_TotalBytes_FirstSynched_Max+=Parser_Buffer_Size; #ifdef MEDIAINFO_APETAG_YES Parser=new File_ApeTag; #else Parser=new File_Unknown; #endif Base->Element_Begin1("ApeTag"); } else if (ID8==0x4C59524943534245LL) //"LYRICSBE" { if (Base->Buffer_Offset+16>Base->Buffer_Size) return false; //Searching for "LYRICS200" std::string Buf((const char*)(Base->Buffer+Base->Buffer_Offset), Base->Buffer_Size-Base->Buffer_Offset); size_t Pos2=Buf.find("LYRICS200"); size_t Pos1=std::string::npos; if (Pos2==std::string::npos) Pos1=Buf.find("LYRICSEND"); if (Pos2!=std::string::npos) Parser_Buffer_Size=Pos2+9; else if (Pos1!=std::string::npos) Parser_Buffer_Size=Pos1+9; else Parser_Buffer_Size=(size_t)(Base->File_Size-(Base->File_Offset+Base->Buffer_Offset)); if (Base->Buffer_Offset+Parser_Buffer_Size>Base->Buffer_Size) return false; if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_Size; if (Base->File_Offset_FirstSynched==(int64u)-1) Base->Buffer_TotalBytes_FirstSynched_Max+=Parser_Buffer_Size; if (Pos2!=std::string::npos) { #ifdef MEDIAINFO_LYRICS3V2_YES Parser=new File_Lyrics3v2; ((File_Lyrics3v2*)Parser)->TotalSize=Parser_Buffer_Size; #else Parser=new File_Unknown; #endif Base->Element_Begin1("Lyrics2"); } else if (Pos1!=std::string::npos) { #ifdef MEDIAINFO_LYRICS3_YES Parser=new File_Lyrics3; ((File_Lyrics3*)Parser)->TotalSize=Parser_Buffer_Size; #else Parser=new File_Unknown; #endif Base->Element_Begin1("Lyrics"); } else { Parser=new File_Unknown; Base->Element_Begin1("Problem"); } } 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; if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_Size; 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; if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_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; if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_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 if (!TagSizeIsFinal) File_BeginTagSize+=Parser_Buffer_Size; Parser_Buffer_Size=(size_t)ApeTag_Size; Base->Element_Begin1("ApeTag"); } else break; Base->Open_Buffer_Init(Parser); } //We continue if (Parser) { if (!Parser_Buffer_Size) { delete Parser; Parser=NULL; return false; //Probably stuck in a loop, exit } int64u Size_ToParse=(Parser_Buffer_SizeBuffer_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, Priority); Base->Merge(*Parser, Stream_Audio , 0, 0, Priority); delete Parser; Parser=NULL; } else { Parser_Streams_Fill.push_back(Parser); #ifdef MEDIAINFO_ID3V2_YES Parser_Streams_Fill_Priority.push_back(Priority); #endif 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_WantedByParserGoTo(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_SizeFile_Size) //Must be at least at the end less 128 bytes of tags { if (Base->File_OffsetFile_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_SizeFile_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_SizeFile_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_SizeFile_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->File_Size-File_EndTagSize-15)-Base->File_Offset))), 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_SizeFile_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->File_Size-File_EndTagSize-32+12)-Base->File_Offset))); if (LittleEndian2int32u(Base->Buffer+((size_t)((Base->File_Size-File_EndTagSize-32+8)-Base->File_Offset)))==2000) ApeTag_Size+=32; File_EndTagSize+=ApeTag_Size; ApeTag_Offset=Base->File_Size-File_EndTagSize; TagSizeIsFinal=false; } } //Finished return true; } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace MediaInfoLib/Source/MediaInfo/Tag/File_Id3v2.h0000664000000000000000000001663712652076434017673 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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() {USLT();} 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 MediaInfoLib/Source/MediaInfo/Tag/File_VorbisCom.h0000664000000000000000000000361612652076434020700 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Tag/File_Lyrics3.cpp0000664000000000000000000000516112652076434020655 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_SizeTotalSize) 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 #include "tinyxml2.h" using namespace tinyxml2; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Xmp::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; std::string NameSpace; XMLElement* XmpMeta=document.FirstChildElement("xmpmeta"); if (XmpMeta==NULL) { NameSpace="x:"; XmpMeta=document.FirstChildElement((NameSpace+"xmpmeta").c_str()); } if (!XmpMeta) { Reject("XMP"); return false; } XMLElement* Rdf=XmpMeta->FirstChildElement("RDF"); if (Rdf==NULL) { NameSpace="rdf:"; Rdf=XmpMeta->FirstChildElement((NameSpace+"RDF").c_str()); } if (!Rdf) { Reject("XMP"); return false; } Accept("XMP"); for (XMLElement* Rdf_Item=Rdf->FirstChildElement(); Rdf_Item; Rdf_Item=Rdf_Item->NextSiblingElement()) { //RDF item if (!strcmp(Rdf_Item->Value(), (NameSpace+"Description").c_str())) { const char* Attribute; Attribute=Rdf_Item->Attribute("xmlns:pdfaid"); if (Attribute) { string Profile; if (strcmp(Attribute, "http://www.aiim.org/pdfa/ns/id/")) Profile=Attribute; else { Profile+="A"; Attribute=Rdf_Item->Attribute("pdfaid:part"); if (Attribute) { Profile+='-'; Profile+=Attribute; Attribute=Rdf_Item->Attribute("pdfaid:conformance"); if (Attribute) { string Conformance(Attribute); if (Conformance.size()==1 && Conformance[0]>='A' && Conformance[0]<='Z') Conformance[0]+=0x20; // From "A" to "a" Profile+=Conformance; } } } Fill(Stream_General, 0, General_Format_Profile, Profile); } } } Finish(); return true; } } //NameSpace #endif //MEDIAINFO_PDF_YES MediaInfoLib/Source/MediaInfo/Tag/File_Xmp.h0000664000000000000000000000223612652076434017536 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about XMP files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_XmpH #define MediaInfo_File_XmpH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Sami //*************************************************************************** class File_Xmp : public File__Analyze { private : //Buffer - File header bool FileHeader_Begin(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Tag/File_VorbisCom.cpp0000664000000000000000000004643712652076434021243 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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=__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("DISCTOTAL")) Fill(StreamKind_Common, 0, "Part/Position_Total", Value); 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') || Value[1]==__T('X'))) { int16u ValueI=0; for (size_t Pos=2; 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("VALID_BITS")) { if (Value.To_int64u()) { // Not related to bit depth, only a detected value, see http://forum.doom9.org/showthread.php?t=125966&page=680 // Fill(Stream_Audio, 0, Audio_BitDepth, Value); Fill(Stream_Audio, 0, Audio_BitDepth_Detected, Value); } } else if (Key==__T("HDCD")) { if (Value != __T("0")) { Fill(Stream_Audio, 0, "HDCD", "Yes"); } } 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 MediaInfoLib/Source/MediaInfo/Tag/File__Tags.h0000664000000000000000000000556012652076434020032 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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; vector Parser_Streams_Fill; //Parser to merge when filling #ifdef MEDIAINFO_ID3V2_YES vector Parser_Streams_Fill_Priority; //Parser to merge when filling #endif 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 MediaInfoLib/Source/MediaInfo/MediaInfo_Config_Automatic.cpp0000664000000000000000000125540612652076434023013 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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;Info@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" " character1; character\n" " character2; characters\n" " character3; characters\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" " fps1; fps\n" " fps2; fps\n" " fps3; fps\n" " frame1; frame\n" " frame2; frames\n" " frame3; frames\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" "3D;3D\n" "3DType;3D Type\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" "All;All\n" "AlternateGroup;Alternate group\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" "AudioComments;Audio Comments\n" "AudioCount;Count of audio streams\n" "AudioDescriptionPresent;Audio Description Present\n" "AudioDescriptionType;Audio Description Type\n" "AudioLoudnessStandard;Audio Loudness Standard\n" "AudioTrackLayout;Audio Track Layout\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" "BitDepth_Detected;Detected bit depth\n" "BitDepth_Stored;Stored bit depth\n" "BitRate;Bit rate\n" "BitRate_Encoded;Encoded 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" "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" "ClosedCaptionsLanguage;Closed Captions Language\n" "ClosedCaptionsPresent;Closed Captions Present\n" "ClosedCaptionsType;Closed Captions Type\n" "Codec;Codec\n" "Codec_Description;Codec description\n" "Codec_Info;Details for codec\n" "Codec_Profile;Codec profile\n" "Codec_Settings;Codec settings\n" "Codec_Settings_BVOP;Codec settings, BVOP\n" "Codec_Settings_CABAC;Codec settings, CABAC\n" "Codec_Settings_Endianness;Codec settings, Endianness\n" "Codec_Settings_Firm;Codec settings, Firm\n" "Codec_Settings_Floor;Codec settings, Floor\n" "Codec_Settings_GMC;Codec settings, GMC\n" "Codec_Settings_ITU;Codec settings, ITU\n" "Codec_Settings_Law;Codec settings, Law\n" "Codec_Settings_Matrix;Codec settings, Matrix\n" "Codec_Settings_PacketBitStream;Codec settings, Packet bitstream\n" "Codec_Settings_QPel;Codec settings, QPel\n" "Codec_Settings_Sign;Codec settings, Sign\n" "Codec_Url;Weblink for codec\n" "CodecID;Codec ID\n" "CodecID_Description;Description of the codec\n" "CoDirector;Codirector\n" "Collection;Collection\n" "Colorimetry;Colorimetry\n" "ColorSpace;Color space\n" "colour_primaries;Color primaries\n" "colour_range;Color range\n" "Comment;Comment\n" "CommissionedBy;Commissioned by\n" "Compilation;Compilation\n" "CompleteName;Complete name\n" "CompletionDate;Completion Date\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" "ContactEmail;Contact Email\n" "ContactTelephoneNumber;Contact Telephone Number\n" "Container and general information;Container and general information\n" "ContentType;ContentType\n" "CoProducer;Coproducer\n" "Copyright;Copyright\n" "CopyrightYear;Copyright Year\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" "Disabled;Disabled\n" "DisplayAspectRatio;Display aspect ratio\n" "DisplayAspectRatio_CleanAperture;Clean aperture display aspect ratio\n" "DisplayAspectRatio_Original;Original display aspect ratio\n" "DistributedBy;Distributed by\n" "Distributor;Distributor\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" "ElementCount;Count of elements\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" "EpisodeTitleNumber;Episode Title Number\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_BVOP;Format settings, BVOP\n" "Format_Settings_CABAC;Format settings, CABAC\n" "Format_Settings_Emphasis;Emphasis\n" "Format_Settings_Endianness;Format settings, Endianness\n" "Format_Settings_Firm;Format settings, Firm\n" "Format_Settings_Floor;Format settings, Floor\n" "Format_Settings_FrameMode;Frame mode\n" "Format_Settings_GMC;Format settings, GMC\n" "Format_Settings_GOP;Format settings, GOP\n" "Format_Settings_ITU;Format settings, ITU\n" "Format_Settings_Law;Format settings, Law\n" "Format_Settings_Matrix;Format settings, Matrix\n" "Format_Settings_Matrix_Custom;Custom\n" "Format_Settings_Matrix_Default;Default\n" "Format_Settings_Mode;Mode\n" "Format_Settings_ModeExtension;Mode extension\n" "Format_Settings_PacketBitStream;Format settings, Packet bitstream\n" "Format_Settings_PictureStructure;Format settings, picture structure\n" "Format_Settings_PS;Format settings, PS\n" "Format_Settings_Pulldown;Format settings, Pulldown\n" "Format_Settings_QPel;Format settings, QPel\n" "Format_Settings_RefFrames;Format settings, ReFrames\n" "Format_Settings_SBR;Format settings, SBR\n" "Format_Settings_Sign;Format settings, Sign\n" "Format_Settings_Wrapping;Format settings, wrapping mode\n" "Format_Url;Weblink for format\n" "Format_Version;Format version\n" "FpaManufacturer;FPA Manufacturer\n" "FpaPass;FPA Pass\n" "FpaVersion;FPA Version\n" "FrameCount;Frame count\n" "FrameRate;Frame rate\n" "FrameRate_Maximum;Maximum frame rate\n" "FrameRate_Minimum;Minimum frame rate\n" "FrameRate_Mode;Frame rate mode\n" "FrameRate_Mode_CFR;Constant\n" "FrameRate_Mode_VFR;Variable\n" "FrameRate_Nominal;Nominal 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;Alt. Rock\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 Rap\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;Psychedelic\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;Bebop\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 Cappella\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;Afro-Punk\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;Thrash Metal\n" "Genre_145;Anime\n" "Genre_146;JPop\n" "Genre_147;Synthpop\n" "Genre_148;Abstract\n" "Genre_149;Art Rock\n" "Genre_150;Baroque\n" "Genre_151;Bhangra\n" "Genre_152;Big Beat\n" "Genre_153;Breakbeat\n" "Genre_154;Chillout\n" "Genre_155;Downtempo\n" "Genre_156;Dub\n" "Genre_157;EBM\n" "Genre_158;Eclectic\n" "Genre_159;Electro\n" "Genre_160;Electroclash\n" "Genre_161;Emo\n" "Genre_162;Experimental\n" "Genre_163;Garage\n" "Genre_164;Global\n" "Genre_165;IDM\n" "Genre_166;Illbient\n" "Genre_167;Industro-Goth\n" "Genre_168;Jam Band\n" "Genre_169;Krautrock\n" "Genre_170;Leftfield\n" "Genre_171;Lounge\n" "Genre_172;Math Rock\n" "Genre_173;New Romantic\n" "Genre_174;Nu-Breakz\n" "Genre_175;Post-Punk\n" "Genre_176;Post-Rock\n" "Genre_177;Psytrance\n" "Genre_178;Shoegaze\n" "Genre_179;Space Rock\n" "Genre_180;Trop Rock\n" "Genre_181;World Music\n" "Genre_182;Neoclassical\n" "Genre_183;Audiobook\n" "Genre_184;Audio Theatre\n" "Genre_185;Neue Deutsche Welle\n" "Genre_186;Podcast\n" "Genre_187;Indie Rock\n" "Genre_188;G-Funk\n" "Genre_189;Dubstep\n" "Genre_190;Garage Rock\n" "Genre_191;Psybient\n" "Go to WebSite;Go to website\n" "Gop_OpenClosed;GOP, Open/Closed\n" "Gop_OpenClosed_Open;Open\n" "Gop_OpenClosed_Closed;Closed\n" "Gop_OpenClosed_FirstFrame;GOP, Open/Closed of first frame\n" "Grouping;Grouping\n" "h;h\n" "Header file;Create a header file\n" "Height;Height\n" "Height_CleanAperture;Clean aperture 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" "IdentClockStart;Ident Clock Start\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" "Interlaced_BFF;Bottom Field First\n" "Interlaced_Interlaced;Interlaced\n" "Interlaced_PPF;Progressive\n" "Interlaced_Progressive;Progressive\n" "Interlaced_TFF;Top Field First\n" "Interlacement;Interlacement\n" "Interleave_Duration;Interleave, duration\n" "Interleave_Preload;Interleave, preload duration\n" "Interleave_VideoFrames;Interleave, duration\n" "Interleaved;Interleaved\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_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_More;Language, more info\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" "LineUpStart;Line Up Start\n" "List;List\n" "Lyricist;Lyricist\n" "Lyrics;Lyrics\n" "Mastered_Date;Mastered date\n" "MasteredBy;Mastered by\n" "Matrix_Channel(s);Matrix encoding, Channel(s)\n" "Matrix_ChannelPositions;Matrix encoding, channel positions\n" "matrix_coefficients;Matrix coefficients\n" "Matrix_Format;Matrix encoding, format\n" "MediaInfo_About;MediaInfo provides easy access to technical and tag information about video and audio files.\r\nExcept the Mac App Store graphical user interface, it is open-source software, which means that it is free of charge to the end user and developers have freedom to study, to improve and to redistribute the program (BSD license)\n" "Menu;Menu\n" "Menu stream(s);Menu streams\n" "Menu_Codec_List;Menu codecs\n" "Menu_Hint;More possibilities\n" "Menu_No;No menu\n" "MenuCount;Count of menu streams\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_Content;A new version (v%Version%) is available, would you like to download it?\n" "NewVersion_Question_Title;A new version was released!\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" "OpenCaptionsLanguage;Open Captions Language\n" "OpenCaptionsPresent;Open Captions Present\n" "OpenCaptionsType;Open Captions Type\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" "OriginalSourceMedium_ID;ID in the original source medium\n" "Originator;Originator\n" "Other;Other\n" "OtherIdentifier;Other Identifier\n" "OtherIdentifierType;Other Identifier Type\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" "PackageName;Package name\n" "Part;Part\n" "Part_Count;Total count\n" "PartNumber;Part Number\n" "PartTotal;Part Total\n" "Performer;Performer\n" "Period;Period\n" "Phone;Phone\n" "PictureRatio;Picture Ratio\n" "PixelAspectRatio;Pixel aspect ratio\n" "PixelAspectRatio_CleanAperture;Clean aperture 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" "PrimaryAudioLanguage;Primary Audio Language\n" "Producer;Producer\n" "ProductionDesigner;Production designer\n" "ProductionNumber;Production Number\n" "ProductionStudio;Production studio\n" "ProductPlacement;Product Placement\n" "ProgrammeHasText;Programme Has Text\n" "ProgrammeTextLanguage;Programme Text Language\n" "ProgrammeTitle;Programme Title\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" "SamplesPerFrame;Samples per frame\n" "SamplingCount;Samples count\n" "SamplingRate;Sampling rate\n" "Save;Save\n" "ScanOrder;Scan order\n" "ScanOrder_Original;Original scan order\n" "ScanOrder_Stored;Stored scan order\n" "ScanOrder_StoredDisplayedInverted;Scan order, stored/displayed order inverted\n" "ScanOrder_StoreMethod;Scan order, store method\n" "ScanType;Scan type\n" "ScanType_Original;Original scan type\n" "ScanType_StoreMethod;Scan type, store method\n" "ScreenplayBy;Screenplay by\n" "Season;Season\n" "SecondaryAudioLanguage;Secondary Audio Language\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" "SeriesTitle;Series Title\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" "ShimName;Shim Name\n" "ShimVersion;Shim Version\n" "Show menu;Show menu\n" "Show toolbar;Show toolbar\n" "SigningPresent;Signing Present\n" "SignLanguage;Sign Language\n" "Sort;Sorted by\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" "StoreMethod_InterleavedFields;Interleaved fields\n" "StoreMethod_SeparatedFields;Separated fields\n" "StoreMethod_SeparatedFields_1;Separated fields (1 field per block)\n" "StoreMethod_SeparatedFields_2;Separated fields (2 fields per block)\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_Demuxed;Stream size when demuxed\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" "TertiaryAudioLanguage;Tertiary Audio Language\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" "TextlessElementsExist;Textless Elements Exist\n" "ThanksTo;Thanks to\n" "Thousands separator;Thousands separator\n" "TimeCode;Time code\n" "TimeCode_FirstFrame;Time code of first frame\n" "TimeCode_Settings;Time code settings\n" "TimeCode_Source;Time code source\n" "TimeCode_Striped;Time code, striped\n" "TimeStamp;Time stamp\n" "TimeZone;Timezone\n" "Title;Title\n" "Title_More;Title, more info\n" "Total;Total\n" "TotalNumberOfParts;Total Number Of Parts\n" "TotalProgrammeDuration;Total Programme Duration\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" "Type;Type\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" "VideoComments;Video Comments\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://MediaArea.net/MediaInfo\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_CleanAperture;Clean aperture 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( "AAF;;;M;Aaf;;aaf;;\n" "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" "DASH MPD;;;M;DashMpd;;mpd;application/dash+xml;;Lossy\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" "HDS F4M;Flash Media Manifest;;M;HdsF4m;;f4m\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 m2ts 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" "NUT;;;M;Nut;;nut;\n" "Ogg;;;M;Ogg;;ogg ogm opus;video/ogg;http://www.free-codecs.com/Ogg_DirectShow_Filters_download.htm\n" "PMP;;;M;Pmp;Playstation Portable;pmp;;\n" "PTX;;;M;Ptx;;ptx;;\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 Standard, 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" "HEVC;;;V;Hevc;High Efficiency Video Coding;avc h264;video/H265;http://www.itu.int\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;;;;Lossy\n" "AC-3;;;A;Ac3;Audio Coding 3;ac3;;;Lossy\n" "ADIF;;;A;Adif;Audio Data Interchange Format;;;\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" "OpenMG;;;A;OpenMG;;oma omg aa3;;;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" "Opus;;;A;;;;audio/opus;http://opus-codec.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" "Arri Raw;;;I;ArriRaw;;ari;;\n" "Bitmap;;;I;Bmp;;bmp;image/bmp;;Lossless\n" "BPG;;;I;Bpg;Better Portable Graphics;bpg;image/bpg;http://bellard.org/bpg/\n" "DDS;;;I;Dds;DirectDraw Surface;dds;;\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" "PCX;;;I;pcx;Personal Computer eXchange;pcx;image/pcx;;Lossless\n" "PNG;;;I;Png;Portable Network Graphic;png;image/png;;Lossless\n" "PSD;;;I;Psd;Photoshop File Format;psd;image/psd;http://www.adobe.com/;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" "N19;;;T;N19;;stl;;;Lossless\n" "PDF;;;T;Pdf;;pdf;;\n" "SAMI;;;T;Sami;;smi sami;;;Lossless\n" "SCC;;;T;SCC;;scc sc2;;;Lossless\n" "SubRip;;;T;SubRip;;srt;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless\n" "TTML;;;T;TTML;;dfxp;;;Lossless\n" "SSA;;;T;Other;;ssa;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless\n" "WebVTT;;;T;WebVTT;;vtt;;;Lossless\n" "Blender;;;O;Other;;blenders;;http://www.blender3d.com\n" "AutoCAD;;;O;Other;;;;http://www.autodesk.com\n" "PlayLater Video;;;V;Other;;;;http://www.playon.tv/playlater\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" "iso4;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_MPEGH/ISO/HEVC;HEVC;;\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" "V_VP9;VP9;;;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;422 HQ;;YUV;4:2:2\n" "apcn;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422;;YUV;4:2:2\n" "apcs;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422 LT;;YUV;4:2:2\n" "apco;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422 Proxy;;YUV;4:2:2\n" "ap4c;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;4444;;;4:4:4\n" "ap4h;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;4444;;;4:4:4\n" "ap4x;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;4444 XQ;;;4:4:4\n" "ai11;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;\n" "ai12;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;\n" "ai13;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;\n" "ai14;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" "AV1x;YUV;;;;;;YUV;4:2:2\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" "AVDJ;JPEG;;Avid\n" "AVdv;DV;;Avid;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n" "AVd1;DV;;Avid;http://www.apple.com/quicktime/download/standalone.html;;\n" "AVdn;VC-3;DNxHD;Avid;http://www.apple.com/quicktime/download/standalone.html;;;\n" "AVmp;MPEG Video;Avid IMX;;;;Version 2;;\n" "avr ;JPEG;;;;;;\n" "AVrp;RGB;Avid;;;;;RGB\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" "CHQX;Canopus HQX;;;;;;\n" "CLLC;Canopus Lossless;;;;;;\n" "CUVC;Canopus HQ;;;;;;\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" "FFV1;FFV1;;;;;;\n" "gif ;M-GIF;;;;;;\n" "Hap1;Hap;;Hap Video Codec;https://github.com/Vidvox/hap;;;\n" "Hap5;Hap Alpha;;Hap Video Codec;https://github.com/Vidvox/hap;;;\n" "HapY;Hap Q;;Hap Video Codec;https://github.com/Vidvox/hap;;;\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" "hvc1;HEVC;;High Efficiency Video Coding;http://www.itu.int/;;;\n" "hev1;HEVC;;High Efficiency Video Coding;http://www.itu.int/;;;\n" "icod;AIC;;Apple Intermediate Codec;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:0\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" "r210;RGB;Blackmagic Design;;;;;RGB\n" "R210;RGB;Blackmagic Design;;;;;RGB\n" "raw ;RGB;;;http://www.apple.com/quicktime/download/standalone.html;;;RGB\n" "rle ;RLE;;;http://www.apple.com/quicktime/download/standalone.html;;;RGB\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" "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" "0x01000000;RLE;;Run length encoded 8bpp RGB image;http://www.fourcc.org/indexrgb.htm;;;;\n" "0x02000010;MPEG Video;;;;;;YUV;4:2:0\n" "0x02000000;RLE;;Run length encoded 4bpp RGB image;http://www.fourcc.org/indexrgb.htm;;;;\n" "0x03000000;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" "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;;;;4:4:4\n" "ap4h;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;;;;4:4:4\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" "CHQX;Canopus HQX;;;;;;\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 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;;;;;;\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;HuffYUV;;;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;HuffYUV;;;;;;\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" "U5.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)_Original/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 MediaInfoLib/Source/MediaInfo/Multiple/0000775000000000000000000000000012652076434016737 5ustar rootrootMediaInfoLib/Source/MediaInfo/Multiple/File_Skm.cpp0000664000000000000000000001421012652076434021132 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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+4Buffer_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 MediaInfoLib/Source/MediaInfo/Multiple/File_HdsF4m.h0000664000000000000000000000317312652076434021140 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about HDS (.f4m) files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_HdsF4mH #define MediaInfo_File_HdsF4mH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; //*************************************************************************** // Class File_HdsF4m //*************************************************************************** class File_HdsF4m : public File__Analyze { public : //Constructor/Destructor File_HdsF4m(); ~File_HdsF4m(); 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(); //Helpers void Representation(); //Temp File__ReferenceFilesHelper* ReferenceFiles; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Ogg.h0000664000000000000000000000502712652076434020567 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Ogg files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_OggH #define MediaInfo_File_OggH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 Stream; std::vector Chunk_Sizes; bool Chunk_Sizes_Finished; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Flv.h0000664000000000000000000000577212652076434020611 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Flash files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_FlvH #define MediaInfo_File_FlvH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 bool FileHeader_Begin(); void FileHeader_Parse(); //Buffer - Synchro bool Synchronize(); bool Synched_Test(); //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 video_HEVC(); 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 Durations; stream() { Parser=NULL; PacketCount=0; Delay=(int32u)-1; TimeStamp=(int32u)-1; } ~stream() { delete Parser; //Parser=NULL; } }; std::vector Stream; //Null, Video, Audio //Count bool video_stream_Count; bool audio_stream_Count; //Temp bool video_stream_FrameRate_Detected; std::vector video_stream_FrameRate; int32u Time; int8u meta_Level; std::map meta_LevelFinished; bool Searching_Duration; bool MetaData_NotTrustable; int32u PreviousTagSize; int32u PreviousTagSize_Add11; int64u meta_filesize; float64 meta_duration; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Ancillary.h0000664000000000000000000000627512652076434021777 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Ancillary data (SMPTE ST291) // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_AncillaryH #define MediaInfo_AncillaryH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Ancillary //*************************************************************************** class File_Ancillary : public File__Analyze { public : //In bool WithTenBit; bool WithChecksum; bool HasBFrames; bool InDecodingOrder; bool LineNumber_IsSecondField; float64 AspectRatio; float64 FrameRate; int32u LineNumber; //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 Cdp_Data; File__Analyze* Cdp_Parser; #endif //defined(MEDIAINFO_CDP_YES) #if defined(MEDIAINFO_AFDBARDATA_YES) std::vector AfdBarData_Data; #endif //defined(MEDIAINFO_AFDBARDATA_YES) #if defined(MEDIAINFO_ARIBSTDB24B37_YES) File__Analyze* AribStdB34B37_Parser; #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) #if defined(MEDIAINFO_SDP_YES) File__Analyze* Sdp_Parser; #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) #if defined(MEDIAINFO_MXF_YES) File__Analyze* Rdd18_Parser; #endif //defined(MEDIAINFO_MXF_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(); //Unknown content struct streaminfo { stream_t StreamKind; std::map Infos; streaminfo() : StreamKind(Stream_Other) {} }; typedef std::map perid; std::vector > Unknown; bool TestAndPrepare(const string* Unique=NULL); //Temp int8u DataID; int8u SecondaryDataID; int8u DataCount; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper_Common.h0000664000000000000000000000514212652076434025541 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__ReferenceFilesHelper_CommonH #define File__ReferenceFilesHelper_CommonH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; class File__Analyze; class MediaInfo_Config_MediaInfo; //*************************************************************************** // Class resource //*************************************************************************** class rfh_common { public: #if MEDIAINFO_DEMUX rfh_common(bool* Demux_Interleave_p, int64u* DTS_Minimal): #else //MEDIAINFO_DEMUX rfh_common(): #endif //MEDIAINFO_DEMUX MI(NULL), Config(NULL), FileSize((int64u)-1), HasMultipleSequences(false), HasMainFile(false), HasMainFile_Filled(false), ContainerHasNoId(false) #if MEDIAINFO_DEMUX , Demux_Interleave(Demux_Interleave_p), DTS_Minimal(DTS_Minimal) #endif //MEDIAINFO_DEMUX { } //Data File__ReferenceFilesHelper* ReferenceFilesHelper; File__Analyze* MI; MediaInfo_Config_MediaInfo* Config; int64u FileSize; bool HasMultipleSequences; bool HasMainFile; bool HasMainFile_Filled; bool ContainerHasNoId; #if MEDIAINFO_DEMUX const bool Demux_Interleave_Get() {return *Demux_Interleave;} void Demux_Interleave_Set(bool Demux_Interleave_n) {*Demux_Interleave=Demux_Interleave_n;} const int64u DTS_Minimal_Get() {return *DTS_Minimal;} void DTS_Minimal_Set(size_t DTS_Minimal_n) {*DTS_Minimal=DTS_Minimal_n;} #endif //MEDIAINFO_DEMUX private: #if MEDIAINFO_DEMUX bool* Demux_Interleave; int64u* DTS_Minimal; #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Mxf.h0000664000000000000000000015421512652076434020611 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Mxf files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_MxfH #define MediaInfo_File_MxfH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #if defined(MEDIAINFO_ANCILLARY_YES) #include #endif //defined(MEDIAINFO_ANCILLARY_YES) #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/TimeCode.h" #include #include #include using namespace std; //--------------------------------------------------------------------------- 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_Accept(); void Streams_Fill (); void Streams_Finish (); void Streams_Finish_Preface (const int128u PrefaceUID); void Streams_Finish_Preface_ForTimeCode (const int128u PrefaceUID); void Streams_Finish_ContentStorage (const int128u ContentStorageUID); void Streams_Finish_ContentStorage_ForTimeCode (const int128u ContentStorageUID); void Streams_Finish_ContentStorage_ForAS11 (const int128u ContentStorageUID); void Streams_Finish_Package (const int128u PackageUID); void Streams_Finish_Package_ForTimeCode (const int128u PackageUID); void Streams_Finish_Package_ForAS11 (const int128u PackageUID); void Streams_Finish_Track (const int128u TrackUID); void Streams_Finish_Track_ForTimeCode (const int128u TrackUID, bool IsSourcePackage); void Streams_Finish_Track_ForAS11 (const int128u TrackUID); void Streams_Finish_Essence (int32u EssenceUID, int128u TrackUID); void Streams_Finish_Essence_FillID (int32u EssenceUID, int128u TrackUID); void Streams_Finish_Descriptor (const int128u DescriptorUID, const int128u PackageUID); void Streams_Finish_Locator (const int128u DescriptorUID, const int128u LocatorUID); void Streams_Finish_Component (const int128u ComponentUID, float64 EditRate, int32u TrackID, int64u Origin); void Streams_Finish_Component_ForTimeCode (const int128u ComponentUID, float64 EditRate, int32u TrackID, int64u Origin, bool IsSourcePackage); void Streams_Finish_Component_ForAS11 (const int128u ComponentUID, float64 EditRate, int32u TrackID, int64u Origin); void Streams_Finish_Identification (const 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 MCAChannelID(); void MCALabelDictionaryID(); void MCATagSymbol(); void MCATagName(); void GroupOfSoundfieldGroupsLinkID(); void MCALinkID(); void SoundfieldGroupLinkID(); void MCAPartitionKind(); void MCAPartitionNumber(); void MCATitle(); void MCATitleVersion(); void MCATitleSubVersion(); void MCAEpisode(); void MCAAudioContentKind(); void MCAAudioElementKind(); void ResourceID(); void NamespaceURI(); void UCSEncoding(); void Filler(); void Filler01() {Filler();} void Filler02() {Filler();} void TerminatingFiller(); void XmlDocumentText(); void SubDescriptors(); void LensUnitMetadata(); void CameraUnitMetadata(); void UserDefinedAcquisitionMetadata(); void DMFiller(); void Sequence(); void SourceClip(); void TimecodeComponent(); void ContentStorage(); void EssenceContainerData(); void CDCIEssenceDescriptor(); void RGBAEssenceDescriptor(); void Preface(); void Identification(); void NetworkLocator(); void TextLocator(); void StereoscopicPictureSubDescriptor(); void MaterialPackage(); void SourcePackage(); void EventTrack(); void StaticTrack(); void TimelineTrack(); void DMSegment(); void GenericSoundEssenceDescriptor(); void GenericDataEssenceDescriptor(); void MultipleDescriptor(); void DMSourceClip(); void AES3PCMDescriptor(); void WaveAudioDescriptor(); void MPEG2VideoDescriptor(); void JPEG2000PictureSubDescriptor(); void VbiPacketsDescriptor(); void AncPacketsDescriptor(); void MpegAudioDescriptor(); void PackageMarkerObject(); void ApplicationPlugInObject(); void ApplicationReferencedObject(); void MCALabelSubDescriptor(); void TimedTextDescriptor(); void TimedTextResourceSubDescriptor(); void Unknown67SubDescriptor(); void Mpeg4VisualSubDescriptor(); void AudioChannelLabelSubDescriptor(); void SoundfieldGroupLabelSubDescriptor(); void GroupOfSoundfieldGroupsLabelSubDescriptor(); 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 DMScheme1(); void AS11_AAF_Core(); void AS11_AAF_Segmentation(); void AS11_AAF_UKDPP(); 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_Duration(); //0202 (copy of StructuralComponent_Duration) //TODO: merge with StructuralComponent_Duration void DMSegment_DMFramework(); //6101 void DMSegment_TrackIDs(); //6102 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_TransferCharacteristic(); //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 GenericPictureEssenceDescriptor_ColorPrimaries(); //3219 void GenericPictureEssenceDescriptor_CodingEquations(); //321A 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 GenericDataEssenceDescriptor_DataEssenceCoding(); //3E01 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 JPEG2000PictureSubDescriptor_CodingStyleDefault(); // void JPEG2000PictureSubDescriptor_QuantizationDefault(); // void MpegAudioDescriptor_BitRate(); // void MultipleDescriptor_SubDescriptorUIDs(); //3F01 void PrimaryExtendedSpokenLanguage(); // void SecondaryExtendedSpokenLanguage(); // void OriginalExtendedSpokenLanguage(); // void SecondaryOriginalExtendedSpokenLanguage(); // void RFC5646AudioLanguageCode(); // 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 Mpeg4VisualDescriptor_SingleSequence() {MPEG2VideoDescriptor_SingleSequence();} void Mpeg4VisualDescriptor_ConstantBFrames() {MPEG2VideoDescriptor_ConstantBFrames();} void Mpeg4VisualDescriptor_CodedContentType() {MPEG2VideoDescriptor_CodedContentType();} void Mpeg4VisualDescriptor_LowDelay() {MPEG2VideoDescriptor_LowDelay();} void Mpeg4VisualDescriptor_ClosedGOP() {MPEG2VideoDescriptor_ClosedGOP();} void Mpeg4VisualDescriptor_IdenticalGOP() {MPEG2VideoDescriptor_IdenticalGOP();} void Mpeg4VisualDescriptor_MaxGOP() {MPEG2VideoDescriptor_MaxGOP();} void Mpeg4VisualDescriptor_BPictureCount() {MPEG2VideoDescriptor_BPictureCount();} void Mpeg4VisualDescriptor_ProfileAndLevel(); // void Mpeg4VisualDescriptor_BitRate() {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_FrameCount(); //0101 void SystemScheme1_TimeCodeArray(); //0102 void SystemScheme1_ClipIDArray(); //0103 void SystemScheme1_ExtendedClipIDArray(); //0104 void SystemScheme1_VideoIndexArray(); //0105 void SystemScheme1_KLVMetadataSequence(); //0106 void SystemScheme1_SampleRate(); //3001 void SystemScheme1_EssenceTrackNumber(); //4804 void SystemScheme1_EssenceTrackNumberBatch(); //6801 void SystemScheme1_ContentPackageIndexArray(); //6803 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 LensUnitMetadata_IrisFNumber(); //8000 void LensUnitMetadata_FocusPositionFromImagePlane(); //8001 void LensUnitMetadata_FocusPositionFromFrontLensVertex(); //8002 void LensUnitMetadata_MacroSetting(); //8003 void LensUnitMetadata_LensZoom35mmStillCameraEquivalent(); //8004 void LensUnitMetadata_LensZoomActualFocalLength(); //8005 void LensUnitMetadata_OpticalExtenderMagnification(); //8006 void LensUnitMetadata_LensAttributes(); //8007 void CameraUnitMetadata_CaptureGammaEquation(); //3210 void CameraUnitMetadata_AutoExposureMode(); //8100 void CameraUnitMetadata_AutoFocusSensingAreaSetting(); //8101 void CameraUnitMetadata_ColorCorrectionFilterWheelSetting();//8102 void CameraUnitMetadata_NeutralDensityFilterWheelSetting(); //8103 void CameraUnitMetadata_ImageSensorDimensionEffectiveWidth();//8104 void CameraUnitMetadata_ImageSensorDimensionEffectiveHeight();//8105 void CameraUnitMetadata_CaptureFrameRate(); //8106 void CameraUnitMetadata_ImageSensorReadoutMode(); //8107 void CameraUnitMetadata_ShutterSpeed_Angle(); //8108 void CameraUnitMetadata_ShutterSpeed_Time(); //8109 void CameraUnitMetadata_CameraMasterGainAdjustment(); //810A void CameraUnitMetadata_ISOSensitivity(); //810B void CameraUnitMetadata_ElectricalExtenderMagnification(); //810C void CameraUnitMetadata_AutoWhiteBalanceMode(); //810D void CameraUnitMetadata_WhiteBalance(); //800E void CameraUnitMetadata_CameraMasterBlackLevel(); //810F void CameraUnitMetadata_CameraKneePoint(); //8110 void CameraUnitMetadata_CameraKneeSlope(); //8111 void CameraUnitMetadata_CameraLuminanceDynamicRange(); //8112 void CameraUnitMetadata_CameraSettingFileURI(); //8113 void CameraUnitMetadata_CameraAttributes(); //8114 void CameraUnitMetadata_ExposureIndexofPhotoMeter(); //8115 void CameraUnitMetadata_GammaForCDL(); //8116 void CameraUnitMetadata_ASC_CDL_V12(); //8117 void UserDefinedAcquisitionMetadata_UdamSetIdentifier(); //E000 void UserDefinedAcquisitionMetadata_Sony_8007(); void UserDefinedAcquisitionMetadata_Sony_E101(); void UserDefinedAcquisitionMetadata_Sony_E102(); void UserDefinedAcquisitionMetadata_Sony_E103(); void UserDefinedAcquisitionMetadata_Sony_E104(); void UserDefinedAcquisitionMetadata_Sony_E105(); void UserDefinedAcquisitionMetadata_Sony_E106(); void UserDefinedAcquisitionMetadata_Sony_E107(); void UserDefinedAcquisitionMetadata_Sony_E109(); void UserDefinedAcquisitionMetadata_Sony_E10B(); void UserDefinedAcquisitionMetadata_Sony_E201(); void UserDefinedAcquisitionMetadata_Sony_E202(); void UserDefinedAcquisitionMetadata_Sony_E203(); void AS11_Core_SeriesTitle(); void AS11_Core_ProgrammeTitle(); void AS11_Core_EpisodeTitleNumber(); void AS11_Core_ShimName(); void AS11_Core_AudioTrackLayout(); void AS11_Core_PrimaryAudioLanguage(); void AS11_Core_ClosedCaptionsPresent(); void AS11_Core_ClosedCaptionsType(); void AS11_Core_ClosedCaptionsLanguage(); void AS11_Core_ShimVersion(); void AS11_Segment_PartNumber(); void AS11_Segment_PartTotal(); void AS11_UKDPP_ProductionNumber(); void AS11_UKDPP_Synopsis(); void AS11_UKDPP_Originator(); void AS11_UKDPP_CopyrightYear(); void AS11_UKDPP_OtherIdentifier(); void AS11_UKDPP_OtherIdentifierType(); void AS11_UKDPP_Genre(); void AS11_UKDPP_Distributor(); void AS11_UKDPP_PictureRatio(); void AS11_UKDPP_3D(); void AS11_UKDPP_3DType(); void AS11_UKDPP_ProductPlacement(); void AS11_UKDPP_FpaPass(); void AS11_UKDPP_FpaManufacturer(); void AS11_UKDPP_FpaVersion(); void AS11_UKDPP_VideoComments(); void AS11_UKDPP_SecondaryAudioLanguage(); void AS11_UKDPP_TertiaryAudioLanguage(); void AS11_UKDPP_AudioLoudnessStandard(); void AS11_UKDPP_AudioComments(); void AS11_UKDPP_LineUpStart(); void AS11_UKDPP_IdentClockStart(); void AS11_UKDPP_TotalNumberOfParts(); void AS11_UKDPP_TotalProgrammeDuration(); void AS11_UKDPP_AudioDescriptionPresent(); void AS11_UKDPP_AudioDescriptionType(); void AS11_UKDPP_OpenCaptionsPresent(); void AS11_UKDPP_OpenCaptionsType(); void AS11_UKDPP_OpenCaptionsLanguage(); void AS11_UKDPP_SigningPresent(); void AS11_UKDPP_SignLanguage(); void AS11_UKDPP_CompletionDate(); void AS11_UKDPP_TextlessElementsExist(); void AS11_UKDPP_ProgrammeHasText(); void AS11_UKDPP_ProgrammeTextLanguage(); void AS11_UKDPP_ContactEmail(); void AS11_UKDPP_ContactTelephoneNumber(); 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 //TimeCode struct mxftimecode { int16u RoundedTimecodeBase; int64u StartTimecode; bool DropFrame; mxftimecode() : RoundedTimecodeBase(0) , StartTimecode((int64u)-1) , DropFrame(false) { } mxftimecode(int16u RoundedTimecodeBase_, int64u StartTimecode_, bool DropFrame_) : RoundedTimecodeBase(RoundedTimecodeBase_) , StartTimecode(StartTimecode_) , DropFrame(DropFrame_) { } }; // Temp struct randomindexmetadata { int64u ByteOffset; int32u BodySID; }; std::vector RandomIndexMetadatas; bool RandomIndexMetadatas_AlreadyParsed; std::set PartitionPack_AlreadyParsed; size_t Streams_Count; int128u Code; int128u OperationalPattern; int128u InstanceUID; int64u Buffer_Begin; int64u Buffer_End; bool Buffer_End_Unlimited; 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 IsSearchingFooterPartitionAddress; bool FooterPartitionAddress_Jumped; bool PartitionPack_Parsed; size_t IdIsAlwaysSame_Offset; //Primer std::map Primer_Values; //Preface struct preface { int128u PrimaryPackage; std::vector Identifications; int128u ContentStorage; preface() { PrimaryPackage.hi=(int64u)-1; PrimaryPackage.lo=(int64u)-1; ContentStorage.hi=(int64u)-1; ContentStorage.lo=(int64u)-1; } }; typedef std::map prefaces; //Key is InstanceUID of preface prefaces Prefaces; int128u Preface_Current; //Identification struct identification { Ztring CompanyName; Ztring ProductName; Ztring ProductVersion; Ztring VersionString; Ztring ToolkitVersion; Ztring Platform; std::map Infos; }; typedef std::map identifications; //Key is InstanceUID of identification identifications Identifications; //ContentStorage struct contentstorage { std::vector Packages; }; typedef std::map contentstorages; //Key is InstanceUID of ContentStorage contentstorages ContentStorages; //Package struct package { int256u PackageUID; int128u Descriptor; std::vector Tracks; bool IsSourcePackage; package() { Descriptor=0; IsSourcePackage=false; } }; typedef std::map packages; //Key is InstanceUID of package packages Packages; //Track struct track { int128u Sequence; int32u TrackID; Ztring TrackName; int32u TrackNumber; float64 EditRate_Real; //Before demux adaptation float64 EditRate; int64u Origin; bool Stream_Finish_Done; track() { Sequence=0; TrackID=(int32u)-1; TrackNumber=(int32u)-1; EditRate_Real=(float64)0; EditRate=(float64)0; Origin=0; Stream_Finish_Done=false; } }; typedef std::map tracks; //Key is InstanceUID of the track tracks Tracks; //Essence typedef std::vector parsers; struct essence { stream_t StreamKind; size_t StreamPos; size_t StreamPos_Initial; parsers Parsers; std::map 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 Field_Count_InThisBlock_1; int64u Field_Count_InThisBlock_2; int64u Frame_Count_NotParsedIncluded; frame_info FrameInfo; essence() { StreamKind=Stream_Max; StreamPos=(size_t)-1; StreamPos_Initial=(size_t)-1; Stream_Size=(int64u)-1; TrackID=(int32u)-1; TrackID_WasLookedFor=false; Stream_Finish_Done=false; Track_Number_IsMappedToTrack=false; IsFilled=false; IsChannelGrouping=false; Field_Count_InThisBlock_1=0; Field_Count_InThisBlock_2=0; Frame_Count_NotParsedIncluded=(int64u)-1; FrameInfo.DTS=(int64u)-1; } ~essence() { for (size_t Pos=0; Pos essences; //Key is TrackNumber essences Essences; bitset StreamPos_StartAtZero; //information about the base of StreamPos (0 or 1, 1 is found in 1 file) TODO: per Essence code (last 4 bytes of the Essence header 0xTTXXTTXX) //Descriptor struct descriptor { std::vector SubDescriptors; std::vector Locators; Ztring ScanType; 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; int128u ChannelAssignment; std::map Infos; int16u BlockAlign; int32u QuantizationBits; int64u Duration; int8u ActiveFormat; int8u FieldTopness; int8u FieldDominance; enum type { Type_Unknown, type_Mutiple, Type_CDCI, Type_RGBA, Type_MPEG2Video, Type_WaveAudio, Type_AES3PCM, Type_JPEG2000Picture, Type_AncPackets, Type_MCALabelSubDescriptor, Type_AudioChannelLabelSubDescriptor, Type_SoundfieldGroupLabelSubDescriptor, Type_GroupOfSoundfieldGroupsLabelSubDescriptor, }; type Type; bool HasBFrames; bool HasMPEG2VideoDescriptor; bool IsAes3Descriptor; int32u ByteRate; //MCALabelSubDescriptor specific (including SoundfieldGroupLabelSubDescriptor...) int128u MCALabelDictionaryID; int128u MCALinkID; Ztring MCATagSymbol; Ztring MCATagName; Ztring MCAPartitionKind; Ztring MCAPartitionNumber; Ztring MCATitle; Ztring MCATitleVersion; Ztring MCATitleSubVersion; Ztring MCAEpisode; Ztring MCAAudioContentKind; Ztring MCAAudioElementKind; //AudioChannelLabelSubDescriptor specific int128u SoundfieldGroupLinkID; 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; ChannelAssignment.hi=(int64u)-1; ChannelAssignment.lo=(int64u)-1; BlockAlign=(int16u)-1; QuantizationBits=(int32u)-1; Duration=(int64u)-1; ActiveFormat=(int8u)-1; FieldTopness=(int8u)-1; //Field x is upper field FieldDominance=1; //Default is field 1 temporaly first Type=Type_Unknown; HasBFrames=false; HasMPEG2VideoDescriptor=false; IsAes3Descriptor=false; ByteRate=(int32u)-1; //MCALabelSubDescriptor specific (including SoundfieldGroupLabelSubDescriptor...) MCALabelDictionaryID.hi=(int64u)-1; MCALabelDictionaryID.lo=(int64u)-1; MCALinkID.hi=(int64u)-1; MCALinkID.lo=(int64u)-1; //AudioChannelLabelSubDescriptor specific SoundfieldGroupLinkID.hi=(int64u)-1; SoundfieldGroupLinkID.lo=(int64u)-1; } }; typedef std::map descriptors; //Key is InstanceUID of Descriptor descriptors Descriptors; //Locator struct locator { Ztring EssenceLocator; stream_t StreamKind; size_t StreamPos; int32u LinkedTrackID; bool IsTextLocator; locator() { StreamKind=Stream_Max; StreamPos=(size_t)-1; LinkedTrackID=(int32u)-1; IsTextLocator=false; } ~locator() { } }; typedef std::map 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 StructuralComponents; //Sequence from MaterialPackage only mxftimecode MxfTimeCode; 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; if (New.MxfTimeCode.StartTimecode!=(int64u)-1) MxfTimeCode.StartTimecode=New.MxfTimeCode.StartTimecode; if (New.MxfTimeCode.RoundedTimecodeBase) { MxfTimeCode.RoundedTimecodeBase=New.MxfTimeCode.RoundedTimecodeBase; MxfTimeCode.DropFrame=New.MxfTimeCode.DropFrame; } } }; typedef std::map components; //Key is InstanceUID of the component components Components; //Descriptive Metadata - DMSegments struct dmsegment { int128u Framework; std::vector TrackIDs; int64u Duration; bool IsAs11SegmentFiller; dmsegment() { Framework.lo=(int64u)-1; Framework.hi=(int64u)-1; Duration=(int64u)-1; IsAs11SegmentFiller=false; } ~dmsegment() { } }; typedef std::map dmsegments; //Key is InstanceUID of the DMSegment dmsegments DMSegments; //Descriptive Metadata - DMScheme1 struct dmscheme1 { Ztring PrimaryExtendedSpokenLanguage; dmscheme1() { } ~dmscheme1() { } }; typedef std::map dmscheme1s; //Key is InstanceUID of the DMScheme1 dmscheme1s DMScheme1s; //Descriptive Metadata - AS11 struct as11 { enum as11_type { Type_Unknown, Type_Core, Type_Segmentation, Type_UKDPP, }; as11_type Type; Ztring SeriesTitle; Ztring ProgrammeTitle; Ztring EpisodeTitleNumber; Ztring ShimName; int8u AudioTrackLayout; Ztring PrimaryAudioLanguage; int8u ClosedCaptionsPresent; int8u ClosedCaptionsType; Ztring ClosedCaptionsLanguage; int8u ShimVersion_Major; int8u ShimVersion_Minor; int16u PartNumber; int16u PartTotal; Ztring ProductionNumber; Ztring Synopsis; Ztring Originator; int16u CopyrightYear; Ztring OtherIdentifier; Ztring OtherIdentifierType; Ztring Genre; Ztring Distributor; int32u PictureRatio_N; int32u PictureRatio_D; int8u ThreeD; int8u ThreeDType; int8u ProductPlacement; int8u FpaPass; Ztring FpaManufacturer; Ztring FpaVersion; Ztring VideoComments; Ztring SecondaryAudioLanguage; Ztring TertiaryAudioLanguage; int8u AudioLoudnessStandard; Ztring AudioComments; int64u LineUpStart; int64u IdentClockStart; int16u TotalNumberOfParts; int64u TotalProgrammeDuration; int8u AudioDescriptionPresent; int8u AudioDescriptionType; int8u OpenCaptionsPresent; int8u OpenCaptionsType; Ztring OpenCaptionsLanguage; int8u SigningPresent; int8u SignLanguage; int64u CompletionDate; int8u TextlessElementsExist; int8u ProgrammeHasText; Ztring ProgrammeTextLanguage; Ztring ContactEmail; Ztring ContactTelephoneNumber; as11() { Type=Type_Unknown; AudioTrackLayout=(int8u)-1; ClosedCaptionsPresent=(int8u)-1; ClosedCaptionsType=(int8u)-1; ShimVersion_Major=(int8u)-1; ShimVersion_Minor=(int8u)-1; PartNumber=(int16u)-1; PartTotal=(int16u)-1; CopyrightYear=(int16u)-1; PictureRatio_N=(int32u)-1; PictureRatio_D=(int32u)-1; ThreeD=(int8u)-1; ThreeDType=(int8u)-1; ProductPlacement=(int8u)-1; AudioLoudnessStandard=(int8u)-1; LineUpStart=(int64u)-1; IdentClockStart=(int64u)-1; TotalNumberOfParts=(int16u)-1; TotalProgrammeDuration=(int64u)-1; AudioDescriptionPresent=(int8u)-1; AudioDescriptionType=(int8u)-1; OpenCaptionsPresent=(int8u)-1; OpenCaptionsType=(int8u)-1; SigningPresent=(int8u)-1; SignLanguage=(int8u)-1; CompletionDate=(int64u)-1; TextlessElementsExist=(int8u)-1; ProgrammeHasText=(int8u)-1; } ~as11() { } }; typedef std::map as11s; //Key is InstanceUID of the DMScheme1 as11s AS11s; //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); void ChooseParser__Sony(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser__Sony_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser__FromEssenceContainer(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Avc(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_DV(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Mpeg4v(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Mpegv(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Raw(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_RV24(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Vc3(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_TimedText(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Aac(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Ac3(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Alaw(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_ChannelGrouping(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Mpega(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Pcm(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_SmpteSt0331(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_SmpteSt0337(const essences::iterator &Essence, const descriptors::iterator &Descriptor); void ChooseParser_Jpeg2000(const essences::iterator &Essence, const descriptors::iterator &Descriptor); //Helpers void Subsampling_Compute(descriptors::iterator Descriptor); #if defined(MEDIAINFO_REFERENCES_YES) void Locators_CleanUp(); void Locators_Test(); #else //defined(MEDIAINFO_REFERENCES_YES) inline void Locators_CleanUp() {} inline void Locators_Test() {} #endif //defined(MEDIAINFO_REFERENCES_YES) void NextRandomIndexMetadata(); void TryToFinish(); //Temp int128u EssenceContainer_FromPartitionMetadata; int64u PartitionMetadata_PreviousPartition; int64u PartitionMetadata_FooterPartition; int64u RandomIndexMetadatas_MaxOffset; mxftimecode MxfTimeCodeForDelay; mxftimecode MxfTimeCodeMaterial; float64 DTS_Delay; //In seconds TimeCode SDTI_TimeCode_StartTimecode; size_t SDTI_TimeCode_RepetitionCount; TimeCode SDTI_TimeCode_Previous; 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 string SystemScheme1_TimeCodeArray_StartTimecode; int64u SystemScheme1_TimeCodeArray_StartTimecode_ms; int64u SystemScheme1_FrameRateFromDescriptor; bool Essences_FirstEssence_Parsed; bool MayHaveCaptionsInStream; bool StereoscopicPictureSubDescriptor_IsPresent; bool UserDefinedAcquisitionMetadata_UdamSetIdentifier_IsSony; int32u Essences_UsedForFrameCount; int32u IndexTable_NSL; int32u IndexTable_NPE; struct systemscheme { bool IsTimeCode; systemscheme() { IsTimeCode=false; } }; typedef std::map systemschemes; systemschemes SystemSchemes; #if MEDIAINFO_ADVANCED int64u Footer_Position; #endif //MEDIAINFO_ADVANCED #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 partitions; partitions Partitions; size_t Partitions_Pos; bool Partitions_IsCalculatingHeaderByteCount; bool Partitions_IsCalculatingSdtiByteCount; bool Partitions_IsFooter; //Config bool TimeCodeFromMaterialPackage; //CameraUnitMetadata struct acquisitionmetadata { string Value; size_t FrameCount; acquisitionmetadata(const string &Value_) : Value(Value_) , FrameCount(1) {} }; typedef std::vector acquisitionmetadatalist; vector AcquisitionMetadataLists; void AcquisitionMetadata_Add(size_t Id, string Value) { if (!AcquisitionMetadataLists[Id]) { AcquisitionMetadataLists[Id]=new acquisitionmetadatalist; AcquisitionMetadataLists[Id]->push_back(acquisitionmetadata(Value)); return; } if ((*AcquisitionMetadataLists[Id])[AcquisitionMetadataLists[Id]->size()-1].Value == Value) { (*AcquisitionMetadataLists[Id])[AcquisitionMetadataLists[Id]->size()-1].FrameCount++; return; } AcquisitionMetadataLists[Id]->push_back(acquisitionmetadata(Value)); } vector AcquisitionMetadata_Sony_E201_Lists; void AcquisitionMetadata_Sony_E201_Add(size_t Id, string Value) { if (!AcquisitionMetadata_Sony_E201_Lists[Id]) { AcquisitionMetadata_Sony_E201_Lists[Id]=new acquisitionmetadatalist; AcquisitionMetadata_Sony_E201_Lists[Id]->push_back(acquisitionmetadata(Value)); return; } if ((*AcquisitionMetadata_Sony_E201_Lists[Id])[AcquisitionMetadata_Sony_E201_Lists[Id]->size()-1].Value == Value) { (*AcquisitionMetadata_Sony_E201_Lists[Id])[AcquisitionMetadata_Sony_E201_Lists[Id]->size()-1].FrameCount++; return; } AcquisitionMetadata_Sony_E201_Lists[Id]->push_back(acquisitionmetadata(Value)); } int8u AcquisitionMetadata_Sony_CalibrationType; //Demux #if MEDIAINFO_DEMUX bool Demux_HeaderParsed; essences::iterator Demux_CurrentEssence; #endif //MEDIAINFO_DEMUX #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK 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 Entries; indextable() { StreamOffset=(int64u)-1; IndexStartPosition=0; IndexDuration=0; EditUnitByteCount=0; IndexEditRate=0; } bool operator < (const indextable& lhs) const { return IndexStartPosition 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; bool DetectDuration(); int64u DemuxedSampleCount_Total; int64u DemuxedSampleCount_Current; int64u DemuxedSampleCount_AddedToFirstFrame; int64u DemuxedElementSize_AddedToFirstFrame; #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Riff.cpp0000664000000000000000000013105412652076434021274 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include 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 #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; #if MEDIAINFO_DEMUX Demux_Parser=NULL; #endif //MEDIAINFO_DEMUX //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 defined(MEDIAINFO_ANCILLARY_YES) if (Ancillary && (*Ancillary)) { Clear(); Stream_Prepare(Stream_General); Finish(*Ancillary); Merge(**Ancillary); Ztring LawRating=(*Ancillary)->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=(*Ancillary)->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); return; } #endif //defined(MEDIAINFO_ANCILLARY_YES) //Global if (IsRIFF64) Fill(Stream_General, 0, General_Format_Profile, "RF64"); //Time codes TimeCode_Fill(__T("ISMP"), INFO_ISMP); TimeCode_Fill(__T("Adobe tc_A"), Tdat_tc_A); TimeCode_Fill(__T("Adobe tc_O"), Tdat_tc_O); //For each stream std::map::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); //When there are few frames, difficult to detect PCM if (Temp->second.IsPcm && !Temp->second.Parsers.empty() && !Temp->second.Parsers[0]->Status[IsAccepted]) { for (size_t Pos=0; Possecond.Parsers.size()-1; Pos++) delete Temp->second.Parsers[Pos]; Temp->second.Parsers.erase(Temp->second.Parsers.begin(), Temp->second.Parsers.begin()+Temp->second.Parsers.size()-1); Temp->second.Parsers[0]->Accept(); } //PAR if (PAR && StreamKind_Last==Stream_Video) Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio, PAR); Ztring ID; if (Temp->first!=(int32u)-1) ID.From_Number(((Temp->first>>24)-'0')*10+(((Temp->first>>16)&0xFF)-'0')); //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]); if (!Temp->second.Parsers.empty() && Temp->second.Parsers[0]->Count_Get(StreamKind_Last)) { //Special case: Compressed audio hidden in PCM if (StreamKind_Last==Stream_Audio && Temp->second.Compression==1 && Retrieve(Stream_General, 0, General_Format)==__T("Wave") && Temp->second.Parsers[0]->Get(Stream_Audio, 0, Audio_Format)!=__T("PCM")) //Some DTS or SMPTE ST 337 streams are coded "1" Clear(Stream_Audio, 0, Audio_Channel_s_); size_t StreamPos_Base=StreamPos_Last; for (size_t Pos=0; Possecond.Parsers[0]->Count_Get(StreamKind_Last); Pos++) { Ztring Temp_ID=ID; Ztring Temp_ID_String=ID; Merge(*Temp->second.Parsers[0], StreamKind_Last, Pos, StreamPos_Base+Pos); if (!Retrieve(StreamKind_Last, StreamPos_Last, General_ID).empty()) { if (!Temp_ID.empty()) { Temp_ID+=__T('-'); Temp_ID_String+=__T('-'); } Temp_ID+=Retrieve(StreamKind_Last, StreamPos_Last, General_ID); Temp_ID_String+=Retrieve(StreamKind_Last, StreamPos_Last, General_ID); } Fill(StreamKind_Last, StreamPos_Last, General_ID, Temp_ID, true); Fill(StreamKind_Last, StreamPos_Last, General_StreamOrder, Temp_ID_String, true); //Special case - MPEG Video + Captions if (StreamKind_Last==Stream_Video && Temp->second.Parsers[0]->Count_Get(Stream_Text)) { //Video and Text are together size_t Parser_Text_Count=Temp->second.Parsers[0]->Count_Get(Stream_Text); for (size_t Parser_Text_Pos=0; Parser_Text_Possecond.Parsers[0]->Finish(); Merge(*Temp->second.Parsers[0], 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); 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); Fill(Stream_Text, StreamPos_Last, "MuxingMode_MoreInfo", __T("Muxed in Video #")+Ztring().From_Number(Count_Get(Stream_Video)), true); } StreamKind_Last=Stream_Video; StreamPos_Last=Count_Get(Stream_Video)-1; } } } else { Fill(StreamKind_Last, StreamPos_Last, General_ID, ID, true); Fill(StreamKind_Last, StreamPos_Last, General_StreamOrder, ID, true); } //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) { float32 FrameRateF=FrameRate.To_float32(); Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Minimum, FrameRateF/5, 3, true); Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Maximum, FrameRateF/4, 3, true); Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "VFR"); } } //Hack - SMPTE ST 337, RIFF channels count is wrong if (StreamKind_Last==Stream_Audio && Retrieve(Stream_Audio, StreamPos_Last, Audio_MuxingMode)==__T("SMPTE ST 337") && Temp->second.Parsers[0]->Get(Stream_Audio, 0, Audio_Channel_s_).empty()) Clear(Stream_Audio, StreamPos_Last, Audio_Channel_s_); //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; StreamPossecond.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_Possecond.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, ID); //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 = (int64u)Temp->second.PacketCount * 384; //MPEG-1 Layer 1 else if ((Version==__T("Version 2") || Version==__T("Version 2.5")) && Layer==__T("Layer 1")) SamplingCount = (int64u)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 = (int64u)Temp->second.PacketCount * 576; //MPEG-2 or 2.5 Layer 3 else SamplingCount = (int64u)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::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 && Temp->second.AvgBytesPerSec) { 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 (Temp->second.Scale!=1 && float64_int64s(Duration_Header/Duration_Source)==Temp->second.Scale) Fill(Stream_Audio, StreamPos_Last, Audio_Duration, Duration_Source, 0, true); //Found 1 stream with Scale not being right else 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; StreamPosInterleaved1_1) || (Interleaved1_1Interleaved0_1))?"Yes":"No"); //MD5 size_t Pos=0; for (size_t StreamKind=Stream_General+1; StreamKindDemux_Unpacketize_Get(); Demux_Rate=Config->Demux_Rate_Get(); if (Demux_UnpacketizeContainer && Demux_Rate==0) Demux_Rate=25; //Default value #endif //MEDIAINFO_DEMUX PAR=0; } //--------------------------------------------------------------------------- #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 (ValueBuffer_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() { for (std::map::iterator Stream_Item=Stream.begin(); Stream_Item!=Stream.end(); ++Stream_Item) for (size_t Pos=0; Possecond.Parsers.size(); Pos++) Stream_Item->second.Parsers[Pos]->Open_Buffer_Unsynch(); if (IsSub) { while(Element_Level) Element_End0(); #if defined(MEDIAINFO_ANCILLARY_YES) //Ancillary specific if (Ancillary && (*Ancillary)) (*Ancillary)->Open_Buffer_Unsynch(); #endif //defined(MEDIAINFO_ANCILLARY_YES) } } //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX void File_Riff::Read_Buffer_Continue() { if (Demux_Parser) { Open_Buffer_Continue(Demux_Parser, Buffer+Buffer_Offset, 0, false); Demux_Parser=NULL; //if (Config->Demux_EventWasSent) // return; } } #endif //MEDIAINFO_DEMUX //*************************************************************************** // Buffer //*************************************************************************** //--------------------------------------------------------------------------- bool File_Riff::Header_Begin() { while (File_Offset+Buffer_OffsetBuffer_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=Buffer_DataToParse_End-(File_Offset+Buffer_Offset); Buffer_DataToParse_End=0; } if (Buffer_Offset+(size_t)Element_Size>Buffer_Size) return false; // Fake header Element_Begin1("...Continued"); //TODO: better method Element_ThisIsAList(); Element_Begin1("...Continued"); Element_ThisIsAList(); if (Buffer_DataToParse_End) Header_Fill_Size(Buffer_DataToParse_End-(File_Offset+Buffer_Offset)); else Header_Fill_Size(Element_Size); Element_End(); 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>=256*1024) { File_GoTo=Buffer_DataToParse_End; Buffer_Offset=Buffer_Size; Element_Size=0; } else { Buffer_Offset+=(size_t)Element_Size; Element_Size-=Element_Offset; } Element_Offset=0; Element_End0(); if (Status[IsFinished] || (File_GoTo!=(int64u)-1 && (File_GoTo<=Buffer_DataToParse_Begin || File_GoTo>=Buffer_DataToParse_End))) { Buffer_DataToParse_Begin=(int64u)-1; Buffer_DataToParse_End=0; return false; } 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)"); } //Special case: we don't need the full data if (Name==Elements::WAVE_data) { Buffer_DataToParse_Begin=File_Offset+Buffer_Offset; if (Size_Complete) Buffer_DataToParse_End=File_Offset+Buffer_Offset+Size_Complete; else Buffer_DataToParse_End=File_Size; //Found one file with 0 as size of data part Size_Complete=Element_Offset; } //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_; //Tests 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 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; if (Size_Complete) Buffer_DataToParse_End=File_Offset+Buffer_Offset+8+Size_Complete; else Buffer_DataToParse_End=File_Size; //Found one file with 0 as size of data part Size_Complete=0; } //Filling Header_Fill_Code(Name, Ztring().From_CC4(Name)); Header_Fill_Size(Size_Complete+8); } //--------------------------------------------------------------------------- bool File_Riff::BookMark_Needed() { if (!movi_Size || SecondPass) return false; //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()) { #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong()) { GoTo(0); Hash_ParseUpTo=Stream_Structure_Temp->first; } else #endif //MEDIAINFO_HASH 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) { if (Value.empty()) return; for (size_t StreamPos=0; StreamPos moov_udta_meta_keys_List; size_t moov_udta_meta_keys_ilst_Pos; int32u moov_mvhd_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; int32u FrameCount_MaxPerStream; bool data_offset_present; 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; size_t StreamOrder; //Data struct stream { Ztring File_Name; std::vector Parsers; std::map Infos; MediaInfo_Internal* MI; struct timecode { int32u TimeScale; int32u FrameDuration; bool DropFrame; bool H24; bool NegativeTimes; }; timecode* TimeCode; stream_t StreamKind; size_t StreamPos; int32u hdlr_Type; int32u hdlr_SubType; int32u hdlr_Manufacturer; struct edts_struct { int64u Duration; int64u Delay; int32u Rate; }; std::vector edts; std::vector stco; struct stsc_struct { int32u FirstChunk; int32u SamplesPerChunk; }; std::vector stsc; std::vector stsz; std::vector stsz_Total; //TODO: merge with stsz int64u stsz_StreamSize; //TODO: merge with stsz std::vector stss; //Sync Sample, base=0 struct stts_struct { int32u SampleCount; int32u SampleDuration; }; std::vector 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 IsPcm; bool IsPcmMono; bool IsPriorityStream; bool IsFilled; bool IsChapter; bool IsEnabled; bool IsExcluded; bool HasForcedSamples; bool AllForcedSamples; std::vector CC; std::vector CCFor; std::vector FallBackTo; std::vector FallBackFrom; std::vector Subtitle; std::vector SubtitleFor; std::vector Forced; std::vector ForcedFor; std::vector Chapters; std::vector ChaptersFor; float32 CleanAperture_Width; float32 CleanAperture_Height; float32 CleanAperture_PixelAspectRatio; #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK int8u Demux_Level; int64u Demux_Offset; struct stts_duration { int64u Pos_Begin; int64u Pos_End; int64u DTS_Begin; int64u DTS_End; int32u SampleDuration; }; typedef std::vector stts_durations; stts_durations stts_Durations; size_t stts_Durations_Pos; int64u stts_FramePos; #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK #if MEDIAINFO_DEMUX bool PtsDtsAreSame; bool Demux_EventWasSent; #endif //MEDIAINFO_DEMUX stream() { MI=NULL; TimeCode=NULL; StreamKind=Stream_Max; StreamPos=0; hdlr_Type=0x00000000; hdlr_SubType=0x00000000; hdlr_Manufacturer=0x00000000; 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; stts_SampleDuration = 0; mvex_trex_default_sample_duration=0; mvex_trex_default_sample_size=0; TimeCode_TrackID=(int32u)-1; TimeCode_IsVisual=false; IsPcm=false; IsPcmMono=false; IsPriorityStream=false; IsFilled=false; IsChapter=false; IsExcluded=false; HasForcedSamples=false; AllForcedSamples=false; CleanAperture_Width=0; CleanAperture_Height=0; CleanAperture_PixelAspectRatio=0; #if MEDIAINFO_DEMUX Demux_Level=2; //Container Demux_Offset=0; stts_Durations_Pos=0; stts_FramePos=0; #endif //MEDIAINFO_DEMUX #if MEDIAINFO_DEMUX PtsDtsAreSame=false; Demux_EventWasSent=false; #endif //MEDIAINFO_DEMUX } ~stream() { for (size_t Pos=0; Pos streams; streams Streams; streams::iterator Stream; #if defined(MEDIAINFO_REFERENCES_YES) File__ReferenceFilesHelper* ReferenceFiles; #endif //defined(MEDIAINFO_REFERENCES_YES) #if MEDIAINFO_NEXTPACKET bool ReferenceFiles_IsParsing; #endif //MEDIAINFO_NEXTPACKET //Hints size_t* File_Buffer_Size_Hint_Pointer; //Positions struct mdat_Pos_Type { int64u Offset; int64u Size; int32u StreamID; int32u Reserved1; int64u Reserved2; }; typedef std::vector mdat_pos; static bool mdat_pos_sort (const File_Mpeg4::mdat_Pos_Type &i,const File_Mpeg4::mdat_Pos_Type &j) { return (i.Offset mdat_Pos_ToParseInPriority_StreamIDs; bool mdat_Pos_NormalParsing; #if MEDIAINFO_DEMUX int64u TimeCode_FrameOffset; int64u TimeCode_DtsOffset; std::map StreamOffset_Jump; //Key is the current position, value is the jump position #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Xdcam_Clip.h0000664000000000000000000000231012652076434022046 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Gxf.cpp0000664000000000000000000023247312652076434021141 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_PCM_YES) #include "MediaInfo/Audio/File_Pcm.h" #endif #if defined(MEDIAINFO_SMPTEST0337_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 ""; } } //--------------------------------------------------------------------------- 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 case 25 : return "DV"; //DVCPRO HD default : return ""; } } //--------------------------------------------------------------------------- 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; case 25 : return Stream_Video; 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 case 25 : return "DV"; //DVCPRO HD 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; IsParsingMiddle_MaxOffset=(int64u)-1; 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; StreamIDFile_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; StreamID2Retrieve(Stream_Audio, 0, Audio_Channel_s_).To_int32u()+Streams[StreamID2].Parsers[0]->Retrieve(Stream_Audio, 0, Audio_Channel_s_).To_int32u(); Streams[StreamID].Parsers[0]->Fill(Stream_Audio, 0, Audio_Channel_s_, Channels, 10, true); int32u BitRate=Streams[StreamID].Parsers[0]->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int32u()+Streams[StreamID2].Parsers[0]->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int32u(); Streams[StreamID].Parsers[0]->Fill(Stream_Audio, 0, Audio_BitRate, BitRate, 10, true); } Streams[StreamID2].MediaType=(int8u)-1; } } } } } //For each Streams for (size_t StreamID=0; StreamID::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) { int64u TimeCode_FirstFrame_ms=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame_ms; string TimeCode_FirstFrame=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame; bool TimeCode_FirstFrame_Striped=false; if (TimeCode_FirstFrame_ms==(int64u)-1) { TimeCode_FirstFrame_ms=TimeCode->second.Milliseconds; TimeCode_FirstFrame=TimeCode->second.String; TimeCode_FirstFrame_Striped=true; } if (TimeCode_FirstFrame_ms!=(int64u)-1) { Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_CodecID, Streams[TimeCode->first].MediaType); Fill(Stream_Other, StreamPos_Last, Other_ID, TimeCode->first); Fill(Stream_Other, StreamPos_Last, Other_Type, "Time code"); Fill(Stream_Other, StreamPos_Last, Other_Format, "SMPTE TC"); Fill(Stream_Other, StreamPos_Last, Other_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); if (TimeCode_FirstFrame_Striped) Fill(Stream_Other, StreamPos_Last, Other_TimeCode_Striped, "Yes"); if (TimeCode->firstfirst].MediaName); } } } //--------------------------------------------------------------------------- void File_Gxf::Streams_Finish_PerStream(size_t StreamID, stream &Temp) { if (Temp.MediaType==(int8u)-1) return; //By the parser if (Temp.Parsers.size()==1 && Temp.Parsers[0]->Status[IsAccepted]) { StreamKind_Last=Stream_Max; StreamPos_Last=(size_t)-1; if (Config->ParseSpeed<=1.0) { Fill(Temp.Parsers[0]); Temp.Parsers[0]->Open_Buffer_Unsynch(); } Finish(Temp.Parsers[0]); //Video bool IsTimeCode=false; for (std::map::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) if (StreamID==TimeCode->first) IsTimeCode=true; if (!IsTimeCode && Temp.DisplayInfo) { if (Temp.Parsers[0]->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::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) { int64u TimeCode_FirstFrame_ms=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame_ms; string TimeCode_FirstFrame=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame; if (TimeCode_FirstFrame_ms==(int64u)-1) { TimeCode_FirstFrame_ms=TimeCode->second.Milliseconds; TimeCode_FirstFrame=TimeCode->second.String; } if (TimeCode_FirstFrame_ms!=(int64u)-1) { Fill(Stream_Video, StreamPos_Last, Video_Delay, TimeCode_FirstFrame_ms, 0); if (TimeCode_FirstFrame.size()==11) Fill(Stream_Video, StreamPos_Last, Video_Delay_DropFrame, TimeCode_FirstFrame[8]==';'?"Yes":"No"); Fill(Stream_Video, StreamPos_Last, Video_Delay_Source, "Container"); //Fill(Stream_Video, StreamPos_Last, Video_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); //Fill(Stream_Video, StreamPos_Last, Video_TimeCode_Source, "Time code track"); } } Merge(*Temp.Parsers[0], Stream_Video, 0, StreamPos_Last); Fill(Stream_Video, StreamPos_Last, Video_CodecID, Temp.MediaType); Fill(Stream_Video, StreamPos_Last, Video_ID, StreamID, 10, true); Fill(Stream_Video, StreamPos_Last, "Title", Temp.MediaName); Ztring LawRating=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); //Special cases if (Temp.Parsers[0]->Count_Get(Stream_Text)) { //Video and Text are together size_t Parser_Text_Count=Temp.Parsers[0]->Count_Get(Stream_Text); for (size_t Parser_Text_Pos=0; Parser_Text_PosCount_Get(Stream_Audio); Pos++) { Stream_Prepare(Stream_Audio); Fill(Stream_Audio, StreamPos_Last, Audio_CodecID, Temp.MediaType); 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::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) { int64u TimeCode_FirstFrame_ms=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame_ms; string TimeCode_FirstFrame=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame; if (TimeCode_FirstFrame_ms==(int64u)-1) { TimeCode_FirstFrame_ms=TimeCode->second.Milliseconds; TimeCode_FirstFrame=TimeCode->second.String; } if (TimeCode_FirstFrame_ms!=(int64u)-1) { Fill(Stream_Audio, StreamPos_Last, Audio_Delay, TimeCode_FirstFrame_ms, 0); if (TimeCode_FirstFrame.size()==11) Fill(Stream_Audio, StreamPos_Last, Audio_Delay_DropFrame, TimeCode_FirstFrame[8]==';'?"Yes":"No"); Fill(Stream_Audio, StreamPos_Last, Audio_Delay_Source, "Container"); //Fill(Stream_Audio, StreamPos_Last, Audio_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); //Fill(Stream_Audio, StreamPos_Last, Audio_TimeCode_Source, "Time code track"); } } Merge(*Temp.Parsers[0], Stream_Audio, Pos, StreamPos_Last, false); Ztring ID; if (Temp.IsChannelGrouping) ID=Ztring::ToZtring(StreamID-1)+__T(" / "); //First half of the channel grouping ID+=Ztring::ToZtring(StreamID); //Second half of the channel grouping or standalone 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); if (Temp.IsChannelGrouping) Fill(Stream_Audio, StreamPos_Last, "Title", Streams[StreamID-1].MediaName); //First half of the channel grouping Fill(StreamKind_Last, StreamPos_Last, "Title", Temp.MediaName); //Second half of the channel grouping or standalone for (std::map::iterator Info=Temp.Infos.begin(); Info!=Temp.Infos.end(); ++Info) if (Info->first=="BitRate" && Temp.Parsers[0]->Count_Get(Stream_Audio)>1) Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Encoded, Pos?Ztring(__T("0")):Info->second); // In case of more than 1 audio sub-stream Encoded bit rate is the bit rate of all streams + overhead else 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.Parsers[0]->Count_Get(Stream_Text)) { size_t Parser_Text_Count=Temp.Parsers[0]->Count_Get(Stream_Text); for (size_t Parser_Text_Pos=0; Parser_Text_PosRetrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); StreamKind_Last=Stream_Max; StreamPos_Last=(size_t)-1; } //Other if (Temp.Parsers[0]->Count_Get(Stream_Other)) { size_t Parser_Other_Count=Temp.Parsers[0]->Count_Get(Stream_Other); for (size_t Parser_Other_Pos=0; Parser_Other_Pos=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; PosOpen_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::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) { int64u TimeCode_First=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parsers[0])->TimeCode_FirstFrame_ms; if (TimeCode_First==(int64u)-1) TimeCode_First=TimeCode->second.Milliseconds; if (TimeCode_First==(int64u)-1) Delay=0; else { Delay=TimeCode_First*1000000; break; } } } if (ValueGopSize!=(int64u)-1) { Value/=((File_Umf*)UMF_File)->GopSize; Value*=((File_Umf*)UMF_File)->GopSize; } Value*=Material_Fields_FieldsPerFrame; for (size_t Pos=0; Pos=IsParsingMiddle_MaxOffset) { Fill(); Open_Buffer_Unsynch(); Finish(); return; } } //*************************************************************************** // 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() && Streams[TrackNumber].Demux_EventWasSent) //media block { Open_Buffer_Continue(Streams[TrackNumber].Parsers[0], Buffer+Buffer_Offset, 0); if (Config->Demux_EventWasSent) return false; Streams[TrackNumber].Demux_EventWasSent=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=Element_Size) SectionLength=(int16u)(Element_Size-Element_Offset); int64u Track_Data_End=Element_Offset+SectionLength; while (Element_Offset=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].Parsers.empty()) { 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 { File__Analyze* Parser=new File__Analyze; Open_Buffer_Init(Parser); Parser->Accept(); Parser->Fill(); Parser->Stream_Prepare(Stream_Video); Parser->Fill(Stream_Video, 0, Video_Format, "JPEG"); Streams[TrackID].Parsers.push_back(Parser); } break; case 7 : case 8 : case 24 : //TimeCode { File__Analyze* Parser=new File_Gxf_TimeCode; Open_Buffer_Init(Parser); Streams[TrackID].Parsers.push_back(Parser); Parsers_Count++; Streams[TrackID].Searching_Payload=true; TimeCodes[TrackID].Milliseconds=(int64u)-1; } break; case 9 : case 10 : { File__Analyze* Parser=new File__Analyze; Open_Buffer_Init(Parser); Parser->Accept(); Parser->Fill(); Parser->Stream_Prepare(Stream_Audio); Parser->Fill(Stream_Audio, 0, Audio_Format, "PCM"); Parser->Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Little"); Streams[TrackID].Parsers.push_back(Parser); Audio_Count++; } break; case 11 : case 12 : case 20 : case 22 : case 23 : //MPEG Video { File__Analyze* Parser=new File_Mpegv(); ((File_Mpegv*)Parser)->FrameIsAlwaysComplete=true; ((File_Mpegv*)Parser)->Ancillary=&Ancillary; Open_Buffer_Init(Parser); Streams[TrackID].Parsers.push_back(Parser); Parsers_Count++; Streams[TrackID].Searching_Payload=true; } break; case 13 : case 14 : case 15 : case 16 : case 25 : // was found for DVCPro HD in some files (not in SMPTE ST 360-2009, maybe it is present in a later version) //DV { File__Analyze* Parser=new File_DvDif(); Open_Buffer_Init(Parser); Streams[TrackID].Parsers.push_back(Parser); Parsers_Count++; Streams[TrackID].Searching_Payload=true; } break; case 17 : //AC-3 in AES3 (half) case 18 : //Dolby E in AES3 (half) { File__Analyze* Parser=ChooseParser_ChannelGrouping(TrackID); if (Parser) { Open_Buffer_Init(Parser); Streams[TrackID].Parsers.push_back(Parser); Parsers_Count++; Audio_Count++; Streams[TrackID].Searching_Payload=true; } } break; case 21 : //Ancillary Metadata { File__Analyze* Parser=new File_Riff(); ((File_Riff*)Parser)->Ancillary=&Ancillary; Open_Buffer_Init(Parser); Streams[TrackID].Parsers.push_back(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::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) if (TrackID==TimeCode->first) for (size_t Pos=0; PosFrameRate_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::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); ++TimeCode) if (TrackID==TimeCode->first) for (size_t Pos=0; PosFieldsPerFrame_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::iterator TimeCode=TimeCodes.find(TrackID); if (TimeCode==TimeCodes.end() || TimeCode->second.Milliseconds==(int64u)-1) { float64 FrameRate=Gxf_FrameRate(Streams[TrackID].FrameRate_Code); TimeCodes[TrackID].Milliseconds=Hours *60*60*1000 +Minutes *60*1000 +Seconds *1000; MediaInfoLib::TimeCode TC; TC.Hours=Hours; TC.Minutes=Minutes; TC.Seconds=Seconds; TC.Frames=Fields/2; TC.DropFrame=DropFrame; TimeCodes[TrackID].String=TC.ToString(); if (!FrameRate) { //Time code frame rate is missing, using the video frame rate for (size_t Pos=0; PosGopSize!=(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].Parsers[0])->TimeCode_FirstFrame_ms; if (TimeCode_First==(int64u)-1) TimeCode_First=TimeCodes.begin()->second.Milliseconds; } 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].Parsers.empty() && (Streams[TrackNumber].Parsers[0]->Demux_UnpacketizeContainer || Streams[TrackNumber].Parsers[0]->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 && IsParsingMiddle_MaxOffset==(int64u)-1) { Skip_XX(Element_Size-Element_Offset, "data"); //Element_DoNotShow(); return; } for (size_t Pos=0; PosFrameInfo.DTS=FrameInfo.DTS; Open_Buffer_Continue(Streams[TrackNumber].Parsers[Pos], Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent && Config->Demux_Unpacketize_Get()) Streams[TrackNumber].Demux_EventWasSent=true; #endif //MEDIAINFO_DEMUX //Multiple parsers if (Streams[TrackNumber].Parsers.size()>1) { if (!Streams[TrackNumber].Parsers[Pos]->Status[IsAccepted] && Streams[TrackNumber].Parsers[Pos]->Status[IsFinished]) { delete *(Streams[TrackNumber].Parsers.begin()+Pos); Streams[TrackNumber].Parsers.erase(Streams[TrackNumber].Parsers.begin()+Pos); Pos--; } else if (Streams[TrackNumber].Parsers.size()>1 && Streams[TrackNumber].Parsers[Pos]->Status[IsAccepted]) { File__Analyze* Parser=Streams[TrackNumber].Parsers[Pos]; for (size_t Pos2=0; Pos2ParseSpeed<1 && Streams[TrackNumber].Parsers.size()==1 && Streams[TrackNumber].Parsers[0]->Status[IsFilled]) { Streams[TrackNumber].Searching_Payload=false; if (Parsers_Count>0) Parsers_Count--; if (Parsers_Count==0) { TryToFinish(); } } } //--------------------------------------------------------------------------- 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; PosGopSize!=(int64u)-1) { size_t NextIFrame=0; for (size_t Pos=0; Pos=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) { TryToFinish(); } } //--------------------------------------------------------------------------- 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->CanBePcm=true; Parser->Channel_Pos=1; Parser->Common=((File_ChannelGrouping*)Streams[TrackID-1].Parsers[0])->Common; Parser->StreamID=TrackID-1; Streams[TrackID].IsChannelGrouping=true; } else { Parser=new File_ChannelGrouping; Parser->CanBePcm=true; Parser->Channel_Pos=0; //if (Descriptor->second.Infos.find("SamplingRate")!=Descriptor->second.Infos.end()) Streams[TrackID].IsChannelGrouping=true; Streams[TrackID].DisplayInfo=false; } Parser->BitDepth=24; Parser->Channel_Total=2; Parser->SamplingRate=48000; //TODO: find where this piece of info is avaialble Parser->Endianness='L'; #if MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX return Parser; } //--------------------------------------------------------------------------- void File_Gxf::TryToFinish() { if (!IsSub && File_Size!=(int64u)-1 && Config->ParseSpeed<1 && IsParsingMiddle_MaxOffset==(int64u)-1 && File_Size/2>SizeToAnalyze*4) { IsParsingMiddle_MaxOffset=File_Size/2+SizeToAnalyze*4; GoTo(File_Size/2); Open_Buffer_Unsynch(); Parsers_Count=(int8u)-1; return; } Finish(); } } //NameSpace #endif //MEDIAINFO_GXF_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Wm.cpp0000664000000000000000000002721012652076434020767 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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::iterator Temp=Stream.begin(); while (Temp!=Stream.end()) { for (std::map::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; Possecond.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 int32u PresentationTime_Previous=(int32u)-1; size_t TimeDiffs_Sum=0; std::map TimeDiffs; for (std::set::iterator PresentationTime=Temp->second.PresentationTimes.begin(); PresentationTime!=Temp->second.PresentationTimes.end(); ++PresentationTime) { if (PresentationTime_Previous!=(int32u)-1) TimeDiffs[*PresentationTime-PresentationTime_Previous]++; PresentationTime_Previous=*PresentationTime; } for (std::map::iterator TimeDiff=TimeDiffs.begin(); TimeDiff!=TimeDiffs.end();) { if (TimeDiff->second<=2) TimeDiffs.erase(TimeDiff++); else { TimeDiffs_Sum+=TimeDiff->second; ++TimeDiff; } } if (TimeDiffs.empty() || (TimeDiffs.size()==1 && TimeDiffs_Sum<16) || (TimeDiffs.size()==2 && TimeDiffs_Sum<32) || TimeDiffs.begin()->first==1) { if (Temp->second.AverageTimePerFrame>0) Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate, ((float)10000000)/(Temp->second.AverageTimePerFrame*(Temp->second.Parser && Temp->second.Parser->Retrieve(Stream_Video, 0, Video_ScanType)==__T("Interlaced")?2:1)), 3, true); } else if (TimeDiffs.size()==1) { Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate, 1000/((float64)TimeDiffs.begin()->first), 3, true); if (Temp->second.AverageTimePerFrame>0) Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate_Nominal, ((float)10000000)/(Temp->second.AverageTimePerFrame*(Temp->second.Parser && Temp->second.Parser->Retrieve(Stream_Video, 0, Video_ScanType)==__T("Interlaced")?2:1)), 3, true); } else if (TimeDiffs.size()==2) { std::map::iterator PresentationTime_Delta_Most=TimeDiffs.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*(Temp->second.Parser && Temp->second.Parser->Retrieve(Stream_Video, 0, Video_ScanType)==__T("Interlaced")?2:1)), 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*(Temp->second.Parser && Temp->second.Parser->Retrieve(Stream_Video, 0, Video_ScanType)==__T("Interlaced")?2:1)), 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Swf.cpp0000664000000000000000000006253412652076434021153 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 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=((float32)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_Info1C((CodecID<16), Swf_Format_Video[CodecID]); 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); if (CodecID<16) { 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_* MediaInfoLib/Source/MediaInfo/Multiple/File_Ibi_Creation.h0000664000000000000000000000646612652076434022412 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Ibi files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_Ibi_CreationH #define MediaInfo_File_Ibi_CreationH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" #include #include 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 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 streams; streams Streams; Ztring Inform_Data; Ztring FileName; //Constructor/Destructor ibi(); ~ibi(); }; //*************************************************************************** /* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //*************************************************************************** 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 Buffers; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Ivf.cpp0000664000000000000000000001061212652076434021126 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // // 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 (4>Buffer_Size) return false; if (Buffer[0]!=0x44 //"DKIF" || Buffer[1]!=0x4B || Buffer[2]!=0x49 || Buffer[3]!=0x46) { Reject(); return false; } if (6>Buffer_Size) 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_* MediaInfoLib/Source/MediaInfo/Multiple/File_Bdmv.cpp0000664000000000000000000017672612652076434021315 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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::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 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; PosOption(__T("File_Bdmv_ParseTargetedFile"), __T("0")); MIs[Pos]->Option(__T("File_IsReferenced"), __T("1")); 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.Option(__T("File_IsReferenced"), __T("1")); 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 PIDs_StreamKind; std::map 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")); MI.Option(__T("File_IsReferenced"), __T("1")); if (MI.Open(M2TS_File)) { Merge(MI); for (size_t StreamKind=Stream_General+1; StreamKind::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 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_Posfirst>=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 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::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; PosElement_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_PosElement_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?"); Mpls_PlayList_PlayItem_Duration=Time_Out-Time_In; if (Time_Out>Time_In) Mpls_PlayList_Duration+=Mpls_PlayList_PlayItem_Duration; std::vector StreamCount_Before; for (size_t StreamKind=Stream_General; StreamKind10+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")); MI.Option(__T("File_IsReferenced"), __T("1")); if (MI.Open(CLPI_File)) { for (size_t StreamKind=Stream_General+1; StreamKind=Count_Get((stream_t)StreamKind)) Stream_Prepare((stream_t)StreamKind); Merge(MI, (stream_t)StreamKind, StreamPos, StreamCount_Before[StreamKind]+StreamPos); } } 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); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Mpls_PlayList_PlayItem_Duration/45); } 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(int8u SubPath_type, int16u Pos) { 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 (SubPath_type==8 && Pos!=(int16u)-1) //MVC { if (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")); MI.Option(__T("File_IsReferenced"), __T("1")); if (MI.Open(CLPI_File)) { if (MI.Count_Get(Stream_Video)) { Ztring ID=Retrieve(Stream_Video, Pos, Video_ID); Ztring ID_String=Retrieve(Stream_Video, Pos, Video_ID_String); Ztring Format_Profile=Retrieve(Stream_Video, Pos, Video_Format_Profile); Ztring BitRate=Retrieve(Stream_Video, Pos, Video_BitRate); Ztring Source=Retrieve(Stream_Video, Pos, "Source"); Fill(Stream_Video, Pos, Video_ID, MI.Get(Stream_Video, 0, Video_ID)+__T(" / ")+ID, true); Fill(Stream_Video, Pos, Video_ID_String, MI.Get(Stream_Video, 0, Video_ID_String)+__T(" / ")+ID_String, true); if (!Format_Profile.empty()) Fill(Stream_Video, Pos, Video_Format_Profile, MI.Get(Stream_Video, 0, Video_Format_Profile)+__T(" / ")+Format_Profile, true); if (!BitRate.empty()) Fill(Stream_Video, Pos, 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, Pos, "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; Posfirst>=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 #endif //defined(MEDIAINFO_ANCILLARY_YES) #include //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Lxf //*************************************************************************** class File_Lxf : public File__Analyze { public : //Constructor/Destructor File_Lxf(); ~File_Lxf(); protected : //Streams management void Streams_Fill (); void Streams_Fill_PerStream (File__Analyze* Parser, stream_t Container_StreamKind, size_t Parser_Pos, int8u Format=(int8u)-1); void Streams_Finish (); //Buffer - File header bool FileHeader_Begin(); //Buffer - Synchro bool Synchronize(); bool Synched_Test(); //Buffer - Global void Read_Buffer_Continue(); #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(); //Streams struct stream { std::vector Parsers; int64u BytesPerFrame; int8u Format; bool IsFilled; stream() { BytesPerFrame=(int64u)-1; Format=(int8u)-1; IsFilled=false; } }; typedef std::vector streams; streams Videos; streams Audios; struct stream_header { int64u TimeStamp_Begin; int64u TimeStamp_End; int64u Duration; int64u Duration_First; int8u PictureType; stream_header() { TimeStamp_Begin=(int64u)-1; TimeStamp_End=(int64u)-1; Duration=(int64u)-1; Duration_First=(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_; Duration_First = (int64u)-1; PictureType = PictureType_; } }; stream_header Videos_Header; stream_header Audios_Header; #if defined(MEDIAINFO_ANCILLARY_YES) File_Ancillary* Ancillary; #endif //defined(MEDIAINFO_ANCILLARY_YES) //Temp bool LookingForLastFrame; int64u Stream_Count; int64u Info_General_StreamSize; std::vector Header_Sizes; std::vector Audio_Sizes; size_t Audio_Sizes_Pos; std::vector Video_Sizes; size_t Video_Sizes_Pos; int8u SampleSize; int32u Version; //Hints size_t* File_Buffer_Size_Hint_Pointer; //Demux #if MEDIAINFO_DEMUX File__Analyze* DemuxParser; #endif //MEDIAINFO_DEMUX //Seek typedef std::map 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 MediaInfoLib/Source/MediaInfo/Multiple/File_SequenceInfo.cpp0000664000000000000000000002206212652076434022770 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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->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); sequence* Sequence=new sequence; Sequence->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); 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()=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(Sequence->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:Sequence->FileNames.size(); do { Number=Ztring::ToZtring(FileNumber); if (Number.size()AddFileName(FullFile); FileNumber++; } while (FileNumber<1000000000); } DirNumber++; } while (DirNumber<1000000000); ReferenceFiles->AddSequence(Sequence); } } } else { Reject("SequenceInfo"); return false; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_SEQUENCEINFO_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Mk.h0000664000000000000000000003776212652076434020435 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Matroska files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_MatroskaH #define MediaInfo_File_MatroskaH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Classe File_Matroska //*************************************************************************** class File_Mk : public File__Analyze { protected : //Streams management void Streams_Finish(); public : File_Mk(); ~File_Mk(); void Segment_Attachements_AttachedFile_FileName(); 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_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 TimeCodes; int64u TimeCode_Start; int64u TrackUID; 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 Infos; int64u TrackDefaultDuration; std::map Segment_Cluster_BlockGroup_BlockDuration_Counts; int64u PixelCropBottom; int64u PixelCropLeft; int64u PixelCropRight; int64u PixelCropTop; stream() { TimeCode_Start=(int64u)-1; TrackUID=(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; TrackDefaultDuration=0; PixelCropBottom=0; PixelCropLeft=0; PixelCropRight=0; PixelCropTop=0; } ~stream() { delete Parser; //Parser=NULL; delete[] ContentCompSettings_Buffer; //ContentCompSettings_Buffer=NULL; } }; std::map 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 int8u InvalidByteMax; int64u Format_Version; int64u TimecodeScale; float64 Duration; int64u TrackNumber; int64u TrackVideoDisplayWidth; int64u TrackVideoDisplayHeight; int32u AvgBytesPerSec; int64u Segment_Cluster_TimeCode_Value; size_t Segment_Info_Count; size_t Segment_Tracks_Count; size_t Segment_Cluster_Count; typedef std::map tagspertrack; typedef std::map tags; tags Segment_Tags_Tag_Items; int64u Segment_Tags_Tag_Targets_TrackUID_Value; bool CurrentAttachmentIsCover; bool CoverIsSetFromAttachment; struct crc32 { int64u Pos; int64u From; int64u UpTo; int32u Computed; int32u Expected; }; std::vector CRC32Compute; //Chapters struct chapterdisplay { Ztring ChapLanguage; Ztring ChapString; }; struct chapteratom { int64u ChapterTimeStart; std::vector ChapterDisplays; chapteratom() { ChapterTimeStart=(int64u)-1; } }; struct editionentry { std::vector ChapterAtoms; }; std::vector EditionEntries; size_t EditionEntries_Pos; size_t ChapterAtoms_Pos; size_t ChapterDisplays_Pos; int64u Segment_Offset_Begin; int64u Segment_Offset_End; std::vector Segment_Seeks; size_t Segment_Seeks_Pos; std::vector Segment_Tag_SimpleTag_TagNames; int64u Segment_Cluster_BlockGroup_BlockDuration_Value; int64u Segment_Cluster_BlockGroup_BlockDuration_TrackNumber; //Helpers void JumpTo(int64u GoTo); void TestMultipleInstances(size_t* Instances=NULL); void CRC32_Check(); void CRC32_Compute(int32u &CRC32, int32u Init, const int8u* Buffer_Begin, const int8u* Buffer_End); void CRC32_Compute(int32u &CRC32, const int8u* Buffer_Begin, const int8u* Buffer_End); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_DcpAm.cpp0000664000000000000000000002673512652076434021403 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DCP_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_DcpAm.h" #include "MediaInfo/MediaInfo.h" #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" #include "MediaInfo/Multiple/File_DcpCpl.h" #include "ZenLib/Dir.h" #include "ZenLib/FileName.h" #include "tinyxml2.h" using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_DcpAm::File_DcpAm() :File__Analyze() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_DcpAm; StreamIDs_Width[0]=sizeof(size_t)*2; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Demux_EventWasSent_Accept_Specific=true; #endif //MEDIAINFO_DEMUX //PKL PKL_Pos=(size_t)-1; //Temp ReferenceFiles=NULL; } //--------------------------------------------------------------------------- File_DcpAm::~File_DcpAm() { delete ReferenceFiles; //ReferenceFiles=NULL; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpAm::Streams_Finish() { if (ReferenceFiles==NULL) return; ReferenceFiles->ParseReferences(); // Detection of IMF CPL bool IsImf=false; for (size_t StreamKind=Stream_General+1; StreamKindSeek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_DcpAm::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) { Reject("DcpAm"); return false; } const char* Attribute=AssetMap->Attribute(NameSpace.empty()?"xmlns":"xmlns:am"); if (!Attribute) { Reject("DcpAm"); return false; } if (strcmp(Attribute, "http://www.digicine.com/PROTO-ASDCP-AM-20040311#") && strcmp(Attribute, "http://www.smpte-ra.org/schemas/429-9/2007/AM")) { Reject("DcpAm"); return false; } Accept("DcpAm"); Fill(Stream_General, 0, General_Format, "DCP AM"); Fill(Stream_General, 0, General_Format_Version, NameSpace=="am:"?"SMPTE":"Interop"); Config->File_ID_OnlyRoot_Set(false); //Parsing main elements for (XMLElement* AssetMap_Item=AssetMap->FirstChildElement(); AssetMap_Item; AssetMap_Item=AssetMap_Item->NextSiblingElement()) { //AssetList if (!strcmp(AssetMap_Item->Value(), (NameSpace+"AssetList").c_str())) { for (XMLElement* AssetList_Item=AssetMap_Item->FirstChildElement(); AssetList_Item; AssetList_Item=AssetList_Item->NextSiblingElement()) { //Asset if (!strcmp(AssetList_Item->Value(), (NameSpace+"Asset").c_str())) { File_DcpPkl::stream Stream; for (XMLElement* Asset_Item=AssetList_Item->FirstChildElement(); Asset_Item; Asset_Item=Asset_Item->NextSiblingElement()) { //ChunkList if (!strcmp(Asset_Item->Value(), (NameSpace+"ChunkList").c_str())) { for (XMLElement* ChunkList_Item=Asset_Item->FirstChildElement(); ChunkList_Item; ChunkList_Item=ChunkList_Item->NextSiblingElement()) { //Chunk if (!strcmp(ChunkList_Item->Value(), (NameSpace+"Chunk").c_str())) { File_DcpPkl::stream::chunk Chunk; for (XMLElement* Chunk_Item=ChunkList_Item->FirstChildElement(); Chunk_Item; Chunk_Item=Chunk_Item->NextSiblingElement()) { //Path if (!strcmp(Chunk_Item->Value(), (NameSpace+"Path").c_str())) Chunk.Path=Chunk_Item->GetText(); } Stream.ChunkList.push_back(Chunk); } } } //Id if (!strcmp(Asset_Item->Value(), (NameSpace+"Id").c_str())) Stream.Id=Asset_Item->GetText(); //PackingList if (!strcmp(Asset_Item->Value(), (NameSpace+"PackingList").c_str())) { PKL_Pos=Streams.size(); Stream.StreamKind=(stream_t)(Stream_Max+2); // Means PKL } } Streams.push_back(Stream); } } } //Creator if (!strcmp(AssetMap_Item->Value(), (NameSpace+"Creator").c_str())) Fill(Stream_General, 0, General_Encoded_Library, AssetMap_Item->GetText()); //IssueDate if (!strcmp(AssetMap_Item->Value(), (NameSpace+"IssueDate").c_str())) Fill(Stream_General, 0, General_Encoded_Date, AssetMap_Item->GetText()); //Issuer if (!strcmp(AssetMap_Item->Value(), (NameSpace+"Issuer").c_str())) Fill(Stream_General, 0, General_EncodedBy, AssetMap_Item->GetText()); } Element_Offset=File_Size; //Merging with PKL if (PKL_PosStreams); for (size_t Pos=0; PosFile_IsReferenced_Get()) { ReferenceFiles=new File__ReferenceFilesHelper(this, Config); for (File_DcpPkl::streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) if (Stream->StreamKind==(stream_t)(Stream_Max+1) && Stream->ChunkList.size()==1) // Means CPL { sequence* Sequence=new sequence; Sequence->FileNames.push_back(Ztring().From_UTF8(Stream->ChunkList[0].Path)); Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } ReferenceFiles->FilesForStorage=true; } //All should be OK... return true; } //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpAm::MergeFromPkl (File_DcpPkl::streams &StreamsToMerge) { for (File_DcpPkl::streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { for (File_DcpPkl::streams::iterator StreamToMerge=StreamsToMerge.begin(); StreamToMerge!=StreamsToMerge.end(); ++StreamToMerge) if (StreamToMerge->Id==Stream->Id) { if (Stream->StreamKind==Stream_Max) Stream->StreamKind=StreamToMerge->StreamKind; if (Stream->OriginalFileName.empty()) Stream->OriginalFileName=StreamToMerge->OriginalFileName; if (Stream->Type.empty()) Stream->Type=StreamToMerge->Type; if (Stream->AnnotationText.empty()) Stream->AnnotationText=StreamToMerge->AnnotationText; } } } } //NameSpace #endif //MEDIAINFO_DCP_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Ism.cpp0000664000000000000000000001634512652076434021143 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include "MediaInfo/MediaInfo.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_Accept() { Fill(Stream_General, 0, General_Format, "ISM"); } //--------------------------------------------------------------------------- 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->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) { ReferenceFiles=new File__ReferenceFilesHelper(this, Config); std::set FileNames; XMLElement* Body=Root->FirstChildElement(); while (Body) { if (string(Body->Value())=="body") { XMLElement* Switch=Body->FirstChildElement(); while (Switch) { if (string(Switch->Value())=="switch") { Accept("ISM"); XMLElement* Stream=Switch->FirstChildElement(); while (Stream) { string Value(Stream->Value()); if (Value=="video" || Value=="videostream" || Value=="audio" || Value=="audiostream" || Value=="text" || Value=="textstream") { sequence* Sequence=new sequence; if (Value=="video" || Value=="videostream") Sequence->StreamKind=Stream_Video; if (Value=="audio" || Value=="audiostream") Sequence->StreamKind=Stream_Audio; if (Value=="text" || Value=="textstream" ) Sequence->StreamKind=Stream_Text; const char* Attribute=Stream->Attribute("src"); if (Attribute) Sequence->AddFileName(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) Sequence->StreamID=Ztring().From_UTF8(Attribute).To_int64u(); } } Param=Param->NextSiblingElement(); } if (!Sequence->FileNames.empty() && !Sequence->FileNames[0].empty() && FileNames.find(Sequence->FileNames[0])==FileNames.end()) { ReferenceFiles->AddSequence(Sequence); FileNames.insert(Sequence->FileNames[0]); } } Stream=Stream->NextSiblingElement(); } } Switch=Switch->NextSiblingElement(); } } Body=Body->NextSiblingElement(); } } else { Reject("ISM"); return false; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_ISM_YES MediaInfoLib/Source/MediaInfo/Multiple/File_P2_Clip.cpp0000664000000000000000000005543412652076434021645 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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/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->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(); #if defined(MEDIAINFO_MXF_YES) size_t Audio_Count=0; #endif while (Track) { string Field=Track->Value(); if (Field=="Video") { sequence* Sequence=new sequence; float64 FrameRate=0; //FrameRate ChildElement=Track->FirstChildElement("FrameRate"); if (ChildElement) { Ztring FrameRateS=Ztring(ChildElement->GetText()); if (FrameRateS.find(__T("23.97"))==0) FrameRate=((float64)24)*1000/1001; else if (FrameRateS.find(__T("29.97"))==0) FrameRate=((float64)30)*1000/1001; else if (FrameRateS.find(__T("59.94"))==0) FrameRate=((float64)60)*1000/1001; else FrameRate=FrameRateS.To_float64(); if (FrameRateS.find('i')!=string::npos) FrameRate/=2; Sequence->FrameRate_Set(FrameRate); } //StartTimecode 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 (FrameRate) ToFill+=float64_int64s(((Text[9]-'0')*10+(Text[10]-'0'))*1000/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+1 && 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') && File_Name[File_Name.size()-10-6]==PathSeparator) { Ztring file=File_Name.substr(File_Name.size()-10, 6); Ztring MXF_File=__T(".."); MXF_File+=PathSeparator; Ztring Path=File_Name.substr(0, File_Name.size()-10-6); ZtringList Dirs=Dir::GetAllFileNames(Path, Dir::Include_Dirs); bool Exists=false; for (size_t Pos=0; Pos6 && (Dirs[Pos][Dirs[Pos].size()-1]&(~0x20))==__T('O') && (Dirs[Pos][Dirs[Pos].size()-2]&(~0x20))==__T('E') && (Dirs[Pos][Dirs[Pos].size()-3]&(~0x20))==__T('D') && (Dirs[Pos][Dirs[Pos].size()-4]&(~0x20))==__T('I') && (Dirs[Pos][Dirs[Pos].size()-5]&(~0x20))==__T('V') && Dirs[Pos][Dirs[Pos].size()-6]==PathSeparator) { MXF_File+=Dirs[Pos].substr(Dirs[Pos].size()-5, 5); Exists=true; break; } if (!Exists) MXF_File+=__T("AUDIO"); MXF_File+=PathSeparator; MXF_File+=file; Dirs=Dir::GetAllFileNames(File_Name.substr(0, File_Name.size()-10-1)+PathSeparator+MXF_File+__T(".MXF"), Dir::Include_Files); Exists=false; for (size_t Pos=0; Pos4 && (Dirs[Pos][Dirs[Pos].size()-1]&(~0x20))==__T('F') && (Dirs[Pos][Dirs[Pos].size()-2]&(~0x20))==__T('X') && (Dirs[Pos][Dirs[Pos].size()-3]&(~0x20))==__T('M') && Dirs[Pos][Dirs[Pos].size()-4]==__T('.')) { MXF_File+=Dirs[Pos].substr(Dirs[Pos].size()-4, 4); Exists=true; break; } if (!Exists) MXF_File+=__T(".MXF"); Sequence->AddFileName(MXF_File); Sequence->StreamKind=Stream_Video; Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } #endif //defined(MEDIAINFO_MXF_YES) } else if (Field=="Audio") { #if defined(MEDIAINFO_MXF_YES) if (File_Name.size()>10+1+4+1 && 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') && File_Name[File_Name.size()-10-6]==PathSeparator) { Ztring file=File_Name.substr(File_Name.size()-10, 6); Ztring MXF_File=__T(".."); MXF_File+=PathSeparator; Ztring Path=File_Name.substr(0, File_Name.size()-10-6); ZtringList Dirs=Dir::GetAllFileNames(Path, Dir::Include_Dirs); bool Exists=false; for (size_t Pos=0; Pos6 && (Dirs[Pos][Dirs[Pos].size()-1]&(~0x20))==__T('O') && (Dirs[Pos][Dirs[Pos].size()-2]&(~0x20))==__T('I') && (Dirs[Pos][Dirs[Pos].size()-3]&(~0x20))==__T('D') && (Dirs[Pos][Dirs[Pos].size()-4]&(~0x20))==__T('U') && (Dirs[Pos][Dirs[Pos].size()-5]&(~0x20))==__T('A') && Dirs[Pos][Dirs[Pos].size()-6]==PathSeparator) { MXF_File+=Dirs[Pos].substr(Dirs[Pos].size()-5, 5); Exists=true; break; } if (!Exists) 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; Dirs=Dir::GetAllFileNames(File_Name.substr(0, File_Name.size()-10-1)+PathSeparator+MXF_File+__T(".MXF"), Dir::Include_Files); Exists=false; for (size_t Pos=0; Pos4 && (Dirs[Pos][Dirs[Pos].size()-1]&(~0x20))==__T('F') && (Dirs[Pos][Dirs[Pos].size()-2]&(~0x20))==__T('X') && (Dirs[Pos][Dirs[Pos].size()-3]&(~0x20))==__T('M') && Dirs[Pos][Dirs[Pos].size()-4]==__T('.')) { MXF_File+=Dirs[Pos].substr(Dirs[Pos].size()-4, 4); Exists=true; break; } if (!Exists) MXF_File+=__T(".MXF"); sequence* Sequence=new sequence; Sequence->AddFileName(MXF_File); Sequence->StreamKind=Stream_Audio; Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); 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; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_P2_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Flv.cpp0000664000000000000000000017650612652076434021150 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // // 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_HEVC_YES) #include "MediaInfo/Video/File_Hevc.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 #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events.h" #endif //MEDIAINFO_EVENTS #include #if MEDIAINFO_DEMUX #include "base64.h" #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- 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[16]= { "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[16]= { "", "", "Layer 3", "", "", "", "", "A-law", "U-law", "", "", "", "", "", "Layer 3", //8 KHz "", }; const char* Flv_Codec_Audio[16]= { "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[16]= { "", "", "MP3", "", "", "", "", "", "", "", "", "", "", "", "MP3", //8 KHz "", }; const char* Flv_Format_Video[16]= { "", "", "Sorenson Spark", "Screen video", "VP6", "VP6", "Screen video 2", "AVC", "", "", "", "", "HEVC", "", "", "", }; const char* Flv_Format_Profile_Video[16]= { "", "", "", "", "", "Alpha channel", "", "", "", "", "", "", "", "", "", "", }; const char* Flv_Codec_Video[16]= { "", "", "Sorenson H263", "Screen video", "On2 VP6", "On2 VP6 with alpha channel", "Screen video 2", "AVC", "", "", "", "", "HEVC", "", "", "", }; const char* Flv_CodecID_Hint_Video[16]= { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; 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 video_stream_FrameRate_Between; for (size_t Pos=1; Posvideo_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_AudioBitRate_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; PosBuffer_Size) return false; if (Buffer[0]!=0x46 //"FLV" || Buffer[1]!=0x4C || Buffer[2]!=0x56) { Reject(); return false; } if (9>Buffer_Size) return false; return true; } //--------------------------------------------------------------------------- void File_Flv::FileHeader_Parse() { //Parsing Element_Begin1("FLV header"); int32u Size; int8u Version, Flags; Skip_String(3, "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 (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); #if MEDIAINFO_DEMUX if (Config->Demux_ForceIds_Get()) Fill(Stream_Video, 0, Video_ID, 9); #endif //MEDIAINFO_DEMUX video_stream_FrameRate_Detected=false; } else video_stream_FrameRate_Detected=true; if (audio_stream_Count) { Stream_Prepare(Stream_Audio); #if MEDIAINFO_DEMUX if (Config->Demux_ForceIds_Get()) Fill(Stream_Audio, 0, Audio_ID, 8); #endif //MEDIAINFO_DEMUX } if (Version>1) { Finish(); return; //Version more than 1 is not supported } FILLING_ELSE() Reject(); FILLING_END(); } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_Flv::Synchronize() { if (File_Offset+Buffer_Offset+4==File_Size) return true; // Used by seek from end //Synchronizing while (Buffer_Offset+15<=Buffer_Size) { int32u BodyLength=BigEndian2int24u(Buffer+Buffer_Offset+5); if ((Buffer[Buffer_Offset ] || Buffer[Buffer_Offset+1] || Buffer[Buffer_Offset+2] || Buffer[Buffer_Offset+3]>=11) && File_Offset+Buffer_Offset+15+BodyLength==File_Size) break; //Last block if (File_Offset+Buffer_Offset+15+BodyLengthBuffer_Size) return false; //Need more data if ((Buffer[Buffer_Offset ] || Buffer[Buffer_Offset+1] || Buffer[Buffer_Offset+2] || Buffer[Buffer_Offset+3]>=11) && (BigEndian2int32u(Buffer+Buffer_Offset+15+BodyLength)==11+BodyLength // PreviousTagSize || BigEndian2int32u(Buffer+Buffer_Offset+15+BodyLength)==BodyLength)) // PreviousTagSize without 11, found in some buggy files { PreviousTagSize_Add11=(BigEndian2int32u(Buffer+Buffer_Offset+15+BodyLength)==BodyLength)?0:11; break; } } Buffer_Offset++; } //Parsing last bytes if needed if (Buffer_Offset+15>Buffer_Size) return false; //Synched return true; } //--------------------------------------------------------------------------- bool File_Flv::Synched_Test() { if (File_Offset+Buffer_Offset+4==File_Size) return true; // Used by seek from end //Must have enough buffer for having header if (Buffer_Offset+15>Buffer_Size) return false; //Quick test of synchro if (Buffer[Buffer_Offset ]==0 && Buffer[Buffer_Offset+1]==0 && Buffer[Buffer_Offset+2]==0 && Buffer[Buffer_Offset+3]9) { if (Searching_Duration) { //Error during parsing, stopping Finish(); Searching_Duration=false; GoTo(File_Size); return true; } Synched=false; return true; } //We continue 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 Of File"); Header_Fill_Size(4); return; } //Parsing int32u BodyLength; int8u Type; Get_B4 (PreviousTagSize, "PreviousTagSize"); if (File_Offset+Buffer_Offset+4>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; } if (Type==0) Trusted_IsNot("Wrong type"); } 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 (8+PreviousTagSize>File_Size) { Searching_Duration=false; Open_Buffer_Unsynch(); //There is a problem, trying to sync PreviousTagSize=1024*1024; } 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) { 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>1024*1024*2 && File_Offset+Buffer_Offset-Header_Size-PreviousTagSize-4ParseSpeed<1) Finish(); else if (Element_Code==0xFA) //RM metadata have a malformed PreviousTagSize, always { //Trying to sync Searching_Duration=false; Open_Buffer_Unsynch(); //There is a problem, trying to sync GoToFromEnd(Header_Size+Element_Size+1024*1024); return; } else GoTo(File_Offset+Buffer_Offset-Header_Size-PreviousTagSize-4); } else if (!Status[IsFilled] && !video_stream_Count && !audio_stream_Count && video_stream_FrameRate_Detected && File_Offset+1024*1024*230) 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; } //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); 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 MustSynchronize=true; // Now, synchronization test is possible } //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; case 12 : video_HEVC(); break; default : Skip_XX(Element_Size-Element_Offset, "Unknown"); video_stream_Count=false; //No more need of Video stream; } FILLING_END(); #if MEDIAINFO_DEMUX int8u Demux_Level_old=Demux_Level; if (Stream[Stream_Video].Parser && Stream[Stream_Video].Parser->Demux_Level==2) Demux_Level=4; Demux(Buffer+Buffer_Offset+1, (size_t)(Element_Size-1), ContentType_MainStream); Demux_Level=Demux_Level_old; #endif //MEDIAINFO_DEMUX } //--------------------------------------------------------------------------- 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 || (Config->ParseSpeed<1.0 && Stream[Stream_Video].PacketCount>=300)) { Stream[Stream_Video].Parser->Open_Buffer_Unsynch(); 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::video_HEVC() { 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_HEVC_YES if (Stream[Stream_Video].Parser==NULL) { Stream[Stream_Video].Parser=new File_Hevc; Open_Buffer_Init(Stream[Stream_Video].Parser); ((File_Hevc*)Stream[Stream_Video].Parser)->MustParse_VPS_SPS_PPS=true; ((File_Hevc*)Stream[Stream_Video].Parser)->MustParse_VPS_SPS_PPS_FromFlv=true; ((File_Hevc*)Stream[Stream_Video].Parser)->MustSynchronize=false; ((File_Hevc*)Stream[Stream_Video].Parser)->SizedBlocks=true; #if MEDIAINFO_DEMUX if (Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()) { Stream[Stream_Video].Parser->Demux_Level=2; //Container Stream[Stream_Video].Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX } //Parsing Open_Buffer_Continue(Stream[Stream_Video].Parser); //Demux #if MEDIAINFO_DEMUX switch (Config->Demux_InitData_Get()) { case 0 : //In demux event Demux_Level=2; //Container Demux(Buffer+Buffer_Offset+2, (size_t)(Element_Size-2), ContentType_Header); break; case 1 : //In field { std::string Data_Raw((const char*)(Buffer+Buffer_Offset+2), (size_t)(Element_Size-2)); std::string Data_Base64(Base64::encode(Data_Raw)); Fill(Stream_Video, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[Stream_Video][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif //MEDIAINFO_DEMUX #else Skip_XX(Element_Size-Element_Offset, "HEVC Data"); video_stream_Count=false; //Unable to parse it #endif break; case 1 : #ifdef MEDIAINFO_HEVC_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 || (Config->ParseSpeed<1.0 && Stream[Stream_Video].PacketCount>=300)) { Stream[Stream_Video].Parser->Open_Buffer_Unsynch(); video_stream_Count=false; } #else Skip_XX(Element_Size-Element_Offset, "HEVC 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; } //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 } if (codec!=10) // AAC has an header { Demux(Buffer+Buffer_Offset+(size_t)(Element_Offset+1), (size_t)(Element_Size-Element_Offset-1), ContentType_MainStream); } 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"); } MustSynchronize=true; // Now, synchronization test is possible } //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) { Stream[Stream_Audio].Parser->Open_Buffer_Unsynch(); 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_AAC_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); //Demux #if MEDIAINFO_DEMUX switch (Config->Demux_InitData_Get()) { case 0 : //In demux event Demux_Level=2; //Container Demux(Buffer+Buffer_Offset+2, (size_t)(Element_Size-2), ContentType_Header); break; case 1 : //In field { std::string Data_Raw((const char*)(Buffer+Buffer_Offset+2), (size_t)(Element_Size-2)); std::string Data_Base64(Base64::encode(Data_Raw)); Fill(Stream_Audio, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif //MEDIAINFO_DEMUX #else Skip_XX(Element_Size-Element_Offset, "AAC Data"); audio_stream_Count=false; //Unable to parse it #endif break; case 1 : //Parsing Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream); if (Stream[Stream_Audio].Parser) { Open_Buffer_Continue(Stream[Stream_Audio].Parser); Stream[Stream_Audio].Parser->Open_Buffer_Unsynch(); } else Skip_XX(Element_Size-Element_Offset, "Decoder config is missing"); 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) { std::string StringDataModified(StringData); if (!StringDataModified.empty() && StringDataModified[0]==__T('_')) StringDataModified.erase(StringDataModified.begin()); //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 (StringDataModified=="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 (StringDataModified=="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 (StringDataModified=="duration") meta_duration=Value*1000; else if (StringDataModified=="audiodatarate") {ToFill="BitRate"; StreamKind=Stream_Audio; ValueS.From_Number(Value*1000, 0);} else if (StringDataModified=="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 (StringDataModified=="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 (StringDataModified=="filesize") {meta_filesize=(int64u)Value;} else if (StringDataModified=="audiosize") {ToFill="StreamSize"; StreamKind=Stream_Audio; ValueS.From_Number(Value, 0); if (Value>File_Size) MetaData_NotTrustable=true;} else if (StringDataModified=="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 (StringDataModified=="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 (StringDataModified=="videocodecid") {; video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag else if (StringDataModified=="audiodelay") {ToFill="Delay"; StreamKind=Stream_Audio; if (Value>0) ValueS.From_Number(Value*1000, 0);} else if (StringDataModified=="audiosamplerate") {ToFill="SamplingRate"; StreamKind=Stream_Audio; if (Value>0) ValueS.From_Number(Value, 0);} else if (StringDataModified=="audiosamplesize") {ToFill="BitDepth"; StreamKind=Stream_Audio; if (Value>0) ValueS.From_Number(Value, 0);} else if (StringDataModified=="totalduration") {ToFill="Duration"; StreamKind=Stream_General; ValueS.From_Number(Value*1000, 0);} else if (StringDataModified=="totaldatarate") {ToFill="OverallBitRate"; StreamKind=Stream_General; ValueS.From_Number(Value*1000, 0);} else if (StringDataModified=="totalframes") {ToFill="FrameCount"; StreamKind=Stream_Video; ValueS.From_Number(Value*1000, 0);} else if (StringDataModified=="bytelength") {if (File_Size!=Value) MetaData_NotTrustable=true;} else if (!(StringDataModified=="datasize" || StringDataModified=="lasttimestamp" || StringDataModified=="lastkeyframetimestamp" || StringDataModified=="lastkeyframelocation" || StringDataModified=="canSeekToEnd" || StringDataModified=="keyframes_times" || StringDataModified=="keyframes_filepositions" || StringDataModified=="aacaot" || StringDataModified=="audiochannels" || StringDataModified=="audiocodecid" || StringDataModified=="avclevel" || StringDataModified=="avcprofile" || StringDataModified=="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, true); if (ToFill=="FrameRate") Fill(StreamKind, 0, "FrameRate_Mode", "CFR", Unlimited, true, true); } } break; case 0x01 : //UI8 { int8u Value; Get_B1 (Value, "Value"); std::string ToFill; if (StringDataModified=="haskeyframes") {} else if (StringDataModified=="hasKeyframes") {} else if (StringDataModified=="hasVideo") {} else if (StringDataModified=="stereo") {} else if (StringDataModified=="canSeekToEnd") {} else if (StringDataModified=="hasAudio") {} else if (StringDataModified=="hasmetadata") {} else if (StringDataModified=="hasMetadata") {} else if (StringDataModified=="hasCuePoints") {} else if (StringDataModified=="canseekontime") {} else {ToFill=StringData;} Element_Info1(Value); Fill(Stream_General, 0, ToFill.c_str(), Value?"Yes":"No", Unlimited, true, true); } 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 (StringDataModified=="creator") {ToFill=General_Encoded_Application;} else if (StringDataModified=="creationdate") {ToFill=General_Encoded_Date; Value.Date_From_String(Value.To_UTF8().c_str());} else if (StringDataModified=="encoder") {ToFill=General_Encoded_Application;} else if (StringDataModified=="Encoded_With") {ToFill=General_Encoded_Application;} else if (StringDataModified=="Encoded_By") {ToFill=General_Encoded_Application;} else if (StringDataModified=="metadatacreator") {ToFill=General_Tagged_Application;} else if (StringDataModified=="creation_time") {ToFill=General_Encoded_Date; Value.insert(0, __T("UTC "));} else if (StringDataModified=="sourcedata") {} else if (StringDataModified=="audiocodecid") {} else if (StringDataModified=="videocodecid") {} else if (!(StringDataModified=="major_brand" || StringDataModified=="minor_version" || StringDataModified=="compatible_brands")) 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, true); else if (!ToFillS.empty()) Fill(Stream_General, 0, StringData.c_str(), Value, true); } } 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, true); } } 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, true); } break; case 0x08 : //SCRIPTDATAVARIABLE[ECMAArrayLength] { int32u ECMAArrayLength; Get_B4 (ECMAArrayLength, "ECMAArrayLength"); Element_Info1(Ztring::ToZtring(ECMAArrayLength)+__T(" elements")); for (int32u Pos=0; Pos #include #include //--------------------------------------------------------------------------- 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 ""; } } //--------------------------------------------------------------------------- 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 ""; } } //--------------------------------------------------------------------------- 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, LF, Front: 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 (int64u 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) { if (!Text.empty()) Text+=", "; Text+="Side:"; } if (ChannelLabels&0x0400) Text+=" L"; if (ChannelLabels&0x0800) Text+=" R"; if ((ChannelLabels&0x0260)!=0x0000) { if (!Text.empty()) Text+=", "; Text+="Back:"; } if (ChannelLabels&0x0020) Text+=" L"; if (ChannelLabels&0x0200) Text+=" C"; if (ChannelLabels&0x0040) Text+=" R"; if ((ChannelLabels&0x0010)!=0x0000) { if (!Text.empty()) Text+=", "; Text+="LFE"; } if (ChannelLabels&0x000000C000000000LL) { if (!Text.empty()) Text+=", "; Text+="Front:"; } if (ChannelLabels&0x0000004000000000LL) Text+=" L"; if (ChannelLabels&0x0000008000000000LL) Text+=" R"; if (ChannelLabels&0x000000C000000000LL) Text+=" (Matrix)"; 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"; case 0x10000 : return "Discrete-0"; case 0x10001 : return "Discrete-1"; case 0x10002 : return "Discrete-2"; case 0x10003 : return "Discrete-3"; case 0x10004 : return "Discrete-4"; case 0x10005 : return "Discrete-5"; case 0x10006 : return "Discrete-6"; case 0x10007 : return "Discrete-7"; case 0x10008 : return "Discrete-8"; case 0x10009 : return "Discrete-9"; case 0x1000A : return "Discrete-10"; case 0x1000B : return "Discrete-11"; case 0x1000C : return "Discrete-12"; case 0x1000D : return "Discrete-13"; case 0x1000E : return "Discrete-14"; case 0x1000F : return "Discrete-15"; 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 "Y"; case 0x12 : return "YUV"; //sYUV default : return ""; } } //--------------------------------------------------------------------------- const char* Mpegv_colour_primaries(int8u colour_primaries); const char* Mpegv_transfer_characteristics(int8u transfer_characteristics); const char* Mpegv_matrix_coefficients(int8u matrix_coefficients); //--------------------------------------------------------------------------- // 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, bool AddCs=false, bool AddLrsRrs=false); extern std::string DTS_HD_SpeakerActivityMask2 (int16u SpeakerActivityMask, bool AddCs=false, bool AddLrsRrs=false); #endif //defined(MEDIAINFO_DTS_YES) //*************************************************************************** // Constants //*************************************************************************** //--------------------------------------------------------------------------- namespace Elements { const int64u bloc=0x626C6F63; const int64u cdat=0x63646174; const int64u cdt2=0x63647432; const int64u free=0x66726565; const int64u ftyp=0x66747970; const int64u ftyp_qt=0x71742020; const int64u ftyp_dash=0x64617368; 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_ainf=0x61696E66; 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_alis=0x616C6973; const int64u moov_trak_mdia_hdlr_clcp=0x636C6370; const int64u moov_trak_mdia_hdlr_data=0x64617461; const int64u moov_trak_mdia_hdlr_hint=0x68696E74; const int64u moov_trak_mdia_hdlr_MPEG=0x4D504547; const int64u moov_trak_mdia_hdlr_ocsm=0x6F63736D; const int64u moov_trak_mdia_hdlr_odsm=0x6F64736D; const int64u moov_trak_mdia_hdlr_sbtl=0x7362746C; const int64u moov_trak_mdia_hdlr_sdsm=0x7364736D; const int64u moov_trak_mdia_hdlr_soun=0x736F756E; const int64u moov_trak_mdia_hdlr_subt=0x73756274; const int64u moov_trak_mdia_hdlr_subp=0x73756270; const int64u moov_trak_mdia_hdlr_text=0x74657874; const int64u moov_trak_mdia_hdlr_twen=0x7477656E; const int64u moov_trak_mdia_hdlr_tmcd=0x746D6364; 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_gmhd_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_stpp=0x73747070; const int64u moov_trak_mdia_minf_stbl_stsd_stpp_btrt=0x62747274; 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_ACLR=0x41434C52; const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_APRG=0x41505247; const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_ARES=0x41524553; 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_colr_clcn=0x636C636E; const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_colr_nclc=0x6E636C63; const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_colr_prof=0x70726F66; 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_damr=0x64616D72; 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_dvc1=0x64766331; 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_hvcC=0x68766343; 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_sthd=0x73746864; 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_txas=0x74786173; const int64u moov_trak_tref=0x74726566; const int64u moov_trak_tref_dpnd=0x64706E64; const int64u moov_trak_tref_chap=0x63686170; const int64u moov_trak_tref_clcp=0x636C6370; const int64u moov_trak_tref_fall=0x66616C6C; const int64u moov_trak_tref_folw=0x666F6C77; const int64u moov_trak_tref_forc=0x666F7263; const int64u moov_trak_tref_hint=0x68696E74; const int64u moov_trak_tref_ipir=0x69706972; const int64u moov_trak_tref_mpod=0x6D706F64; const int64u moov_trak_tref_scpt=0x73637074; const int64u moov_trak_tref_ssrc=0x73737263; const int64u moov_trak_tref_sync=0x73796E63; const int64u moov_trak_tref_tmcd=0x746D6364; const int64u moov_trak_udta=0x75647461; 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_meta_uuid=0x75756964; 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 pdin=0x7064696E; 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 ""; } } //*************************************************************************** // Format //*************************************************************************** //--------------------------------------------------------------------------- void File_Mpeg4::Data_Parse() { //mdat if (IsParsing_mdat) { mdat_xxxx(); return; } //Padding if (!Element_Code && !Element_Size) return; //Parsing DATA_BEGIN ATOM(bloc) 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 ATOM(moov_ainf) 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(moov_trak_mdia_minf_gmhd_tcmi) 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 LIST(moov_trak_mdia_minf_stbl_stsd_stpp) ATOM_BEGIN ATOM(moov_trak_mdia_minf_stbl_stsd_stpp_btrt) ATOM_END 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_ACLR) ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_APRG) ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_ARES) 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_damr) 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_dvc1) 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_hvcC) 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_sthd) 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) ATOM(moov_trak_txas) LIST(moov_trak_tref) ATOM_BEGIN ATOM(moov_trak_tref_chap) ATOM(moov_trak_tref_clcp) ATOM(moov_trak_tref_dpnd) ATOM(moov_trak_tref_fall) ATOM(moov_trak_tref_folw) ATOM(moov_trak_tref_forc) ATOM(moov_trak_tref_ipir) ATOM(moov_trak_tref_hint) ATOM(moov_trak_tref_mpod) ATOM(moov_trak_tref_scpt) ATOM(moov_trak_tref_ssrc) ATOM(moov_trak_tref_sync) ATOM(moov_trak_tref_tmcd) ATOM_END LIST(moov_trak_udta) ATOM_DEFAULT_ALONE (moov_trak_udta_xxxx); 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(moov_udta_meta_uuid) 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(pdin) 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_SizeFrameInfo.DTS=FrameInfo.DTS; Streams[(int32u)Element_Code].Parsers[Pos]->FrameInfo.DUR=FrameInfo.DUR/(Element_Size/2); } #endif //MEDIAINFO_DEMUX while (Element_Offset+2<=Element_Size) { for (size_t Pos=0; Possecond.stco.push_back(File_Offset+Buffer_Offset); } //--------------------------------------------------------------------------- void File_Mpeg4::ftyp() { Element_Name("File Type"); if (Count_Get(Stream_General)) { Skip_XX(Element_Size, "Duplicate ftyp"); return; } //Parsing std::vector ftyps; int32u MajorBrandVersion; Get_C4 (MajorBrand, "MajorBrand"); ftyps.push_back(MajorBrand); Get_B4 (MajorBrandVersion, "MajorBrandVersion"); while (Element_OffsetFile_Names.size()==1)TestContinuousFileNames(1, __T("m4s")); break; 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); Ztring CodecID_String=Ztring().From_CC4(MajorBrand); if (MajorBrand==Elements::ftyp_qt) { ZtringList Version; Version.Separator_Set(0, __T(".")); Version.push_back(Ztring().From_CC2(MajorBrandVersion>>16)); Version.push_back(Ztring().From_CC1((int8u)(MajorBrandVersion>>8))); if (MajorBrandVersion&0xFF) Version.push_back(Ztring().From_CC1((int8u)MajorBrandVersion)); Fill(Stream_General, 0, General_CodecID_Version, Version.Read()); CodecID_String += __T(' '); CodecID_String += Version.Read(); } if (ftyps.size()>1) { ZtringList Compat; Compat.Separator_Set(0, __T("/")); for (size_t i=1; iFile_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 && File_Size!=(int64u)-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"); } //--------------------------------------------------------------------------- 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 (!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()->OffsetLastMdatPos) 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 #if MEDIAINFO_HASH if (!Hash || (!IsSecondPass && FirstMdatPossecond.stco.push_back(File_Offset+Buffer_Offset); } //--------------------------------------------------------------------------- void File_Mpeg4::mdat_xxxx() { if (!Element_IsComplete_Get()) { Element_WaitForMoreData(); return; } if (!IsSub) { if (Config->ParseSpeed>=1.0) Config->State_Set(((float)Buffer_TotalBytes)/File_Size); } stream &Stream_Temp=Streams[(int32u)Element_Code]; if (Stream_Temp.Parsers.empty()) { Skip_XX(Element_Size, "Unknown"); mdat_StreamJump(); return; } #if MEDIAINFO_DEMUX if (Stream_Temp.StreamKind!=Stream_Other && Stream_Temp.StreamKind!=Stream_Max) { //DTS Frame_Count_NotParsedIncluded=Stream_Temp.stts_FramePos; if (Stream_Temp.stts_Durations_PosDTS_Begin+(((int64u)stts_Duration->SampleDuration)*(Frame_Count_NotParsedIncluded-stts_Duration->Pos_Begin)); if (!Stream_Temp.edts.empty()) { int64s Delay=0; switch (Stream_Temp.edts.size()) { case 0 : break; case 1 : if (Stream_Temp.edts[0].Duration==Stream_Temp.tkhd_Duration && Stream_Temp.edts[0].Rate==0x00010000 && moov_mvhd_TimeScale) { Delay=-((int64s)Stream_Temp.edts[0].Delay); } break; case 2 : if (Stream_Temp.edts[0].Delay==(int32u)-1 && Stream_Temp.edts[0].Duration+Stream_Temp.edts[1].Duration==Stream_Temp.tkhd_Duration && Stream_Temp.edts[0].Rate==0x00010000 && Stream_Temp.edts[1].Rate==0x00010000 && moov_mvhd_TimeScale) { Delay=((int64s)Stream_Temp.edts[0].Duration)-Stream_Temp.edts[1].Delay; } break; default: break; //TODO: handle more complex Edit Lists } if (-Delay<(int64s)stts_Offset) stts_Offset+=Delay; else stts_Offset=0; } FrameInfo.DTS=TimeCode_DtsOffset+stts_Offset*1000000000/Stream_Temp.mdhd_TimeScale; FrameInfo.PTS=Stream_Temp.PtsDtsAreSame?FrameInfo.DTS:(int64u)-1; FrameInfo.DUR=((int64u)stts_Duration->SampleDuration)*1000000000/Stream_Temp.mdhd_TimeScale; Stream_Temp.stts_FramePos++; if (Stream_Temp.stts_FramePos>=stts_Duration->Pos_End) Stream_Temp.stts_Durations_Pos++; if (!Stream_Temp.stss.empty()) { Demux_random_access=false; for (size_t Pos=0; PosFrameInfo=FrameInfo; #endif //MEDIAINFO_DEMUX Open_Buffer_Continue(Stream_Temp.Parsers[Pos], Buffer+Buffer_Offset, (size_t)Element_Size); #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent && Config->Demux_Unpacketize_Get()) Stream_Temp.Demux_EventWasSent=true; #endif //MEDIAINFO_DEMUX Element_Show(); #if MEDIAINFO_DEMUX if (!Stream_Temp.IsFilled && Stream_Temp.Parsers[Pos]->Status[IsFilled]) { if (Stream_Temp.StreamKind==Stream_Other) //If this is a TimeCode track { if (((File_Mpeg4_TimeCode*)Stream_Temp.Parsers[Pos])->Pos!=(int32u)-1) { for (std::map::iterator StreamTemp=Streams.begin(); StreamTemp!=Streams.end(); ++StreamTemp) if (StreamTemp->second.TimeCode_TrackID==(int32u)Element_Code) { TimeCode_FrameOffset=((File_Mpeg4_TimeCode*)Stream_Temp.Parsers[Pos])->Pos; TimeCode_DtsOffset=float64_int64s(((float64)TimeCode_FrameOffset)*1000000000*Stream_Temp.TimeCode->FrameDuration/Stream_Temp.TimeCode->TimeScale); } } } Stream_Temp.IsFilled=true; if (Config->ParseSpeed<1 && !mdat_Pos.empty()) { bool File_Offset_Next_IsValid; int64u File_Offset_Next; if (mdat_Pos_Temp!=mdat_Pos_Max) { File_Offset_Next=mdat_Pos_Temp->Offset; File_Offset_Next_IsValid=true; } else { File_Offset_Next=(int64u)-1; File_Offset_Next_IsValid=false; } mdat_pos mdat_Pos_New; mdat_Pos_Max=mdat_Pos.empty()?NULL:(&mdat_Pos[0]+mdat_Pos.size()); if (!mdat_Pos.empty()) { for (mdat_Pos_Type* mdat_Pos_Item=&mdat_Pos[0]; mdat_Pos_ItemStreamID!=(int32u)Element_Code) mdat_Pos_New.push_back(*mdat_Pos_Item); } mdat_Pos=mdat_Pos_New; std::sort(mdat_Pos.begin(), mdat_Pos.end(), &mdat_pos_sort); mdat_Pos_Temp=mdat_Pos.empty()?NULL:&mdat_Pos[0]; mdat_Pos_Max=mdat_Pos_Temp+mdat_Pos.size(); if (File_Offset_Next_IsValid) for (; mdat_Pos_TempOffset>=File_Offset_Next) break; } else mdat_Pos_Temp=mdat_Pos_Max; } } #endif //MEDIAINFO_DEMUX //Multiple parsers if (Stream_Temp.Parsers.size()>1) { if (!Stream_Temp.Parsers[Pos]->Status[IsAccepted] && Stream_Temp.Parsers[Pos]->Status[IsFinished]) { delete *(Stream_Temp.Parsers.begin()+Pos); Stream_Temp.Parsers.erase(Stream_Temp.Parsers.begin()+Pos); Pos--; } else if (Stream_Temp.Parsers.size()>1 && Stream_Temp.Parsers[Pos]->Status[IsAccepted]) { File__Analyze* Parser=Stream_Temp.Parsers[Pos]; for (size_t Pos2=0; Pos2Offset; #if MEDIAINFO_DEMUX if (Config->ParseSpeed==1) { std::map::iterator StreamOffset_Jump_Temp=StreamOffset_Jump.find(ToJump); if (StreamOffset_Jump_Temp!=StreamOffset_Jump.end()) { ToJump=StreamOffset_Jump_Temp->second; if (!mdat_Pos.empty()) { mdat_Pos_Temp=&mdat_Pos[0]; while (mdat_Pos_TempOffset!=ToJump) mdat_Pos_Temp++; } else mdat_Pos_Temp=NULL; } } #endif // MEDIAINFO_DEMUX } if (ToJump>File_Size) ToJump=File_Size; if (ToJump!=File_Offset+Buffer_Offset+Element_Size) { if (!Status[IsAccepted]) Data_Accept("MPEG-4"); #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong() && ((IsSecondPass && mdat_Pos_NormalParsing) || FirstMoovPossecond.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; Possecond.mvex_trex_default_sample_duration; if (!default_sample_size_present) 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 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 if (moof_traf_base_data_offset!=(int64u)-1 || data_offset_present) 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; Possecond.stsz_StreamSize+=sample_size; Stream->second.stsz_Total.push_back(sample_size); if (Stream->second.stsz.size()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 #if MEDIAINFO_HASH if (!Hash || (!IsSecondPass && FirstMdatPos 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_Size8) { #if defined(MEDIAINFO_PROPERTYLIST_YES) File_PropertyList MI; Open_Buffer_Init(&MI); Open_Buffer_Continue(&MI, Buffer+Buffer_Offset+8, (size_t)(Element_Size-8)); Open_Buffer_Finalize(&MI); Merge(MI, Stream_General, 0, 0); #endif //defined(MEDIAINFO_PROPERTYLIST_YES) } else 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" || Parameter=="HDVideo" || Parameter=="iTunesU" || Parameter=="Podcast") { 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=="ContentType") { if (Value==__T("0")) Value=__T("Movie"); else if (Value==__T("1")) Value=__T("Music"); else if (Value==__T("2")) Value=__T("Audiobook"); else if (Value==__T("5")) Value=__T("Whacked Bookmark"); else if (Value==__T("6")) Value=__T("Music Video"); else if (Value==__T("9")) Value=__T("Short Film"); else if (Value==__T("10")) Value=__T("TV Show"); else if (Value==__T("11")) Value=__T("Booklet"); else if (Value==__T("14")) Value=__T("Ringtone"); else if (Value==__T("21")) Value=__T("Podcast"); else Value=__T("Unknown Type"); Fill(Stream_General, 0, General_ContentType, Value); } if (Parameter=="AppleStoreAccountType") { if (Value==__T("0")) Value=__T("iTunes"); else Value=__T("AOL"); Fill(Stream_General, 0, General_ServiceName, Value); } if (Parameter=="Rating") { if (Value==__T("0")) Value=__T("None"); else if (Value==__T("2")) Value=__T("Clean"); else Value=__T("Explicit"); } if (Parameter=="AppleStoreCountry") { if (Value==__T("143441")) Value=__T("United States"); else if (Value==__T("143442")) Value=__T("France"); else if (Value==__T("143443")) Value=__T("Germany"); else if (Value==__T("143444")) Value=__T("United Kingdom"); else if (Value==__T("143445")) Value=__T("Austria"); else if (Value==__T("143446")) Value=__T("Belgium"); else if (Value==__T("143447")) Value=__T("Finland"); else if (Value==__T("143448")) Value=__T("Greece"); else if (Value==__T("143449")) Value=__T("Ireland"); else if (Value==__T("143450")) Value=__T("Italy"); else if (Value==__T("143451")) Value=__T("Luxembourg"); else if (Value==__T("143452")) Value=__T("Netherlands"); else if (Value==__T("143453")) Value=__T("Portugal"); else if (Value==__T("143454")) Value=__T("Spain"); else if (Value==__T("143455")) Value=__T("Canada"); else if (Value==__T("143456")) Value=__T("Sweden"); else if (Value==__T("143457")) Value=__T("Norway"); else if (Value==__T("143458")) Value=__T("Denmark"); else if (Value==__T("143459")) Value=__T("Switzerland"); else if (Value==__T("143460")) Value=__T("Australia"); else if (Value==__T("143461")) Value=__T("New Zealand"); else if (Value==__T("143462")) Value=__T("Japan"); else Value=__T("Unknown Country"); } if (!Parameter.empty()) { Element_Info1(Parameter.c_str()); if (Value!=Retrieve(Stream_General, 0, Parameter.c_str())) Fill(Stream_General, 0, Parameter.c_str(), Value); } 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=Duration*0.99 && Streams[moov_trak_tkhd_TrackID].tkhd_Duration*0.99<=Duration*1.01 && TimeScale && moov_mvhd_TimeScale!=TimeScale && moov_mvhd_TimeScale) { float64 Ratio=((float64)TimeScale)/((float64)moov_mvhd_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)moov_mvhd_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; if (End>Element_Size) End=Element_Size; //Found one file having record_size = the size of the atom, header included 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=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_sthd() { NAME_VERSION_FLAG("Subtitle Media Header") FILLING_BEGIN(); if (StreamKind_Last!=Stream_Text) { Stream_Prepare(Stream_Text); Streams[moov_trak_tkhd_TrackID].StreamKind=Stream_Text; Streams[moov_trak_tkhd_TrackID].StreamPos=StreamPos_Last; } FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl() { Element_Name("Sample Table"); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl_co64() { NAME_VERSION_FLAG("Chunk offset"); int64u Offset; int32u Count; Get_B4 (Count, "Number of entries"); if (Count==0) return; std::vector &stco=Streams[moov_trak_tkhd_TrackID].stco; stco.resize(CountElement_Size) break; //Problem Offset=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=8; if (PosElement_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; PosElement_Size) break; //Problem Offset=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; if (PosElement_Size) break; //Problem sample_number=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; //Coherency testing (first frame is 0 or 1) if (sample_number==0 && Offset) { for (size_t Pos=0; PosElement_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_stpp() { Element_Name("Subtitle (stpp)"); //Parsing string NameSpace; Skip_B4( "Reserved"); Skip_B2( "Reserved"); Skip_B2( "Data reference index"); size_t Pos=(size_t)Element_Offset; while (PosIsChapter=Streams[moov_trak_tkhd_TrackID].IsChapter; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT #endif //MEDIAINFO_TIMEDTEXT_YES } FILLING_END(); } //--------------------------------------------------------------------------- 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"), StreamKind_Last, StreamPos_Last, InfoCodecID_Format_Mpeg4); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "text", Unlimited, true, true); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Timed Text", Unlimited, true, true); #ifdef MEDIAINFO_TIMEDTEXT_YES File_TimedText* Parser=new File_TimedText; int64u Elemen_Code_Save=Element_Code; Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier Open_Buffer_Init(Parser); Element_Code=Elemen_Code_Save; Parser->IsChapter=Streams[moov_trak_tkhd_TrackID].IsChapter; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT #endif //MEDIAINFO_TIMEDTEXT_YES FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_tmcd() { Element_Name("TimeCode"); //Parsing stream::timecode *tc=new stream::timecode(); int32u TimeCodeFlags; int8u NumberOfFrames; 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"); Get_B1 (NumberOfFrames, "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; if (StreamKind_Last!=Stream_Other) { Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_Type, "Time code"); Fill(Stream_Other, StreamPos_Last, Other_Format, "QuickTime TC"); Streams[moov_trak_tkhd_TrackID].StreamKind=Stream_Other; Streams[moov_trak_tkhd_TrackID].StreamPos=StreamPos_Last; } //Filling Streams[moov_trak_tkhd_TrackID].TimeCode=tc; //Preparing TimeCode parser File_Mpeg4_TimeCode* Parser=new File_Mpeg4_TimeCode; Open_Buffer_Init(Parser); mdat_Pos_ToParseInPriority_StreamIDs.push_back(moov_trak_tkhd_TrackID); Streams[moov_trak_tkhd_TrackID].IsPriorityStream=true; ((File_Mpeg4_TimeCode*)Parser)->NumberOfFrames=NumberOfFrames; //tc->FrameDuration?(((float64)tc->TimeScale)/tc->FrameDuration):0; ((File_Mpeg4_TimeCode*)Parser)->DropFrame=tc->DropFrame; ((File_Mpeg4_TimeCode*)Parser)->NegativeTimes=tc->NegativeTimes; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT FILLING_ELSE(); delete tc; //tc=NULL; 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_Other, StreamPos_Last, "Title", Value); FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_tx3g() { Element_Name("Text"); //Parsing bool tx3gallforced, tx3ghasforced; int32u Flags; Skip_B4( "Reserved"); Skip_B2( "Reserved"); Skip_B2( "Data reference index"); Get_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_Flags(Flags, 29, "vertical placement"); Get_Flags(Flags, 30, tx3ghasforced, "some samples are forced"); Get_Flags(Flags, 31, tx3gallforced, "all samples are forced"); 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"), StreamKind_Last, StreamPos_Last, InfoCodecID_Format_Mpeg4); Streams[moov_trak_tkhd_TrackID].HasForcedSamples = tx3ghasforced; Streams[moov_trak_tkhd_TrackID].AllForcedSamples = tx3gallforced; Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "tx3g", Unlimited, true, true); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Timed Text", Unlimited, true, true); #ifdef MEDIAINFO_TIMEDTEXT_YES File_TimedText* Parser=new File_TimedText; int64u Elemen_Code_Save=Element_Code; Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier Open_Buffer_Init(Parser); Element_Code=Elemen_Code_Save; Parser->IsChapter=Streams[moov_trak_tkhd_TrackID].IsChapter; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT #endif //MEDIAINFO_TIMEDTEXT_YES 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=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"); Get_B4 (Flags, "Flags"); Skip_B4( "Bytes per packet"); Skip_B4( "Frames per packet"); SampleRate=float64_int64s(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 //Bug found in one file: sample size is 16 with a 32-bit CodecID ("fl32") if (Element_Code==0x666C3332 && SampleSize==16) SampleSize=32; //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) { File_Aac* Parser=new File_Aac; Parser->AudioSpecificConfig_OutOfBand(SampleRate, 2); Parser->Mode=File_Aac::Mode_raw_data_block; Parser->FrameIsAlwaysComplete=true; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #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; #if MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].PtsDtsAreSame=true; #endif // MEDIAINFO_DEMUX //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)) { File_ChannelGrouping* Parser=new File_ChannelGrouping; if (StreamPos_Last%2 && !Streams[moov_trak_tkhd_TrackID-1].Parsers.empty()) { Parser->Channel_Pos=1; Parser->Common=((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID-1].Parsers[0])->Common; Parser->StreamID=moov_trak_tkhd_TrackID-1; Element_Code=moov_trak_tkhd_TrackID-1; } else { Parser->Channel_Pos=0; Streams[moov_trak_tkhd_TrackID].IsPcmMono=true; } Parser->Channel_Total=2; Parser->SamplingRate=(int16u)SampleRate; Parser->BitDepth=(int8u)SampleSize; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } //Specific cases #if defined(MEDIAINFO_SMPTEST0337_YES) if (Channels==2 && SampleSize<=32 && SampleRate==48000) //Some SMPTE ST 337 streams are hidden in PCM stream { File_SmpteSt0337* Parser=new File_SmpteSt0337; Parser->Container_Bits=(int8u)SampleSize; Parser->Endianness=(Flags&0x02)?'B':'L'; Parser->ShouldContinueParsing=true; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif //PCM parser File_Pcm* Parser=new File_Pcm; Parser->Channels=(int8u)Channels; Parser->SamplingRate=(int32u)SampleRate; Parser->BitDepth=(int8u)SampleSize; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX if (Version==2) { if (Flags&0x01) Parser->Endianness='F'; else { Parser->Endianness=(Flags&0x02)?'B':'L'; Parser->Sign=(Flags&0x04)?'S':'U'; } } Parser->Codec=Ztring().From_Local(Codec.c_str()); Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); Streams[moov_trak_tkhd_TrackID].IsPcm=true; #if MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].Demux_Level=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 File_Mpega* Parser=new File_Mpega; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif if (Element_Code==0x6F776D61) //"owma" { //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 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, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplingRate, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, BytesPerSec*8, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Resolution, 10, true); 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")) { File_Mpega* Parser=new File_Mpega; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif FILLING_END(); //Parsing if (Data_Size>0) { Element_Begin1("Codec Specific Data"); switch (CodecID) { case 0x0161 : //Parsing Skip_L4( "SamplesPerBlock"); Skip_L2( "EncodeOptions"); Skip_L4( "SuperBlockAlign"); break; default : Skip_XX(Data_Size, "Unknown"); } Element_End0(); } //Demux #if MEDIAINFO_DEMUX if (!((MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("AVC") && Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) || (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("HEVC") && Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()))) switch (Config->Demux_InitData_Get()) { case 0 : //In demux event Demux_Level=2; //Container Demux(Buffer+Buffer_Offset+Element_Offset-(18+Data_Size), (size_t)(18+Data_Size), ContentType_Header); break; case 1 : //In field { std::string Data_Raw((const char*)(Buffer+Buffer_Offset+Element_Offset-(18+Data_Size)), (size_t)(18+Data_Size)); std::string Data_Base64(Base64::encode(Data_Raw)); Fill(Stream_Audio, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif //MEDIAINFO_DEMUX } #if MEDIAINFO_DEMUX if (Streams[moov_trak_tkhd_TrackID].Parsers.empty() && Config_Demux) { File__Analyze* Parser=new File__Analyze; //Only for activating Demux Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif //MEDIAINFO_DEMUX for (size_t Pos=0; PosWithAppleHeader=true; Parser->AspectRatio=((float)16)/9; //TODO: this is hardcoded, must adapt it to the real video aspect ratio Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_TTML_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Text, InfoCodecID_Format_Mpeg4, CodecID, InfoCodecID_Format)==__T("TTML")) { //Creating the parser File_Ttml* Parser=new File_Ttml; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if MEDIAINFO_DEMUX if (Streams[moov_trak_tkhd_TrackID].Parsers.empty() && Config_Demux) { File__Analyze* Parser=new File__Analyze; //Only for activating Demux Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif //MEDIAINFO_DEMUX for (size_t Pos=0; Pos0x20 && Depth<0x40) { Depth-=0x20; IsGreyscale=true; } else if (Depth==1) IsGreyscale=true; else IsGreyscale=false; Get_B2 (ColorTableID, "Color table ID"); if (!IsGreyscale && (Depth>1 && Depth<=8) && !ColorTableID) { int32u ColorStart; int16u ColorEnd; Get_B4 (ColorStart, "Color Start"); Skip_B2( "Color Count"); Get_B2 (ColorEnd, "Color End"); for (int32u Color=ColorStart; Color<=ColorEnd; Color++) { Skip_B2( "Alpha"); Skip_B2( "Red"); Skip_B2( "Green"); Skip_B2( "Blue"); } } 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].Parsers.empty()) { #if defined(MEDIAINFO_DVDIF_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==__T("DV")) { File_DvDif* Parser=new File_DvDif; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_MXF_YES) if (Element_Code==0x6D78336E || Element_Code==0x6D783370 || Element_Code==0x6D78356E || Element_Code==0x6D783570) //mx3n, mx3p, mx5n, mx5p { File_Mxf* Parser=new File_Mxf; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); // Note: MXF parser is set first but MPEG Video parser is still active because some IMX files have no MXF header #if MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate #endif //MEDIAINFO_DEMUX } #endif #if defined(MEDIAINFO_AIC_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("AIC")) { File_Aic* Parser=new File_Aic; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #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")) { File_Avc* Parser=new File_Avc; Parser->FrameIsAlwaysComplete=true; #if MEDIAINFO_DEMUX if (Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) { Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_FFV1_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("FFV1")) { File_Ffv1* Parser=new File_Ffv1; Parser->Width=moov_trak_tkhd_Width; Parser->Height=moov_trak_tkhd_Height; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #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")) { File_H263* Parser=new File_H263; Parser->FrameIsAlwaysComplete=true; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_HEVC_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("HEVC")) { File_Hevc* Parser=new File_Hevc; Parser->FrameIsAlwaysComplete=true; #if MEDIAINFO_DEMUX if (Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()) { Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #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")) { File_Mpegv* Parser=new File_Mpegv; Parser->FrameIsAlwaysComplete=true; #if MEDIAINFO_ADVANCED Parser->InitDataNotRepeated_Optional=true; #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_DEMUX if (Streams[moov_trak_tkhd_TrackID].Demux_Level==4) //Intermediate { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_PRORES_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("ProRes")) { File_ProRes* Parser=new File_ProRes; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_VC1_YES) if (Element_Code!=0x76632D31 && MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==__T("VC-1")) // If "vc-1" CodecID, there is a dvc1 atom, not using the hack with Sequence Header direct search { File_Vc1* Parser=new File_Vc1; Parser->FrameIsAlwaysComplete=true; Open_Buffer_Init(Parser); Open_Buffer_Continue(Parser); Element_Offset=Element_Size; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT } #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")) { File_Vc3* Parser=new File_Vc3; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_JPEG_YES) if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==__T("JPEG")) { File_Jpeg* Parser=new File_Jpeg; Parser->StreamKind=Stream_Video; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #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")) { File_Mpeg4* Parser=new File_Mpeg4; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); #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].Parsers.empty() && Config_Demux) { File__Analyze* Parser=new File__Analyze; //Only for activating Demux Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); } #endif //MEDIAINFO_DEMUX for (size_t Pos=0; PosStatus[IsAccepted]) { 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].Parsers[Pos]); Element_Code=Elemen_Code_Save; mdat_MustParse=true; //Data is in MDAT } } //RGB(A) if (Codec=="raw " || Codec=="rle ") { if (IsGreyscale) { Fill(Stream_Video, StreamPos_Last, Video_ColorSpace, "Y", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_BitDepth, Depth); } else if (Depth==32) { Fill(Stream_Video, StreamPos_Last, Video_ColorSpace, "RGBA", Unlimited, true, true); Fill(Stream_Video, StreamPos_Last, Video_BitDepth, Depth/4); } else Fill(Stream_Video, StreamPos_Last, Video_BitDepth, Depth/3); } else if (Codec=="AVrp") Fill(Stream_Video, StreamPos_Last, Video_BitDepth, 10); //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_Offset1) { Skip_XX(Element_Size-Element_Offset, "Data not analyzed"); return; //Handling only the first description } else if (Version==1) { #ifdef MEDIAINFO_AVC_YES for (size_t Pos=0; PosFrameIsAlwaysComplete=true; #if MEDIAINFO_DEMUX Element_Code=moov_trak_tkhd_TrackID; if (Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) { Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Open_Buffer_Init(Parser); Parser->MustParse_SPS_PPS=true; Parser->MustSynchronize=false; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT //Demux #if MEDIAINFO_DEMUX if (!Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) 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); (*Stream_More)[Stream_Video][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif //MEDIAINFO_DEMUX //Parsing Open_Buffer_Continue(Parser); Parser->MustParse_SPS_PPS=false; 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 std::string ChannelDescription_Layout; int64u ChannelLabels=0; int32u ChannelLayoutTag, ChannelBitmap, NumberChannelDescriptions; bool ChannelLabels_Valid=true; Get_B4 (ChannelLayoutTag, "ChannelLayoutTag"); Get_B4 (ChannelBitmap, "ChannelBitmap"); Get_B4 (NumberChannelDescriptions, "NumberChannelDescriptions"); if (ChannelLayoutTag==0) //UseChannelDescriptions { for (int32u Pos=0; Pos1) return; //Handling only the first description FILLING_BEGIN(); if (ChannelLayoutTag==0) //UseChannelDescriptions { Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, ChannelDescription_Layout.c_str(), Unlimited, true, true); if (ChannelLabels_Valid) Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, Mpeg4_chan_ChannelDescription(ChannelLabels), true, true); else Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, ChannelDescription_Layout); } else if (ChannelLayoutTag==0x10000) //UseChannelBitmap { int8u Channels=0; for (size_t Bit=0; Bit<18; Bit++) if (ChannelBitmap&(1<0x10000) { //int16u Channels=ChannelLayoutTag&0x0000FFFF; int16u Ordering=(ChannelLayoutTag&0xFFFF0000)>>16; //Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels, 10, true); //Channel count from this atom should not be used as a primary source, it may be wrong 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(); if (apertureWidth_N && apertureWidth_D && apertureHeight_N && apertureHeight_D) { 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 int32u ColorParameterType; Get_C4 (ColorParameterType, "Color parameter type"); switch (ColorParameterType) { case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_colr_clcn: moov_trak_mdia_minf_stbl_stsd_xxxx_colr_nclc(true); break; case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_colr_nclc: moov_trak_mdia_minf_stbl_stsd_xxxx_colr_nclc(); break; case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_colr_prof: moov_trak_mdia_minf_stbl_stsd_xxxx_colr_prof(); break; default : Skip_XX(Element_Size-Element_Offset, "Unknown"); } } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_colr_nclc(bool LittleEndian) { //Parsing int16u colour_primaries, transfer_characteristics, matrix_coefficients; if (LittleEndian) Get_L2 (colour_primaries, "Primaries index"); else Get_B2 (colour_primaries, "Primaries index"); Param_Info1(Mpegv_colour_primaries((int8u)colour_primaries)); if (LittleEndian) Get_L2 (transfer_characteristics, "Transfer function index"); else Get_B2 (transfer_characteristics, "Transfer function index"); Param_Info1(Mpegv_transfer_characteristics((int8u)transfer_characteristics)); if (LittleEndian) Get_L2 (matrix_coefficients, "Matrix index"); else Get_B2 (matrix_coefficients, "Matrix index"); Param_Info1(Mpegv_matrix_coefficients((int8u)matrix_coefficients)); FILLING_BEGIN(); if (Retrieve(Stream_Video, StreamPos_Last, Video_colour_description_present).empty()) //Using only the first one met { Fill(Stream_Video, StreamPos_Last, Video_colour_description_present, "Yes"); Fill(Stream_Video, StreamPos_Last, Video_colour_primaries, Mpegv_colour_primaries((int8u)colour_primaries)); Fill(Stream_Video, StreamPos_Last, Video_transfer_characteristics, Mpegv_transfer_characteristics((int8u)transfer_characteristics)); Fill(Stream_Video, StreamPos_Last, Video_matrix_coefficients, Mpegv_matrix_coefficients((int8u)matrix_coefficients)); } FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_colr_prof() { //Parsing Skip_XX(Element_Size-Element_Offset, "ICC profile"); //TODO: parse ICC profile } //--------------------------------------------------------------------------- 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("AC3SpecificBox"); 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].Parsers.empty()) { File_Ac3* Parser=new File_Ac3; Open_Buffer_Init(Parser); Parser->Frame_Count_Valid=2; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); 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].Parsers.empty()) { File_Ac3* Parser=new File_Ac3; Open_Buffer_Init(Parser); Parser->MustParse_dac3=true; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT //Parsing Open_Buffer_Continue(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_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_dec3() { Element_Name("EAC3SpecificBox"); 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].Parsers.empty()) { File_Ac3* Parser=new File_Ac3; Open_Buffer_Init(Parser); Parser->Frame_Count_Valid=2; Parser->MustParse_dec3=true; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT //Parsing Open_Buffer_Continue(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() { Element_Name("DTSSpecificBox"); 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 } //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(); 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_dvc1() { Element_Name("VC1SpecificBox"); // Parsing int32u hrd_buffer, hrd_rate, framerate=0; int8u profile, level, frmrtq_pp, bitrtq_pp, dquant, vtransform, overlap, syncmarker, rangered, maxbframes, quantizer, finterpflag, no_interlace, no_multiple_seq, no_multiple_entry, no_slice_code, no_bframe; bool cbr, loopfilter, multires, fastuvmc, extended_mv; BS_Begin(); Get_S1 (4, profile, "Profile"); Get_S1 (3, level, "Level"); Skip_SB( "reserved"); BS_End(); switch(profile) { case 0 : // Simple Profile case 4 : // Main Profile BS_Begin(); Get_S1 (3, level, "Level"); // should be the same as above Get_SB (cbr, "CBR"); // should be equal to 1 if CBR Mode, 0 otherwhise Skip_S1(4, "Reserved"); // should be set to 0 BS_End(); Get_B3 (hrd_buffer, "HRD_Buffer"); // Buffer Size of Hypothetical Reference Decoder in ms Get_B4 (hrd_rate, "HRD_Rate"); // Peak Transmisson Rate of the Hypothetical Reference Decoder in bps Get_B4 (framerate, "FrameRate"); // Rounded FPS of the track BS_Begin(); Get_S1 (4, profile, "Profile"); // should be the same as above Get_S1 (3, frmrtq_pp, "Frmrtq_postproc"); Get_S1 (5, bitrtq_pp, "Bitrtq_postproc"); Get_SB (loopfilter, "Loopfilter"); Skip_SB( "Reserved"); // should be set to 0 Get_SB (multires, "MultiRes"); Skip_SB( "Reserved"); // should be set to 1 Get_SB (fastuvmc, "Fastuvmc"); Get_SB (extended_mv, "Extended_mv"); Get_S1 (2, dquant, "Dquant"); Get_S1 (1, vtransform, "Vtransform"); Skip_SB( "Reserved"); // should be set to 0 Get_S1 (1, overlap, "Overlap"); Get_S1 (1, syncmarker, "Syncmarker"); Get_S1 (1, rangered, "Rangered"); Get_S1 (3, maxbframes, "MaxBFrames"); // should be equal to 0 with SP Get_S1 (2, quantizer, "Quantizer"); Get_S1 (1, finterpflag, "Finterpflag"); Skip_SB( "Reserved"); // should be set to 1 BS_End(); break; case 12 : // Advanced Profile BS_Begin(); Get_S1 (3, level, "Level"); // should be the same as above Get_SB (cbr, "CBR"); // should be equal to 1 if CBR Mode, 0 otherwhise Skip_S1(6, "Reserved"); // should be set to 0 Get_S1 (1, no_interlace, "No Interlace"); // should be set to 0 for Interlaced Content Get_S1 (1, no_multiple_seq, "No Multiple Sequence"); Get_S1 (1, no_multiple_entry, "No Multiple Entry"); Get_S1 (1, no_slice_code, "No Slice Code"); Get_S1 (1, no_bframe, "No BFrame"); Skip_SB( "Reserved"); BS_End(); Get_B4 (framerate, "FrameRate"); Element_Begin1("Sequence HDR"); #if defined(MEDIAINFO_VC1_YES) File_Vc1* Parser=new File_Vc1; Parser->FrameIsAlwaysComplete=true; Open_Buffer_Init(Parser); Open_Buffer_Continue(Parser); Element_Offset=Element_Size; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT*/ #else //defined(MEDIAINFO_VC1_YES) Skip_XX(Element_Size - Element_Offset, "VC-1 data"); #endif //defined(MEDIAINFO_VC1_YES) Element_End0(); break; } FILLING_BEGIN(); #if defined(MEDIAINFO_VC1_YES) Ztring Profile, Level; switch (profile) { case 0 : Profile=__T("Simple"); break; case 4 : Profile=__T("Main"); break; case 12 : Profile=__T("Advanced"); break; default : Profile=__T(""); } Profile+=__T("@"); if (profile == 0) // Simple Profile { switch (level) { case 0 : Level=__T("Low"); break; case 2 : Level=__T("Medium"); break; default : Level=__T(""); } } else if (profile == 4) // Main Profile { switch (level) { case 0 : Level=__T("Low"); break; case 2 : Level=__T("Medium"); break; case 4 : Level=__T("High"); break; default : Level=__T(""); } } else if (profile == 12) // Advanced Profile { switch (level) { case 0 : Level=__T("L0"); break; case 1 : Level=__T("L1"); break; case 2 : Level=__T("L2"); break; case 3 : Level=__T("L3"); break; case 4 : Level=__T("L4"); break; default : Level=__T(""); } } Profile+=Level; Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, Profile); Fill(Stream_Video, StreamPos_Last, Video_Codec_Profile, Profile); #endif //defined(MEDIAINFO_VC1_YES) if (framerate && framerate!=(int32u)-1) Fill(StreamKind_Last, StreamPos_Last, Video_FrameRate, framerate, 3); FILLING_END(); } //--------------------------------------------------------------------------- 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].Parsers.size()==1 && !Retrieve(StreamKind_Last, StreamPos_Last, "Encryption").empty()) { Finish(Streams[moov_trak_tkhd_TrackID].Parsers[0]); } FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_fiel() { //Source: http://developer.apple.com/quicktime/icefloe/dispatch019.html#fiel //Source: QuickTimeFileFormat2011.pdf: // 1 – T is displayed earliest, T is stored first in the file. // 6 – B is displayed earliest, B is stored first in the file. // 9 – B is displayed earliest, T is stored first in the file. //14 – T is displayed earliest, B is stored first in the file. 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 : // T is displayed earliest, T is stored first in the file. case 9 : // B is displayed earliest, T is stored first in the file. Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, "TFF", Unlimited, true, true); break; case 6 : // B is displayed earliest, B is stored first in the file. case 14 : // T is displayed earliest, B is stored first in the file. Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, "BFF", Unlimited, true, true); break; default : ; } // Priorizing https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG10-THE__FIEL__IMAGEDESCRIPTION_EXTENSION__FIELD_FRAME_INFORMATION /* switch(detail) { case 9 : // B is displayed earliest, T is stored first in the file. case 14 : // T is displayed earliest, B is stored first in the file. Streams[moov_trak_tkhd_TrackID].ScanOrder_StoredDisplayedInverted=true; break; default : ; } */ switch (detail) { case 1 : // Separated fields, TFF case 6 : // Separated fields, BFF Fill(Stream_Video, StreamPos_Last, Video_ScanType_StoreMethod_FieldsPerBlock, 2, 10, true); Fill(Stream_Video, StreamPos_Last, Video_ScanType_StoreMethod, "SeparatedFields", Unlimited, true, true); break; case 9 : // Interleaved fields, TFF case 14 : // Interleaved fields, BFF Fill(Stream_Video, StreamPos_Last, Video_ScanType_StoreMethod, "InterleavedFields", Unlimited, true, true); break; default : ; } #ifdef MEDIAINFO_JPEG_YES if (Retrieve(Stream_Video, StreamPos_Last, Video_Format)==__T("JPEG") && Streams[moov_trak_tkhd_TrackID].Parsers.size()==1) ((File_Jpeg*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Interlaced=true; #endif //MEDIAINFO_JPEG_YES 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); #if defined(MEDIAINFO_MPEGV_YES) File_Mpegv* Parser=new File_Mpegv; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); //Re-init int64u Elemen_Code_Save=Element_Code; Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier Open_Buffer_Init(Parser); Element_Code=Elemen_Code_Save; mdat_MustParse=true; //Data is in MDAT Open_Buffer_Continue(Parser); #endif //defined(MEDIAINFO_MPEGV_YES) //TODO: demux is not done in this case (2 possibilities: MXF wrapped and it is useless, not MXF wrapped and we may need it but up to now we saw only data in this atom redundant with the raw stream data) return; } //Demux #if MEDIAINFO_DEMUX Demux_Level=2; //Container Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream); #endif //MEDIAINFO_DEMUX //Parsing for (size_t Pos=0; PosFrameIsAlwaysComplete=true; #if MEDIAINFO_DEMUX Element_Code=moov_trak_tkhd_TrackID; if (Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()) { Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Open_Buffer_Init(Parser); Parser->MustParse_VPS_SPS_PPS=true; Parser->MustSynchronize=false; Streams[moov_trak_tkhd_TrackID].Parsers.push_back(Parser); mdat_MustParse=true; //Data is in MDAT //Demux #if MEDIAINFO_DEMUX if (!Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()) 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); (*Stream_More)[Stream_Video][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif //MEDIAINFO_DEMUX //Parsing Open_Buffer_Continue(Parser); Parser->SizedBlocks=true; //Now this is SizeBlocks #else Skip_XX(Element_Size, "HEVC Data"); #endif } //--------------------------------------------------------------------------- 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 defined(MEDIAINFO_PCM_YES) if (Streams[moov_trak_tkhd_TrackID].IsPcm) { if (Streams[moov_trak_tkhd_TrackID].Parsers.size()==1) ((File_Pcm*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Endianness=Endianness?'L':'B'; if (Streams[moov_trak_tkhd_TrackID].Parsers.size()==2) { ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Endianness=Endianness?'L':'B'; ((File_Pcm*)Streams[moov_trak_tkhd_TrackID].Parsers[1])->Endianness=Endianness?'L':'B'; } } #endif //defined(MEDIAINFO_PCM_YES) 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(); Ztring OldFormat=Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID); Ztring NewFormat=Ztring::ToZtring(CodecMS, 16); if (OldFormat!=NewFormat) { Clear(Stream_Audio, StreamPos_Last, Audio_CodecID); CodecID_Fill(NewFormat, 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" { Ztring OldFormat=Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID); Ztring NewFormat=Ztring().From_CC4(Codec); if (OldFormat!=NewFormat) { Clear(Stream_Audio, StreamPos_Last, Audio_CodecID); CodecID_Fill(NewFormat, 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; PosElement_Size) break; //Problem sample_number=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; //Coherency testing (first frame is 0 or 1) if (sample_number==0 && Offset) { for (size_t Pos=0; Pos0) { //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*Multipliersecond.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; /* if (FieldSize==4) BS_Begin(); //Too much slow */ for (int32u Pos=0; PosElement_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 (Possecond.stsz.push_back(Size); } /* if (FieldSize==4) BS_End(); //Too much slow */ } } //--------------------------------------------------------------------------- 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 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].Parsers[0] && ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Mpeg4_stts==NULL) ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->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; Possecond.stts_FrameCount-SampleCount; DV_stts_Part.Pos_End=Stream->second.stts_FrameCount; DV_stts_Part.Duration=SampleDuration; ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->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].Parsers[0])->Mpeg4_stts->size(); Pos++) { if (((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Mpeg4_stts->at(Pos).Duration==Duration_FrameCount_Max_Duration) { ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Mpeg4_stts->erase(((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Mpeg4_stts->begin()+Pos); Pos--; } } if (((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Mpeg4_stts->empty()) {delete ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->Mpeg4_stts; ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parsers[0])->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.SampleDurationsecond.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; if (Stts.SampleDuration<0x80000000) Stream->second.stts_Duration+=Stts.SampleCount*Stts.SampleDuration; else Stream->second.stts_Duration-=Stts.SampleCount*(((int32u)-1)-Stts.SampleDuration+1); //Negative value #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_BFP4(16, "cleanApertureWidth"); Skip_BFP4(16, "cleanApertureHeight"); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_tapt_prof() { NAME_VERSION_FLAG("Production Aperture Dimensions"); //Parsing Skip_BFP4(16, "productionApertureWidth"); Skip_BFP4(16, "productionApertureHeight"); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_tapt_enof() { NAME_VERSION_FLAG("Encoded Pixels Dimensions"); //Parsing Skip_BFP4(16, "encodedApertureWidth"); Skip_BFP4(16, "encodedApertureHeight"); } //--------------------------------------------------------------------------- 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, Alternate_Group; bool Enabled; Get_Flags(Flags, 0, Enabled, "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"); if (moov_mvhd_TimeScale) {Param_Info2(Duration*1000/moov_mvhd_TimeScale, " ms"); Element_Info2(Duration*1000/moov_mvhd_TimeScale, " ms");} Skip_B4( "Reserved"); Skip_B4( "Reserved"); Skip_B2( "Layer"); Get_B2(Alternate_Group, "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::iterator Temp=Streams.find((int32u)-1); if (Temp!=Streams.end()) { Streams[moov_trak_tkhd_TrackID]=Temp->second; Temp->second.Parsers.clear(); //They are a copy, we don't want that the destructor deletes the Parser Streams.erase(Temp); } Streams[moov_trak_tkhd_TrackID].IsEnabled = Enabled; if (Alternate_Group) Fill(StreamKind_Last, StreamPos_Last, "AlternateGroup", Alternate_Group); if (moov_mvhd_TimeScale) Fill(StreamKind_Last, StreamPos_Last, "Duration", float64_int64s(((float64)Duration)*1000/moov_mvhd_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_txas() { Element_Name("Track Exclude"); FILLING_BEGIN(); Streams[moov_trak_tkhd_TrackID].IsExcluded=true; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_tref() { Element_Name("Track Reference"); } //--------------------------------------------------------------------------- void File_Mpeg4::moov_trak_tref_chap() { Element_Name("Chapters List"); //Parsing int32u TrackID; while (Element_OffsetElement_Size) { Size32=0; Peek_B2(Size16); if (4+(int64u)Size16>Element_Size) IsText=false; } } if (!IsText) { Skip_XX(Element_Size, "Unknown"); return; } while(Element_OffsetFile_IsReferenced_Get() || ReferenceFiles==NULL) return; ReferenceFiles->ParseReferences(); // Detection of IMF CPL bool IsImf=false; for (size_t StreamKind=Stream_General+1; StreamKindFile_IsReferenced_Get() || ReferenceFiles==NULL) return 0; return ReferenceFiles->Seek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_DcpPkl::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; XMLElement* PackingList=document.FirstChildElement("PackingList"); if (!PackingList) { Reject("DcpPkl"); return false; } const char* Attribute=PackingList->Attribute("xmlns"); if (!Attribute) { Reject("DcpPkl"); return false; } if (strcmp(Attribute, "http://www.digicine.com/PROTO-ASDCP-PKL-20040311#") && strcmp(Attribute, "http://www.smpte-ra.org/schemas/429-8/2007/PKL")) { Reject("DcpPkl"); return false; } Accept("DcpPkl"); Fill(Stream_General, 0, General_Format, "DCP PKL"); Config->File_ID_OnlyRoot_Set(false); //Parsing main elements for (XMLElement* PackingList_Item=PackingList->FirstChildElement(); PackingList_Item; PackingList_Item=PackingList_Item->NextSiblingElement()) { //AssetList if (!strcmp(PackingList_Item->Value(), "AssetList")) { for (XMLElement* AssetList_Item=PackingList_Item->FirstChildElement(); AssetList_Item; AssetList_Item=AssetList_Item->NextSiblingElement()) { //Asset if (!strcmp(AssetList_Item->Value(), "Asset")) { stream Stream; for (XMLElement* File_Item=AssetList_Item->FirstChildElement(); File_Item; File_Item=File_Item->NextSiblingElement()) { //AnnotationText if (!strcmp(File_Item->Value(), "AnnotationText")) Stream.AnnotationText=File_Item->GetText(); //Id if (!strcmp(File_Item->Value(), "Id")) Stream.Id=File_Item->GetText(); //OriginalFileName if (!strcmp(File_Item->Value(), "OriginalFileName")) Stream.OriginalFileName=File_Item->GetText(); //Type if (!strcmp(File_Item->Value(), "Type")) { if (!strcmp(File_Item->GetText(), "application/x-smpte-mxf;asdcpKind=Picture")) Stream.StreamKind=Stream_Video; else if (!strcmp(File_Item->GetText(), "application/x-smpte-mxf;asdcpKind=Sound")) Stream.StreamKind=Stream_Audio; else if (!strcmp(File_Item->GetText(), "text/xml") || !strcmp(File_Item->GetText(), "text/xml;asdcpKind=CPL")) Stream.StreamKind=(stream_t)(Stream_Max+1); // Means CPL else Stream.StreamKind=Stream_Other; } } Streams.push_back(Stream); } } } } Element_Offset=File_Size; //Merging with Assetmap if (!Config->File_IsReferenced_Get()) { FileName Directory(File_Name); Ztring Assetmap_FileName=Directory.Path_Get()+PathSeparator+__T("ASSETMAP.xml"); bool IsOk=false; if (File::Exists(Assetmap_FileName)) IsOk=true; else { Assetmap_FileName.resize(Assetmap_FileName.size()-4); //Old fashion, without ".xml" if (File::Exists(Assetmap_FileName)) IsOk=true; } if (IsOk) { 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()); MI.Option(__T("File_IsReferenced"), __T("1")); size_t MiOpenResult=MI.Open(Assetmap_FileName); 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("DCP AM") || MI.Get(Stream_General, 0, General_Format)==__T("IMF AM"))) { MergeFromAm(((File_DcpPkl*)MI.Info)->Streams); } } } //Creating the playlist if (!Config->File_IsReferenced_Get()) { ReferenceFiles=new File__ReferenceFilesHelper(this, Config); for (File_DcpPkl::streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) if (Stream->StreamKind==(stream_t)(Stream_Max+1) && Stream->ChunkList.size()==1) // Means CPL { sequence* Sequence=new sequence; Sequence->FileNames.push_back(Ztring().From_UTF8(Stream->ChunkList[0].Path)); Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } ReferenceFiles->FilesForStorage=true; } //All should be OK... return true; } //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpPkl::MergeFromAm (File_DcpPkl::streams &StreamsToMerge) { for (File_DcpPkl::streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { for (File_DcpPkl::streams::iterator StreamToMerge=StreamsToMerge.begin(); StreamToMerge!=StreamsToMerge.end(); ++StreamToMerge) if (StreamToMerge->Id==Stream->Id) *Stream=*StreamToMerge; } } } //NameSpace #endif //MEDIAINFO_DCP_YES MediaInfoLib/Source/MediaInfo/Multiple/File_P2_Clip.h0000664000000000000000000000312112652076434021274 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about P2 Clip files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_P2_ClipH #define MediaInfo_File_P2_ClipH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper_Sequence.h0000664000000000000000000000614012652076434026060 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__ReferenceFilesHelper_SequenceH #define File__ReferenceFilesHelper_SequenceH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File__ReferenceFilesHelper_Resource.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper_Sequence_Common.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { class resource; typedef std::vector resources; class rfhs_common; //*************************************************************************** // Class sequence //*************************************************************************** class sequence { public: //Constructor/Desctructor sequence(); ~sequence(); //In void AddFileName(const Ztring& FileName, size_t Pos=(size_t)-1); void AddResource(resource* NewResource, size_t Pos=(size_t)-1); void UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName); stream_t StreamKind; size_t StreamPos; int64u StreamID; size_t MenuPos; bool Enabled; bool IsMain; std::map Infos; void FrameRate_Set(float64 NewFrameRate); //Out bool IsFinished() {return !Enabled || Resources_Current>=Resources.size();} size_t State; bool IsCircular; #if MEDIAINFO_ADVANCED || MEDIAINFO_HASH bool List_Compute_Done; #endif //MEDIAINFO_ADVANCED || MEDIAINFO_HASH //Config rfh_common* Package; #if MEDIAINFO_NEXTPACKET && MEDIAINFO_IBIUSAGE ibi::stream IbiStream; #endif //MEDIAINFO_NEXTPACKET && MEDIAINFO_IBIUSAGE resources Resources; size_t Resources_Current; public: rfhs_common* Common; public: ZtringList FileNames; Ztring Source; //Source file name (relative path) float64 FrameRate; int64u Delay; int64u FileSize; bool FileSize_IsPresent; //TODO: merge with FileSize after regression tests MediaInfo_Internal* MI; std::bitset<32> Status; }; typedef std::vector sequences; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Skm.h0000664000000000000000000000345612652076434020611 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Xdcam_Clip.cpp0000664000000000000000000001505712652076434022415 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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"); if (Element) Fill(Stream_General, 0, General_Recorded_Date, Element->Attribute("value")); //LastUpdate 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; MI.Option(__T("File_IsReferenced"), __T("1")); 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) { const char* manufacturer=Element->Attribute("manufacturer"); if (manufacturer) { string manufacturer_modelName(manufacturer); const char* modelName=Element->Attribute("modelName"); if (modelName) { manufacturer_modelName+=' '; manufacturer_modelName+=modelName; } Fill(Stream_General, 0, General_Encoded_Application, manufacturer_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; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_XDCAM_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Gxf_TimeCode.h0000664000000000000000000000345212652076434022350 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 #endif //defined(MEDIAINFO_ANCILLARY_YES) #include "MediaInfo/TimeCode.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Gxf_TimeCode //*************************************************************************** class File_Gxf_TimeCode : public File__Analyze { public : //In int32u FrameRate_Code; int32u FieldsPerFrame_Code; bool IsAtc; // SMPTE ST 12-2 //Out int64u TimeCode_FirstFrame_ms; string TimeCode_FirstFrame; string Settings; //Constructor/Destructor File_Gxf_TimeCode(); ~File_Gxf_TimeCode(); private : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue (); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_DcpCpl.h0000664000000000000000000000335512652076434021222 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DCP/IMF Composition Playlist files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DcpCplH #define MediaInfo_File_DcpCplH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include "MediaInfo/Multiple/File_DcpPkl.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; //*************************************************************************** // Class File_DcpCpl //*************************************************************************** class File_DcpCpl : public File__Analyze { public : //Constructor/Destructor File_DcpCpl(); ~File_DcpCpl(); 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(); //PKL size_t PKL_Pos; void MergeFromAm (File_DcpPkl::streams &StreamsToMerge); //Temp File__ReferenceFilesHelper* ReferenceFiles; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_MpegTs.h0000664000000000000000000001214512652076434021251 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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" //--------------------------------------------------------------------------- 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 #ifdef MEDIAINFO_ARIBSTDB24B37_YES bool FromAribStdB24B37; #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 (); #if MEDIAINFO_ADVANCED2 void Read_Buffer_SegmentChange(); #endif //MEDIAINFO_ADVANCED2 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 MpegTs_ScanUpTo; 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(); #if MEDIAINFO_ADVANCED float64 Config_VbrDetection_Delta; int64u Config_VbrDetection_Occurences; bool Config_VbrDetection_GiveUp; #endif // MEDIAINFO_ADVANCED #endif //MEDIAINFO_MPEGTS_PCR_YES void Streams_Update_Duration_End(); void SetAllToPES(); void transport_private_data(int8u transport_private_data_length); #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 Output_Buffer_Get_Pos; #endif //MEDIAINFO_DUPLICATE //Config bool Config_Trace_TimeSection_OnlyFirstOccurrence; bool TimeSection_FirstOccurrenceParsed; #if MEDIAINFO_SEEK std::map Unsynch_Frame_Counts; int64u Seek_Value; int64u Seek_Value_Maximal; int64u Seek_ID; size_t InfiniteLoop_Detect; bool Duration_Detected; #endif //MEDIAINFO_SEEK }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Pmp.h0000664000000000000000000000243212652076434020604 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about PMP files // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_PmpH #define MediaInfo_File_PmpH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Tag/File__Tags.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File_Pmp //*************************************************************************** class File_Pmp : public File__Analyze { public : //In int64u Frame_Count_Valid; private : //Buffer bool FileHeader_Begin(); void FileHeader_Parse(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp0000664000000000000000000033147312652076434024575 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include #include #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events_Internal.h" #include "MediaInfo/MediaInfo_Config_PerPackage.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_AES #include "base64.h" #endif //MEDIAINFO_AES using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File__ReferenceFilesHelper::File__ReferenceFilesHelper(File__Analyze* MI_, MediaInfo_Config_MediaInfo* Config_) { //In TestContinuousFileNames=false; ContainerHasNoId=false; ID_Max=0; //Private Sequences_Current=0; MI=MI_; Config=Config_; Init_Done=false; FrameRate=0; Duration=0; #if MEDIAINFO_DEMUX Demux_Interleave=false; DTS_Minimal=(int64u)-1; #endif //MEDIAINFO_DEMUX #if MEDIAINFO_EVENTS StreamID_Previous=(int64u)-1; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Offset_Video_DTS=0; #endif //MEDIAINFO_DEMUX //Private #if MEDIAINFO_DEMUX Common=new rfh_common(&Demux_Interleave, &DTS_Minimal); #else //MEDIAINFO_DEMUX Common=new rfh_common(); #endif //MEDIAINFO_DEMUX Common->ReferenceFilesHelper=this; Common->MI=MI; Common->Config=Config; //Temp FilesForStorage=false; HasMainFile=false; HasMainFile_Filled=false; #if MEDIAINFO_NEXTPACKET DTS_Interval=(int64u)-1; #endif //MEDIAINFO_NEXTPACKET } //--------------------------------------------------------------------------- File__ReferenceFilesHelper::~File__ReferenceFilesHelper() { size_t Sequences_Size=Sequences.size(); for (size_t Sequences_Pos=0; Sequences_PosStreamIDStreamID);} bool File__ReferenceFilesHelper_Algo2 (const sequence* Ref1, const sequence* Ref2) { return (Ref1->StreamPosStreamPos);} bool File__ReferenceFilesHelper_Algo3 (const sequence* Ref1, const sequence* Ref2) { return (Ref1->StreamKindStreamKind);} void File__ReferenceFilesHelper_InfoFromFileName (sequences &Sequences) { ZtringListList List; vector Iterators; for (size_t Sequences_Pos=0; Sequences_PosStreamKind==Stream_Audio && !Sequences[Sequences_Pos]->FileNames.empty()) { Ztring Name=Sequences[Sequences_Pos]->FileNames[0]; while (Name.FindAndReplace(__T("51 "), Ztring())); while (Name.FindAndReplace(__T("_"), __T(" "))); while (Name.FindAndReplace(__T("."), __T(" "))); while (Name.FindAndReplace(__T(" "), __T(" "))); size_t PathSeparator_Pos=Name.rfind(PathSeparator); if (PathSeparator_Pos!=(size_t)-1) Name.erase(0, PathSeparator_Pos+1); //Removing extension if (Name.size()>4 && Name.rfind(__T('.'))==Name.size()) Name.resize(Name.size()-4); List2.Write(Name); for (size_t Pos=0; Pos=List[Pos].size()) break; //Maybe begin of title const Ztring &Test=List[Pos][List[Pos].size()-1-Pos2]; //ChannelLayout if (ChannelLayout_Pos==(size_t)-1 && Test!=__T("l") && Test!=__T("r") && Test!=__T("lt") && Test!=__T("rt") && Test!=__T("c") && Test!=__T("lf") && Test!=__T("lfe") && Test!=__T("sub") && Test!=__T("ls") && Test!=__T("rs") && Test!=__T("b") && Test!=__T("mono")) IsChannelLayout=false; //Language if (Language_Pos==(size_t)-1 && Test!=__T("ara") && Test!=__T("deu") && Test!=__T("eng") && Test!=__T("fra") && Test!=__T("fre") && Test!=__T("ita") && Test!=__T("jpn") && Test!=__T("rus") && Test!=__T("spa")) IsLanguage=false; } if (IsChannelLayout && ChannelLayout_Pos==(size_t)-1) ChannelLayout_Pos=Pos2; if (IsLanguage && Language_Pos==(size_t)-1) Language_Pos=Pos2; if (ChannelLayout_Pos!=(size_t)-1 && Language_Pos!=(size_t)-1) break; } //ChannelLayout if (ChannelLayout_Pos!=(size_t)-1) for (size_t Pos=0; PosInfos["ChannelPositions"]=ChannelPositions; Sequences[Iterators[Pos]]->Infos["ChannelPositions/String2"]=ChannelPositions2; Sequences[Iterators[Pos]]->Infos["ChannelLayout"]=ChannelLayout; } //Language if (Language_Pos!=(size_t)-1) for (size_t Pos=0; PosInfos["Language"]=Language; } } //*************************************************************************** // In //*************************************************************************** //--------------------------------------------------------------------------- void File__ReferenceFilesHelper::AddSequence(sequence* NewSequence) { Common->HasMultipleSequences=!Sequences.empty(); //If not empty, there will be more than 1 sequence just after NewSequence->Package=Common; NewSequence->Common->Package=Common; Sequences.push_back(NewSequence); } //--------------------------------------------------------------------------- void File__ReferenceFilesHelper::UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName) { size_t Sequences_Size=Sequences.size(); for (size_t Sequences_Pos=0; Sequences_PosUpdateFileName(OldFileName, NewFileName); } } //*************************************************************************** // Streams management //*************************************************************************** void File__ReferenceFilesHelper::ParseReferences() { if (!Init_Done) { #if MEDIAINFO_FILTER if (MI->Config->File_Filter_Audio_Get()) { for (size_t Pos=0; PosStreamKind!=Stream_Audio) { Sequences.erase(Sequences.begin()+Pos); Pos--; } CountOfReferencesToParse=Sequences.size(); } #endif //MEDIAINFO_FILTER //Filling Filenames from the more complete version and Edit rates float64 EditRate=DBL_MAX; size_t EditRate_Count=0; for (Sequences_Current=0; Sequences_CurrentFileNames.empty()) for (size_t Pos=0; PosResources.size(); Pos++) { for (size_t Resource_FileNames_Pos=0; Resource_FileNames_PosResources[Pos]->FileNames.size(); Resource_FileNames_Pos++) Sequences[Sequences_Current]->FileNames.push_back(Sequences[Sequences_Current]->Resources[Pos]->FileNames[Resource_FileNames_Pos]); if (Sequences[Sequences_Current]->Resources[Pos]->EditRate && EditRate!=Sequences[Sequences_Current]->Resources[Pos]->EditRate) { if (EditRate>Sequences[Sequences_Current]->Resources[Pos]->EditRate) EditRate=Sequences[Sequences_Current]->Resources[Pos]->EditRate; EditRate_Count++; } } if (EditRate_Count>1) //Multiple rates, using only one rate for (Sequences_Current=0; Sequences_CurrentResources.size(); Pos++) if (Sequences[Sequences_Current]->Resources[Pos]->EditRate && EditRate!=Sequences[Sequences_Current]->Resources[Pos]->EditRate) { if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore) { float64 Temp=(float64)Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore; Temp/=Sequences[Sequences_Current]->Resources[Pos]->EditRate; Temp*=EditRate; Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore=float64_int64s(Temp); } if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter!=(int64u)-1) { float64 Temp=(float64)Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter; Temp/=Sequences[Sequences_Current]->Resources[Pos]->EditRate; Temp*=EditRate; Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter=float64_int64s(Temp); } if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration!=(int64u)-1) { float64 Temp=(float64)Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration; Temp/=Sequences[Sequences_Current]->Resources[Pos]->EditRate; Temp*=EditRate; Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration=float64_int64s(Temp); } Sequences[Sequences_Current]->Resources[Pos]->EditRate=EditRate; } //Testing IDs std::set StreamList; bool StreamList_DuplicatedIds=false; for (Sequences_Current=0; Sequences_CurrentStreamID)==StreamList.end()) StreamList.insert(Sequences[Sequences_Current]->StreamID); else { StreamList_DuplicatedIds=true; break; } if (StreamList_DuplicatedIds) for (Sequences_Current=0; Sequences_CurrentStreamID=Sequences_Current+1; if (Sequences.size()==1 && (*Sequences.begin())->StreamID==(int64u)-1) { ContainerHasNoId=true; #if MEDIAINFO_EVENTS MI->StreamIDs_Width[MI->StreamIDs_Size-1]=0; #endif //MEDIAINFO_EVENTS } std::sort(Sequences.begin(), Sequences.end(), File__ReferenceFilesHelper_Algo1); std::sort(Sequences.begin(), Sequences.end(), File__ReferenceFilesHelper_Algo2); std::sort(Sequences.begin(), Sequences.end(), File__ReferenceFilesHelper_Algo3); //InfoFromFileName File__ReferenceFilesHelper_InfoFromFileName(Sequences); #if MEDIAINFO_EVENTS if (MI->Config->Config_PerPackage==NULL) { MI->Config->Config_PerPackage=new MediaInfo_Config_PerPackage; MI->Config->Config_PerPackage->CountOfPackages=Sequences.size(); } #endif //MEDIAINFO_EVENTS //Configuring file names Sequences_Current=0; while (Sequences_CurrentFileNames; ZtringList AbsoluteNames; AbsoluteNames.Separator_Set(0, ","); for (size_t Pos=0; PosFile_Name.find(__T("://"))==string::npos) AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name); else { size_t Pos_Path=MI->File_Name.find_last_of('/'); if (Pos_Path!=Ztring::npos) AbsoluteName=MI->File_Name.substr(0, Pos_Path); } if (!AbsoluteName.empty()) AbsoluteName+=ZenLib::PathSeparator; } AbsoluteName+=Names[Pos]; #ifdef __WINDOWS__ if (AbsoluteName.find(__T("://"))==string::npos) AbsoluteName.FindAndReplace(__T("/"), __T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization local file else AbsoluteName.FindAndReplace(__T("\\"), __T("/"), 0, Ztring_Recursive); //Names[Pos] normalization with protocol (so "/" in all cases) #endif //__WINDOWS__ AbsoluteNames.push_back(AbsoluteName); } if (AbsoluteNames.empty() || !(AbsoluteNames[0].find(__T("://"))!=string::npos || 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; PosFile_Name.find(__T("://"))==string::npos) AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name); else { size_t Pos_Path=MI->File_Name.find_last_of('/'); if (Pos_Path!=Ztring::npos) AbsoluteName=MI->File_Name.substr(0, Pos_Path); } 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 (AbsoluteNames.empty() || !File::Exists(AbsoluteNames[0])) { AbsoluteNames.clear(); Names=Sequences[Sequences_Current]->FileNames; //Configuring file name (this time, we try to test local files) size_t PathSeparator_Pos=Names.empty()?string::npos: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; PosFile_Name.find(__T("://"))==string::npos) AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name); else { size_t Pos_Path=MI->File_Name.find_last_of('/'); if (Pos_Path!=Ztring::npos) AbsoluteName=MI->File_Name.substr(0, Pos_Path); } if (!AbsoluteName.empty()) AbsoluteName+=ZenLib::PathSeparator; AbsoluteName+=Names[Pos]; #ifdef __WINDOWS__ if (AbsoluteName.find(__T("://"))==string::npos) AbsoluteName.FindAndReplace(__T("/"), __T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization local file else AbsoluteName.FindAndReplace(__T("\\"), __T("/"), 0, Ztring_Recursive); //Names[Pos] normalization with protocol (so "/" in all cases) #endif //__WINDOWS__ AbsoluteNames.push_back(AbsoluteName); } if (!File::Exists(AbsoluteNames[0])) { AbsoluteNames.clear(); Names=Sequences[Sequences_Current]->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; PosFile_Name.find(__T("://"))==string::npos) AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name); else { size_t Pos_Path=MI->File_Name.find_last_of('/'); if (Pos_Path!=Ztring::npos) AbsoluteName=MI->File_Name.substr(0, Pos_Path); } 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 (!AbsoluteNames.empty() && !File::Exists(AbsoluteNames[0])) AbsoluteNames.clear(); } } } } } Sequences[Sequences_Current]->Source=Sequences[Sequences_Current]->FileNames.Read(0); if (Sequences[Sequences_Current]->StreamKind!=Stream_Max && !Sequences[Sequences_Current]->Source.empty()) { if (Sequences[Sequences_Current]->StreamPos==(size_t)-1) Sequences[Sequences_Current]->StreamPos=Stream_Prepare(Sequences[Sequences_Current]->StreamKind); MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source", Sequences[Sequences_Current]->Source); } if (!AbsoluteNames.empty()) Sequences[Sequences_Current]->FileNames=AbsoluteNames; if (!AbsoluteNames.empty() && AbsoluteNames[0]==MI->File_Name) { Sequences[Sequences_Current]->IsCircular=true; Sequences[Sequences_Current]->FileNames.clear(); Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished); } else if (!AbsoluteNames.empty()) Sequences[Sequences_Current]->FileNames=AbsoluteNames; else { Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished); if (Sequences[Sequences_Current]->StreamKind!=Stream_Max && !Sequences[Sequences_Current]->Source.empty()) { MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source_Info", "Missing"); if (MI->Retrieve(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, General_ID).empty() && Sequences[Sequences_Current]->StreamID!=(int64u)-1) MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, General_ID, Sequences[Sequences_Current]->StreamID); for (std::map::iterator Info=Sequences[Sequences_Current]->Infos.begin(); Info!=Sequences[Sequences_Current]->Infos.end(); ++Info) { if (Info->first=="CodecID") MI->CodecID_Fill(Info->second, Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, InfoCodecID_Format_Mpeg4); else MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, Info->first.c_str(), Info->second); } } } if (FilesForStorage) { for (size_t Pos=0; PosFileNames.size(); Pos++) { if (Pos==Sequences[Sequences_Current]->Resources.size()) Sequences[Sequences_Current]->Resources.push_back(new resource); Sequences[Sequences_Current]->Resources[Pos]->FileNames.clear(); Sequences[Sequences_Current]->Resources[Pos]->FileNames.push_back(Sequences[Sequences_Current]->FileNames[Pos]); } Sequences[Sequences_Current]->FileNames.resize(1); } Sequences_Current++; } #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get()) { Demux_Interleave=Config->File_Demux_Interleave_Get(); if (Demux_Interleave) { CountOfReferencesToParse=Sequences.size(); for (sequences::iterator ReferenceSource=Sequences.begin(); ReferenceSource!=Sequences.end(); ++ReferenceSource) if ((*ReferenceSource)->FileNames.empty()) CountOfReferencesToParse--; DTS_Interval=250000000LL; // 250 milliseconds } } else Demux_Interleave=false; //Using the frame rate from the first stream having a frame rate if (!FrameRate) for (sequences::iterator ReferenceFrameRate=Sequences.begin(); ReferenceFrameRate!=Sequences.end(); ++ReferenceFrameRate) if ((*ReferenceFrameRate)->FrameRate) { FrameRate=(*ReferenceFrameRate)->FrameRate; break; } if (Config->NextPacket_Get()) { Sequences_Current=0; while (Sequences_CurrentStatus[File__Analyze::IsFinished]) { Sequences.erase(Sequences.begin()+Pos); Pos--; } CountOfReferencesToParse=Sequences.size(); if (Sequences.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); } } #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET FileSize_Compute(); Sequences_Current=0; CountOfReferences_ForReadSize=Sequences.size(); Init_Done=true; #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get() && MI->Demux_EventWasSent_Accept_Specific) { MI->Config->Demux_EventWasSent=true; return; } #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET } while (Sequences_CurrentStatus[File__Analyze::IsFinished]) #endif //MEDIAINFO_NEXTPACKET ParseReference(); //State int64u FileSize_Parsed=0; #if MEDIAINFO_NEXTPACKET DTS_Minimal=(int64u)-1; #endif //MEDIAINFO_NEXTPACKET for (sequences::iterator ReferenceTemp=Sequences.begin(); ReferenceTemp!=Sequences.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; #if MEDIAINFO_NEXTPACKET //Minimal DTS if (DTS_Interval!=(int64u)-1 && !Sequences[Sequences_Current]->Status[File__Analyze::IsFinished] && ((*ReferenceTemp)->Resources.empty() || (*ReferenceTemp)->Resources_Current<(*ReferenceTemp)->Resources.size())) { int64u DTS_Temp; if (!(*ReferenceTemp)->Resources.empty() && (*ReferenceTemp)->Resources_Current) { if ((*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1) DTS_Temp=(*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->MI->Info->FrameInfo.DTS-(*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->MI->Info->Config->Demux_Offset_DTS_FromStream; else DTS_Temp=0; } else { if ((*ReferenceTemp)->MI->Info->FrameInfo.DTS!=(int64u)-1) DTS_Temp=(*ReferenceTemp)->MI->Info->FrameInfo.DTS-(*ReferenceTemp)->MI->Info->Config->Demux_Offset_DTS_FromStream; else DTS_Temp=0; } DTS_Temp+=(*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->Demux_Offset_DTS; if (DTS_Minimal>DTS_Temp) DTS_Minimal=DTS_Temp; } #endif //MEDIAINFO_NEXTPACKET } else FileSize_Parsed+=(*ReferenceTemp)->FileSize; } Config->State_Set(((float)FileSize_Parsed)/MI->Config->File_Size); #if MEDIAINFO_EVENTS struct MediaInfo_Event_General_SubFile_End_0 Event; MI->Event_Prepare((struct MediaInfo_Event_Generic*)&Event); Event.EventCode=MediaInfo_EventCode_Create(0, MediaInfo_Event_General_SubFile_End, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_SubFile_End_0); MI->Config->Event_Send(NULL, (const int8u*)&Event, Event.EventSize, MI->File_Name); #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Demux_Interleave && (Sequences[Sequences_Current]->MI==NULL || Sequences[Sequences_Current]->MI->Info==NULL || Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser==NULL || Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser->Demux_TotalBytes>=Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser->Buffer_TotalBytes+Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser->Buffer_Size)) { size_t Reference_Next=Sequences_Current; ++Reference_Next; if (Reference_Next==Sequences.size() && Config->NextPacket_Get() && CountOfReferencesToParse) Sequences_Current=0; else Sequences_Current=Reference_Next; if (Config->Demux_EventWasSent) return; } else { if (Config->Demux_EventWasSent) return; Sequences_Current++; } #else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET Sequences_Current++; #endif //MEDIAINFO_DEMUX } //File size handling FileSize_Compute(); if (MI->Config->File_Size!=MI->File_Size #if MEDIAINFO_ADVANCED && !Config->File_IgnoreSequenceFileSize_Get() #endif //MEDIAINFO_ADVANCED ) { 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); } #if MEDIAINFO_ADVANCED if (Config->File_IgnoreSequenceFileSize_Get()) MI->Clear(Stream_General, 0, General_FileSize); #endif //MEDIAINFO_ADVANCED } //--------------------------------------------------------------------------- bool File__ReferenceFilesHelper::ParseReference_Init() { //Configuration Sequences[Sequences_Current]->MI=MI_Create(); if (Config->ParseSpeed>=1) { for (size_t Pos=0; PosResources.size(); Pos++) { if (Sequences[Sequences_Current]->Resources[0]->EditRate) { #if MEDIAINFO_DEMUX if (Pos==0) { Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS=0; Sequences[Sequences_Current]->Resources[0]->Demux_Offset_Frame=0; } if (Pos+1Resources.size()) { Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_DTS=float64_int64s(Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS+(Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter-Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore)/Sequences[Sequences_Current]->Resources[0]->EditRate*1000000000); Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_Frame+Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter-Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore; } #endif //MEDIAINFO_DEMUX } else { MediaInfo_Internal MI2; MI2.Option(__T("File_KeepInfo"), __T("1")); Ztring ParseSpeed_Save=MI2.Option(__T("ParseSpeed_Get"), __T("0")); Ztring Demux_Save=MI2.Option(__T("Demux_Get"), __T("")); MI2.Option(__T("ParseSpeed"), __T("0")); MI2.Option(__T("Demux"), Ztring()); Sequences[Sequences_Current]->Resources[Pos]->FileNames.Separator_Set(0, ","); size_t MiOpenResult=MI2.Open(Sequences[Sequences_Current]->Resources[Pos]->FileNames.Read()); 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) { #if MEDIAINFO_DEMUX int64u Duration=MI2.Get(Sequences[Sequences_Current]->StreamKind, 0, __T("Duration")).To_int64u()*1000000; int64u FrameCount=MI2.Get(Sequences[Sequences_Current]->StreamKind, 0, __T("FrameCount")).To_int64u(); if (Pos==0) { int64u Delay=MI2.Get(Stream_Video, 0, Video_Delay).To_int64u()*1000000; if (Sequences[Sequences_Current]->StreamKind==Stream_Video && Offset_Video_DTS==0) Offset_Video_DTS=Delay; Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS=Offset_Video_DTS; Sequences[Sequences_Current]->Resources[0]->Demux_Offset_Frame=0; } if (Pos+1Resources.size()) { Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_DTS=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS+Duration; Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_Frame+FrameCount; } else Duration=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS+Duration-Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS; #endif //MEDIAINFO_DEMUX } } if (Pos) { Sequences[Sequences_Current]->Resources[Pos]->MI=MI_Create(); Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_IgnoreEditsBefore=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore; if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter==(int64u)-1 && Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration!=(int64u)-1) Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore+Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration; else Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter; Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_EditRate=Sequences[Sequences_Current]->Resources[Pos]->EditRate; #if MEDIAINFO_DEMUX Sequences[Sequences_Current]->Resources[Pos]->MI->Config.Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_Frame; Sequences[Sequences_Current]->Resources[Pos]->MI->Config.Demux_Offset_DTS=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS; #endif //MEDIAINFO_DEMUX } } if (!Sequences[Sequences_Current]->Resources.empty()) { Sequences[Sequences_Current]->MI->Config.File_IgnoreEditsBefore=Sequences[Sequences_Current]->Resources[0]->IgnoreEditsBefore; if (Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfter==(int64u)-1 && Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfterDuration!=(int64u)-1) Sequences[Sequences_Current]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[0]->IgnoreEditsBefore+Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfterDuration; else Sequences[Sequences_Current]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfter; Sequences[Sequences_Current]->MI->Config.File_EditRate=Sequences[Sequences_Current]->Resources[0]->EditRate; #if MEDIAINFO_DEMUX Sequences[Sequences_Current]->MI->Config.Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[0]->Demux_Offset_Frame; Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS=Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS; #endif //MEDIAINFO_DEMUX } } if (Sequences[Sequences_Current]->IsCircular) { MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source_Info", "Circular"); if (!Config->File_KeepInfo_Get()) { #if MEDIAINFO_DEMUX if (CountOfReferencesToParse) CountOfReferencesToParse--; #endif //MEDIAINFO_DEMUX Sequences[Sequences_Current]->StreamKind=Stream_Max; Sequences[Sequences_Current]->StreamPos=(size_t)-1; Sequences[Sequences_Current]->FileSize=Sequences[Sequences_Current]->MI->Config.File_Size; delete Sequences[Sequences_Current]->MI; Sequences[Sequences_Current]->MI=NULL; } Sequences[Sequences_Current]->FileNames.clear(); Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished); } else { //Run #if MEDIAINFO_EVENTS SubFile_Start(); #endif //MEDIAINFO_EVENTS if (!Sequences[Sequences_Current]->MI->Open(Sequences[Sequences_Current]->FileNames.Read())) { if (Sequences[Sequences_Current]->StreamKind!=Stream_Max) MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source_Info", "Missing", Unlimited, true, true); if (!Config->File_KeepInfo_Get()) { #if MEDIAINFO_DEMUX if (CountOfReferencesToParse) CountOfReferencesToParse--; #endif //MEDIAINFO_DEMUX Sequences[Sequences_Current]->StreamKind=Stream_Max; Sequences[Sequences_Current]->StreamPos=(size_t)-1; Sequences[Sequences_Current]->FileSize=Sequences[Sequences_Current]->MI->Config.File_Size; delete Sequences[Sequences_Current]->MI; Sequences[Sequences_Current]->MI=NULL; } Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished); } if (Config->ParseSpeed>=1) for (size_t Pos=1; PosResources.size(); Pos++) { Sequences[Sequences_Current]->Resources[Pos]->FileNames.Separator_Set(0, ","); Sequences[Sequences_Current]->Resources[Pos]->MI->Open(Sequences[Sequences_Current]->Resources[Pos]->FileNames.Read()); } #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX if (Config->NextPacket_Get()) return false; #endif //MEDIAINFO_NEXTPACKET } return true; } //--------------------------------------------------------------------------- void File__ReferenceFilesHelper::ParseReference() { if (Sequences[Sequences_Current]->MI==NULL && !Sequences[Sequences_Current]->FileNames.empty()) { if (!ParseReference_Init()) return; } if (Sequences[Sequences_Current]->MI) { #if MEDIAINFO_EVENTS && MEDIAINFO_NEXTPACKET if (DTS_Interval!=(int64u)-1 && !Sequences[Sequences_Current]->Status[File__Analyze::IsFinished] && Sequences[Sequences_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1 && DTS_Minimal!=(int64u)-1 && (Sequences[Sequences_Current]->Resources.empty() || Sequences[Sequences_Current]->Resources_CurrentResources.size())) { int64u DTS_Temp; if (!Sequences[Sequences_Current]->Resources.empty() && Sequences[Sequences_Current]->Resources_Current) { if (Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1) DTS_Temp=Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Info->FrameInfo.DTS-Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Info->Config->Demux_Offset_DTS_FromStream; else DTS_Temp=0; } else { if (Sequences[Sequences_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1) DTS_Temp=Sequences[Sequences_Current]->MI->Info->FrameInfo.DTS-Sequences[Sequences_Current]->MI->Info->Config->Demux_Offset_DTS_FromStream; else DTS_Temp=0; } DTS_Temp+=Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->Demux_Offset_DTS; if (!Sequences[Sequences_Current]->Resources.empty() && Sequences[Sequences_Current]->Resources_CurrentResources.size() && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->EditRate && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->IgnoreEditsBefore) { int64u TimeOffset=float64_int64s(((float64)Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->IgnoreEditsBefore)/Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->EditRate*1000000000); if (DTS_Temp>TimeOffset) DTS_Temp-=TimeOffset; else DTS_Temp=0; } if (DTS_Temp>DTS_Minimal+DTS_Interval) return; } if (Config->Event_CallBackFunction_IsSet() && !Sequences[Sequences_Current]->Status[File__Analyze::IsFinished]) { #if MEDIAINFO_DEMUX SubFile_Start(); if (Sequences[Sequences_Current]->Resources_Current==0) { while ((Sequences[Sequences_Current]->Status=Sequences[Sequences_Current]->MI->Open_NextPacket())[8]) { if (!Sequences[Sequences_Current]->FileSize_IsPresent && Sequences[Sequences_Current]->MI->Config.File_Size!=(int64u)-1) { Sequences[Sequences_Current]->FileSize_IsPresent=true; if (CountOfReferences_ForReadSize) { CountOfReferences_ForReadSize--; if (!CountOfReferences_ForReadSize) CountOfReferences_ForReadSize_Run(); } } if (Config->Event_CallBackFunction_IsSet()) { Config->Demux_EventWasSent=true; return; } } Sequences[Sequences_Current]->Resources_Current++; if (Sequences[Sequences_Current]->Resources_CurrentResources.size() && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI) Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Open_Buffer_Seek(0, 0, (int64u)-1); } #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX if (Config->ParseSpeed<1.0) Sequences[Sequences_Current]->Resources_Current=Sequences[Sequences_Current]->Resources.size(); //No need to parse all files #endif //MEDIAINFO_NEXTPACKET while (Sequences[Sequences_Current]->Resources_CurrentResources.size()) { while ((Sequences[Sequences_Current]->Status=Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Open_NextPacket())[8]) { if (!Sequences[Sequences_Current]->FileSize_IsPresent && Sequences[Sequences_Current]->MI->Config.File_Size!=(int64u)-1) { Sequences[Sequences_Current]->FileSize_IsPresent=true; if (CountOfReferences_ForReadSize) { CountOfReferences_ForReadSize--; if (!CountOfReferences_ForReadSize) CountOfReferences_ForReadSize_Run(); } } if (Config->Event_CallBackFunction_IsSet()) { Config->Demux_EventWasSent=true; return; } } Sequences[Sequences_Current]->Resources_Current++; if (Sequences[Sequences_Current]->Resources_CurrentResources.size() && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI) Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Open_Buffer_Seek(0, 0, (int64u)-1); } if (CountOfReferencesToParse) CountOfReferencesToParse--; #endif //MEDIAINFO_DEMUX } #endif //MEDIAINFO_EVENTS && MEDIAINFO_NEXTPACKET ParseReference_Finalize(); if (!Config->File_KeepInfo_Get()) { Sequences[Sequences_Current]->StreamKind=Stream_Max; Sequences[Sequences_Current]->StreamPos=(size_t)-1; Sequences[Sequences_Current]->State=10000; if (Sequences[Sequences_Current]->Resources.empty()) Sequences[Sequences_Current]->FileSize=Sequences[Sequences_Current]->MI->Config.File_Size; else if (Sequences[Sequences_Current]->FileSize==(int64u)-1) { Sequences[Sequences_Current]->FileSize=0; for (size_t Pos=0; PosResources.size(); Pos++) for (size_t Resource_FileNames_Pos=0; Resource_FileNames_PosResources[Pos]->FileNames.size(); Resource_FileNames_Pos++) Sequences[Sequences_Current]->FileSize+=File::Size_Get(Sequences[Sequences_Current]->Resources[Pos]->FileNames[Resource_FileNames_Pos]); } delete Sequences[Sequences_Current]->MI; Sequences[Sequences_Current]->MI=NULL; } } } //--------------------------------------------------------------------------- void File__ReferenceFilesHelper::ParseReference_Finalize () { //Removing wrong initial value if (Sequences[Sequences_Current]->MI->Count_Get(Sequences[Sequences_Current]->StreamKind)==0 && Sequences[Sequences_Current]->StreamPos!=(size_t)-1 && Sequences[Sequences_Current]->MI->Count_Get(Stream_Video)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Audio)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Image)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Text)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Other)) { MI->Stream_Erase(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos); for (sequences::iterator ReferenceTemp=Sequences.begin(); ReferenceTemp!=Sequences.end(); ++ReferenceTemp) if ((*ReferenceTemp)->StreamKind==Sequences[Sequences_Current]->StreamKind && (*ReferenceTemp)->StreamPos!=(size_t)-1 && (*ReferenceTemp)->StreamPos>Sequences[Sequences_Current]->StreamPos) (*ReferenceTemp)->StreamPos--; Sequences[Sequences_Current]->StreamPos=(size_t)-1; } bool StreamFound=false; for (size_t StreamKind=Stream_General+1; StreamKindMI->Count_Get((stream_t)StreamKind); StreamPos++) { StreamKind_Last=(stream_t)StreamKind; if (Sequences[Sequences_Current]->StreamPos!=(size_t)-1 && StreamKind_Last==Sequences[Sequences_Current]->StreamKind && StreamPos==0) { StreamPos_To=Sequences[Sequences_Current]->StreamPos; StreamFound=true; } else { size_t ToInsert=(size_t)-1; for (sequences::iterator ReferencePos=Sequences.begin(); ReferencePos!=Sequences.end(); ++ReferencePos) if ((*ReferencePos)->StreamKind==StreamKind_Last && Sequences[Sequences_Current]->StreamID<(*ReferencePos)->StreamID) { ToInsert=(*ReferencePos)->StreamPos; break; } StreamPos_To=Stream_Prepare((stream_t)StreamKind, ToInsert); } StreamPos_From=StreamPos; ParseReference_Finalize_PerStream(); } if (!StreamFound && Sequences[Sequences_Current]->StreamKind!=Stream_Max && Sequences[Sequences_Current]->StreamPos!=(size_t)-1 && Sequences[Sequences_Current]->MI->Info) { Ztring MuxingMode=MI->Retrieve(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "MuxingMode"); if (!MuxingMode.empty()) MuxingMode.insert(0, __T(" / ")); MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "MuxingMode", Sequences[Sequences_Current]->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 (HasMainFile_Filled && !Sequences[Sequences_Current]->IsMain) { ID_Base=Ztring::ToZtring(ID_Max+Sequences[Sequences_Current]->StreamID-1); MI->Fill(StreamKind_Last, StreamPos_To, "SideCar_FilePos", Sequences[Sequences_Current]->StreamID-1); (*MI->Stream_More)[StreamKind_Last][StreamPos_To](Ztring().From_Local("SideCar_FilePos"), Info_Options)=__T("N NT"); } else if (Sequences[Sequences_Current]->StreamID!=(int64u)-1) ID_Base=Ztring::ToZtring(Sequences[Sequences_Current]->StreamID); Ztring ID=ID_Base; Ztring ID_String=ID_Base; Ztring MenuID; Ztring MenuID_String; if (!HasMainFile_Filled && Sequences[Sequences_Current]->IsMain) { MI->Fill(Stream_General, 0, General_Format, Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_Format) , true); MI->Fill(Stream_General, 0, General_CompleteName, Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_CompleteName) , true); MI->Fill(Stream_General, 0, General_FileExtension, Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_FileExtension) , true); HasMainFile=true; HasMainFile_Filled=true; } if (Sequences[Sequences_Current]->IsMain) { int64u ID_New=Sequences[Sequences_Current]->MI->Get(StreamKind_Last, StreamPos_From, General_ID).To_int64u(); if (ID_MaxClear(StreamKind_Last, StreamPos_To, General_ID); MI->Merge(*Sequences[Sequences_Current]->MI->Info, StreamKind_Last, StreamPos_From, StreamPos_To); if (!Sequences[Sequences_Current]->Resources.empty()) { MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_BitRate)); MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_Duration)); MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_FrameCount)); MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_StreamSize)); float64 BitRate_Before=0; int64u Duration_Temp=0; int64u FrameCount_Temp=0; int64u StreamSize_Temp=0; int64u FileSize_Temp=0; for (size_t Pos=0; PosResources.size(); Pos++) { 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()); MI2.Config.File_IgnoreEditsBefore=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore; if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter==(int64u)-1 && Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration!=(int64u)-1) MI2.Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore+Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration; else MI2.Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter; MI2.Config.File_EditRate=Sequences[Sequences_Current]->Resources[Pos]->EditRate; Sequences[Sequences_Current]->Resources[Pos]->FileNames.Separator_Set(0, ","); size_t MiOpenResult=MI2.Open(Sequences[Sequences_Current]->Resources[Pos]->FileNames.Read()); 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) { BitRate_Before=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_BitRate)).To_float64(); Ztring Duration_Temp2=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_Duration)); if (!Duration_Temp2.empty() && Duration_Temp!=(int64u)-1) Duration_Temp+=Duration_Temp2.To_int64u(); else Duration_Temp=(int64u)-1; Ztring FrameCount_Temp2=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_FrameCount)); if (!FrameCount_Temp2.empty() && FrameCount_Temp!=(int64u)-1) FrameCount_Temp+=FrameCount_Temp2.To_int64u(); else FrameCount_Temp=(int64u)-1; Ztring StreamSize_Temp2=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_StreamSize)); if (!StreamSize_Temp2.empty() && StreamSize_Temp!=(int64u)-1) StreamSize_Temp+=StreamSize_Temp2.To_int64u(); else StreamSize_Temp=(int64u)-1; Ztring FileSize_Temp2=MI2.Get(Stream_General, 0, General_FileSize); if (!FileSize_Temp2.empty() && FileSize_Temp!=(int64u)-1) FileSize_Temp+=FileSize_Temp2.To_int64u(); else FileSize_Temp=(int64u)-1; } else { Duration_Temp=(int64u)-1; FrameCount_Temp=(int64u)-1; StreamSize_Temp=(int64u)-1; FileSize_Temp=(int64u)-1; break; } } if (Duration_Temp!=(int64u)-1) MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_Duration), Duration_Temp, 10, true); if (FrameCount_Temp!=(int64u)-1) MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_FrameCount), FrameCount_Temp, 10, true); if (StreamSize_Temp!=(int64u)-1) MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_StreamSize), StreamSize_Temp, 10, true); if (FileSize_Temp!=(int64u)-1) Sequences[Sequences_Current]->FileSize=FileSize_Temp; if (BitRate_Before && Duration_Temp) { float64 BitRate_After=((float64)StreamSize_Temp)*8000/Duration_Temp; if (BitRate_Before>BitRate_After*0.999 && BitRate_BeforeFill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_BitRate), BitRate_Before, 0, true); //In case of similar bitrate, there is great chance hte compute bit rate is different due to aproximation errors only, using the previous one. TODO: find a better way to detect it } } //Frame rate if available from container if (StreamKind_Last==Stream_Video && Sequences[Sequences_Current]->FrameRate) MI->Fill(Stream_Video, StreamPos_To, Video_FrameRate, Sequences[Sequences_Current]->FrameRate, 3 , true); //Hacks - After if (!Sequences[Sequences_Current]->IsMain && 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 (!Sequences[Sequences_Current]->IsMain && Sequences[Sequences_Current]->MI->Count_Get(Stream_Video)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Audio)>1 && Sequences[Sequences_Current]->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; PosFill(Stream_Menu, StreamPos_To, Menu_List, List.Read(), true); MI->Fill(Stream_Menu, StreamPos_To, Menu_List_String, List_String.Read(), true); } else if (Sequences.size()>1 && Sequences[Sequences_Current]->MI->Count_Get(Stream_Menu)==0) { if (Sequences[Sequences_Current]->MenuPos==(size_t)-1) { Sequences[Sequences_Current]->MenuPos=MI->Stream_Prepare(Stream_Menu); MI->Fill(Stream_Menu, Sequences[Sequences_Current]->MenuPos, General_ID, ID_Base); MI->Fill(Stream_Menu, Sequences[Sequences_Current]->StreamPos, "Source", Sequences[Sequences_Current]->Source); } Ztring List=Sequences[Sequences_Current]->MI->Get(StreamKind_Last, StreamPos_From, General_ID); Ztring List_String=Sequences[Sequences_Current]->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, Sequences[Sequences_Current]->MenuPos, Menu_List, List); MI->Fill(Stream_Menu, Sequences[Sequences_Current]->MenuPos, Menu_List_String, List_String); } } if (!Sequences[Sequences_Current]->IsMain && (ContainerHasNoId || !Config->File_ID_OnlyRoot_Get() || Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_Format)==__T("SCC") || Sequences[Sequences_Current]->MI->Count_Get(Stream_Video)+Sequences[Sequences_Current]->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 (Sequences[Sequences_Current]->MenuPos!=(size_t)-1) { MenuID=ID_Base; MenuID_String=ID_Base; } } if (!Sequences[Sequences_Current]->IsMain) { 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()) { if (MI->Retrieve(StreamKind_Last, StreamPos_To, "Source_Original").empty() && Sequences[Sequences_Current]->Source!=MI->Retrieve(StreamKind_Last, StreamPos_To, "Source")) // TODO: better handling { MI->Fill(StreamKind_Last, StreamPos_To, "Source_Original", MI->Retrieve(StreamKind_Last, StreamPos_To, "Source")); MI->Fill(StreamKind_Last, StreamPos_To, "Source_Original_Kind", MI->Retrieve(StreamKind_Last, StreamPos_To, "Source_Kind")); MI->Fill(StreamKind_Last, StreamPos_To, "Source_Original_Info", MI->Retrieve(StreamKind_Last, StreamPos_To, "Source_Info")); } MI->Clear(StreamKind_Last, StreamPos_To, "Source"); MI->Clear(StreamKind_Last, StreamPos_To, "Source_Kind"); MI->Clear(StreamKind_Last, StreamPos_To, "Source_Info"); } MI->Fill(StreamKind_Last, StreamPos_To, "Source", Sequences[Sequences_Current]->Source); } for (std::map::iterator Info=Sequences[Sequences_Current]->Infos.begin(); Info!=Sequences[Sequences_Current]->Infos.end(); ++Info) if (MI->Retrieve(StreamKind_Last, StreamPos_To, Info->first.c_str()).empty()) MI->Fill(StreamKind_Last, StreamPos_To, Info->first.c_str(), Info->second); //Others if (!Sequences[Sequences_Current]->IsMain && Sequences[Sequences_Current]->MI->Info && MI->Retrieve(StreamKind_Last, StreamPos_To, Sequences[Sequences_Current]->MI->Info->Fill_Parameter(StreamKind_Last, Generic_Format))!=Sequences[Sequences_Current]->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", Sequences[Sequences_Current]->MI->Info->Get(Stream_General, 0, General_Format)+MuxingMode, true); } //Lists #if MEDIAINFO_ADVANCED || MEDIAINFO_HASH if (!Sequences[Sequences_Current]->List_Compute_Done && (Sequences[Sequences_Current]->MI->Count_Get(Stream_Menu)==0 || StreamKind_Last==Stream_Menu)) { List_Compute(); Sequences[Sequences_Current]->List_Compute_Done=true; } #endif //MEDIAINFO_ADVANCED || MEDIAINFO_HASH } //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED || MEDIAINFO_HASH void File__ReferenceFilesHelper::List_Compute() { stream_t StreamKind=Sequences.size()>1?StreamKind_Last:Stream_General; size_t StreamPos=Sequences.size()>1?StreamPos_To:0; stream_t StreamKind_Target=Sequences[Sequences_Current]->MenuPos==(size_t)-1?StreamKind:Stream_Menu; size_t StreamPos_Target=Sequences[Sequences_Current]->MenuPos==(size_t)-1?StreamPos:Sequences[Sequences_Current]->MenuPos; //Hash #if MEDIAINFO_HASH if (!HasMainFile && Config->File_Hash_Get().to_ulong()) { for (size_t Hash_Pos=0; Hash_PosMI->Get(Stream_General, 0, Hash_NameU+__T("_Generated")).empty()) { if (Sequences[Sequences_Current]->MI->Config.File_Names.size()==1) { if (MI->Retrieve(StreamKind_Target, StreamPos_Target, "Source").empty()) { Ztring SourcePath; Ztring SourceName=MI->Retrieve(Stream_General, 0, General_CompleteName); if (SourceName.find(__T("://"))==string::npos) SourcePath=ZenLib::FileName::Path_Get(SourceName); else { size_t Pos_Path=SourceName.find_last_of('/'); if (Pos_Path!=Ztring::npos) SourcePath=SourceName.substr(0, Pos_Path); } size_t SourcePath_Size=SourcePath.size()+1; //Path size + path separator size Ztring Temp=Sequences[Sequences_Current]->MI->Config.File_Names[0]; if (!Config->File_IsReferenced_Get()) Temp.erase(0, SourcePath_Size); MI->Fill(StreamKind_Target, StreamPos_Target, "Source", Temp); } MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(Stream_General, 0, Hash_NameU+__T("_Generated"))); (*MI->Stream_More)[StreamKind_Target][StreamPos_Target](Ztring().From_Local("Source_"+Hash_Name+"_Generated"), Info_Options)=__T("N NT"); } MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(Stream_General, 0, Hash_NameU+__T("_Generated"))); (*MI->Stream_More)[StreamKind_Target][StreamPos_Target](Ztring().From_Local("Source_List_"+Hash_Name+"_Generated"), Info_Options)=__T("N NT"); } if (!Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List_")+Hash_NameU+__T("_Generated")).empty()) { MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List_")+Hash_NameU+__T("_Generated"))); (*MI->Stream_More)[StreamKind_Target][StreamPos_Target](Ztring().From_Local("Source_List_"+Hash_Name+"_Generated"), Info_Options)=__T("N NT"); } else if (!Sequences[Sequences_Current]->MI->Get(StreamKind, StreamPos, __T("Source_List_")+Hash_NameU+__T("_Generated")).empty()) { MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(StreamKind, StreamPos, __T("Source_List_")+Hash_NameU+__T("_Generated"))); (*MI->Stream_More)[StreamKind_Target][StreamPos_Target](Ztring().From_Local("Source_List_"+Hash_Name+"_Generated"), Info_Options)=__T("N NT"); } } } #endif //MEDIAINFO_HASH //Source_List #if MEDIAINFO_ADVANCED if (!HasMainFile && Config->File_Source_List_Get()) { Ztring SourcePath; Ztring SourceName=MI->Retrieve(Stream_General, 0, General_CompleteName); if (SourceName.find(__T("://"))==string::npos) SourcePath=ZenLib::FileName::Path_Get(SourceName); else { size_t Pos_Path=SourceName.find_last_of('/'); if (Pos_Path!=Ztring::npos) SourcePath=SourceName.substr(0, Pos_Path); } size_t SourcePath_Size=SourcePath.size()+1; //Path size + path separator size for (size_t Pos=0; PosFileNames.size(); Pos++) { Ztring Temp=Sequences[Sequences_Current]->FileNames[Pos]; if (!Config->File_IsReferenced_Get()) Temp.erase(0, SourcePath_Size); MI->Fill(StreamKind_Target, StreamPos_Target, "Source_List", Temp); } if (!Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List")).empty()) { ZtringList List; List.Separator_Set(0, __T(" / ")); List.Write(Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List"))); for (size_t Pos=0; PosFile_IsReferenced_Get()) Temp.erase(0, SourcePath_Size); MI->Fill(StreamKind_Target, StreamPos_Target, "Source_List", Temp); } } (*MI->Stream_More)[StreamKind_Target][StreamPos_Target](Ztring().From_Local("Source_List"), Info_Options)=__T("N NT"); } #endif //MEDIAINFO_ADVANCED } #endif //MEDIAINFO_ADVANCED || MEDIAINFO_HASH //--------------------------------------------------------------------------- MediaInfo_Internal* File__ReferenceFilesHelper::MI_Create() { //Configuration MediaInfo_Internal* MI_Temp=new MediaInfo_Internal(); MI_Temp->Option(__T("File_IsReferenced"), __T("1")); MI_Temp->Option(__T("File_FileNameFormat"), __T("CSV")); MI_Temp->Option(__T("File_KeepInfo"), __T("1")); MI_Temp->Option(__T("File_ID_OnlyRoot"), Config->File_ID_OnlyRoot_Get()?__T("1"):__T("0")); MI_Temp->Option(__T("File_DvDif_DisableAudioIfIsInContainer"), Config->File_DvDif_DisableAudioIfIsInContainer_Get()?__T("1"):__T("0")); if ((Sequences.size()>1 || Config->File_MpegTs_ForceMenu_Get()) && !Sequences[Sequences_Current]->IsMain && !HasMainFile) MI_Temp->Option(__T("File_MpegTs_ForceMenu"), __T("1")); #if MEDIAINFO_AES MI_Temp->Option(__T("File_Encryption_Format"), MI->Retrieve(Stream_General, 0, "Encryption_Format")); MI_Temp->Option(__T("File_Encryption_Key"), Ztring().From_UTF8(Base64::encode(MI->Config->Encryption_Key_Get()))); MI_Temp->Option(__T("File_Encryption_Method"), MI->Retrieve(Stream_General, 0, "Encryption_Method")); MI_Temp->Option(__T("File_Encryption_Mode"), MI->Retrieve(Stream_General, 0, "Encryption_Mode")); MI_Temp->Option(__T("File_Encryption_Padding"), MI->Retrieve(Stream_General, 0, "Encryption_Padding")); MI_Temp->Option(__T("File_Encryption_InitializationVector"), MI->Retrieve(Stream_General, 0, "Encryption_InitializationVector")); #endif //AES #if MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get()) MI_Temp->Option(__T("File_NextPacket"), __T("1")); if (Config->File_Demux_Interleave_Get()) MI_Temp->Option(__T("File_Demux_Interleave"), __T("1")); #endif //MEDIAINFO_NEXTPACKET #if MEDIAINFO_ADVANCED if (Config->File_IgnoreSequenceFileSize_Get()) MI_Temp->Option(__T("File_IgnoreSequenceFileSize"), __T("1")); if (Config->File_IgnoreSequenceFilesCount_Get()) MI_Temp->Option(__T("File_IgnoreSequenceFilesCount"), __T("1")); if (Config->File_Source_List_Get()) MI_Temp->Option(__T("File_Source_List"), __T("1")); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong()) MI_Temp->Option(__T("File_Hash"), Config->Option(__T("File_Hash_Get"), Ztring())); #endif //MEDIAINFO_HASH #if MEDIAINFO_EVENTS MI_Temp->Config.Config_PerPackage=Config->Config_PerPackage; if (Config->Event_CallBackFunction_IsSet()) { MI_Temp->Option(__T("File_Event_CallBackFunction"), Config->Event_CallBackFunction_Get()); MI_Temp->Config.Config_PerPackage->Event_CallBackFunction_Set(Config->Event_CallBackFunction_Get()); } MI_Temp->Config.File_Names_RootDirectory=FileName(MI->File_Name).Path_Get(); if (Sequences[Sequences_Current]->FileNames.size()>1) MI_Temp->Option(__T("File_TestContinuousFileNames"), __T("0")); ZtringListList SubFile_IDs; if (Sequences[Sequences_Current]->IsMain) HasMainFile=true; if (HasMainFile && !Sequences[Sequences_Current]->IsMain) { ZtringList ID; ID.push_back(Ztring::ToZtring((((int64u)MediaInfo_Parser_SideCar)<<56)|Sequences[Sequences_Current]->StreamID-1)); ID.push_back(Ztring::ToZtring(16)); ID.push_back(Ztring::ToZtring(MediaInfo_Parser_SideCar)); SubFile_IDs.push_back(ID); } else if (!Sequences[Sequences_Current]->IsMain) for (size_t Pos=0; PosStreamIDs_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(Sequences[Sequences_Current]->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(",")); MI_Temp->Option(__T("File_SubFile_IDs_Set"), SubFile_IDs.Read()); } #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) MI_Temp->Option(__T("File_Demux_Unpacketize"), __T("1")); if (Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) MI_Temp->Option(__T("File_Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10"), __T("1")); if (Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()) MI_Temp->Option(__T("File_Demux_Hevc_Transcode_Iso14496_15_to_AnnexB"), __T("1")); if (FrameRate) MI_Temp->Option(__T("File_Demux_Rate"), Ztring::ToZtring(FrameRate)); else if (!Sequences[Sequences_Current]->Resources.empty() && Sequences[Sequences_Current]->Resources[0]->EditRate) //TODO: per Pos MI_Temp->Option(__T("File_Demux_Rate"), Ztring::ToZtring(Sequences[Sequences_Current]->Resources[0]->EditRate)); switch (Config->Demux_InitData_Get()) { case 0 : MI_Temp->Option(__T("File_Demux_InitData"), __T("Event")); break; case 1 : MI_Temp->Option(__T("File_Demux_InitData"), __T("Field")); break; default: ; } #endif //MEDIAINFO_DEMUX #if MEDIAINFO_IBIUSAGE if (!Sequences[Sequences_Current]->IbiStream.Infos.empty()) { ibi Ibi; Ibi.Streams[(int64u)-1]=new ibi::stream(Sequences[Sequences_Current]->IbiStream); //IBI Creation File_Ibi_Creation IbiCreation(Ibi); Ztring IbiText=IbiCreation.Finish(); if (!IbiText.empty()) MI_Temp->Option(__T("File_Ibi"), IbiText); } #endif //MEDIAINFO_IBIUSAGE return MI_Temp; } //--------------------------------------------------------------------------- void File__ReferenceFilesHelper::Read_Buffer_Unsynched() { MI->Open_Buffer_Unsynch(); for (size_t Sequences_Pos=0; Sequences_PosMI) Sequences[Sequences_Pos]->MI->Open_Buffer_Unsynch(); #if MEDIAINFO_DEMUX DTS_Minimal=(int64u)-1; Config->Demux_EventWasSent=true; //We want not try to read new data from the file #endif //MEDIAINFO_DEMUX } //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK Ztring Duration_Milliseconds2String(int64u DurationM) { Ztring DurationS; DurationS+=L'0'+(Char)(DurationM/(10*60*60*1000)); DurationM%=10*60*60*1000; DurationS+=L'0'+(Char)(DurationM/( 60*60*1000)); DurationM%= 60*60*1000; DurationS+=L':'; DurationS+=L'0'+(Char)(DurationM/( 10*60*1000)); DurationM%= 10*60*1000; DurationS+=L'0'+(Char)(DurationM/( 60*1000)); DurationM%= 60*1000; DurationS+=L':'; DurationS+=L'0'+(Char)(DurationM/( 10*1000)); DurationM%= 10*1000; DurationS+=L'0'+(Char)(DurationM/( 1000)); DurationM%= 1000; DurationS+=L'.'; DurationS+=L'0'+(Char)(DurationM/( 100)); DurationM%= 100; DurationS+=L'0'+(Char)(DurationM/( 10)); DurationM%= 10; DurationS+=L'0'+(Char)(DurationM); return DurationS; } size_t File__ReferenceFilesHelper::Seek (size_t Method, int64u Value, int64u ID) { for (Sequences_Current=0; Sequences_CurrentMI==NULL && !Sequences[Sequences_Current]->FileNames.empty()) ParseReference_Init(); //Parsing switch (Method) { case 0 : #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET { 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; DurationF*=1000; int64u DurationM=(int64u)DurationF; CountOfReferencesToParse=Sequences.size(); bool HasProblem=false; for (Sequences_Current=0; Sequences_CurrentMI) { Ztring Result; if (Sequences[Sequences_Current]->Resources.size()<=1 || DurationMResources[1]->Demux_Offset_DTS) { Sequences[Sequences_Current]->Resources_Current=0; int64u DurationFTemp=DurationF; if (Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1) DurationFTemp+=Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp); Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), DurationS); } else { size_t Resources_Current_Temp=1; while (Resources_Current_TempResources.size() && DurationM>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_DTS) Resources_Current_Temp++; Resources_Current_Temp--; int64u DurationFTemp=DurationF; if (Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1) DurationFTemp+=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp); Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), DurationS); if (Result.empty()) Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp; } if (!Result.empty()) HasProblem=true; } Sequences[Sequences_Current]->Status.reset(); } Sequences_Current=0; Open_Buffer_Unsynch(); return HasProblem?(size_t)-1:1; //Not supported value if there is a problem (TODO: better info) } CountOfReferencesToParse=Sequences.size(); bool HasProblem=false; for (Sequences_Current=0; Sequences_CurrentMI) { Sequences[Sequences_Current]->Resources_Current=0; Ztring Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), Ztring::ToZtring(Value)); if (!Result.empty()) HasProblem=true; } Sequences[Sequences_Current]->Status.reset(); } Sequences_Current=0; Open_Buffer_Unsynch(); return HasProblem?(size_t)-1:1; //Not supported value if there is a problem (TODO: better info) } #else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET case 1 : #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET { //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/=10; // divided by 10000 for 0.01 percentage then x1000 for milliseconds int64u DurationM=(int64u)DurationF; CountOfReferencesToParse=Sequences.size(); bool HasProblem=false; for (Sequences_Current=0; Sequences_CurrentMI) { Ztring Result; if (Sequences[Sequences_Current]->Resources.size()<2 || DurationResources[1]->Demux_Offset_DTS) { Sequences[Sequences_Current]->Resources_Current=0; int64u DurationFTemp=DurationF; if (Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1) DurationFTemp+=Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp); Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), DurationS); } else { size_t Resources_Current_Temp=1; while (Resources_Current_TempResources.size() && Duration>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_DTS) Resources_Current_Temp++; Resources_Current_Temp--; int64u DurationFTemp=DurationF; if (Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1) DurationFTemp+=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp); Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), DurationS); if (Result.empty()) Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp; } if (!Result.empty()) HasProblem=true; } Sequences[Sequences_Current]->Status.reset(); } Sequences_Current=0; Open_Buffer_Unsynch(); return HasProblem?2:1; //Invalid value if there is a problem (TODO: better info) } #else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET case 2 : //Timestamp #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET { CountOfReferencesToParse=Sequences.size(); for (Sequences_Current=0; Sequences_CurrentMI) { Ztring Result; if (Sequences[Sequences_Current]->Resources.size()<2 || ValueResources[1]->Demux_Offset_DTS) { Sequences[Sequences_Current]->Resources_Current=0; int64u ValueTemp=Value; if (Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1) ValueTemp+=Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream; Ztring Time; Time.Duration_From_Milliseconds(ValueTemp/1000000); Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), Time); } else { size_t Resources_Current_Temp=1; while (Resources_Current_TempResources.size() && Value>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_DTS) Resources_Current_Temp++; Resources_Current_Temp--; int64u ValueTemp=Value; if (Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1) ValueTemp+=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream; Ztring Time; Time.Duration_From_Milliseconds(ValueTemp/1000000); Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), Time); if (Result.empty()) Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp; } if (!Result.empty()) return 2; //Invalid value } else { //There was a problem, removing Sequence Sequences.clear(); return Seek(Method, Value, ID); } Sequences[Sequences_Current]->Status.reset(); } Sequences_Current=0; Open_Buffer_Unsynch(); return 1; } #else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET case 3 : //FrameNumber #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET CountOfReferencesToParse=Sequences.size(); for (Sequences_Current=0; Sequences_CurrentMI) { Ztring Result; if (Sequences[Sequences_Current]->Resources.size()<2 || ValueResources[1]->Demux_Offset_Frame) { Sequences[Sequences_Current]->Resources_Current=0; Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), __T("Frame=")+Ztring::ToZtring(Value)); } else { size_t Resources_Current_Temp=1; while (Resources_Current_TempResources.size() && Value>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_Frame) Resources_Current_Temp++; Resources_Current_Temp--; Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), __T("Frame=")+Ztring::ToZtring(Value-Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_Frame)); if (Result.empty()) Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp; } if (!Result.empty()) return 2; //Invalid value } Sequences[Sequences_Current]->Status.reset(); } Sequences_Current=0; Open_Buffer_Unsynch(); return 1; #else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET 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 (sequences::iterator ReferencePos=Sequences.begin(); ReferencePos!=Sequences.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 (size_t Sequences_Pos=0; Sequences_PosFileSize!=(int64u)-1) MI->Config->File_Size+=Sequences[Sequences_Pos]->FileSize; else if (Sequences[Sequences_Pos]->MI && Sequences[Sequences_Pos]->MI->Config.File_Size!=(int64u)-1) { MI->Config->File_Size+=Sequences[Sequences_Pos]->MI->Config.File_Size; #if MEDIAINFO_ADVANCED if (!Config->File_IgnoreSequenceFileSize_Get()) #endif //MEDIAINFO_ADVANCED { if (!Sequences[Sequences_Pos]->Resources.empty()) for (size_t Pos=1; PosResources.size(); Pos++) for (size_t Resource_FileNames_Pos=0; Resource_FileNames_PosResources[Pos]->FileNames.size(); Resource_FileNames_Pos++) MI->Config->File_Size+=File::Size_Get(Sequences[Sequences_Pos]->Resources[Pos]->FileNames[Resource_FileNames_Pos]); } } else { #if MEDIAINFO_ADVANCED if (!Config->File_IgnoreSequenceFileSize_Get()) #endif //MEDIAINFO_ADVANCED { if (Sequences[Sequences_Pos]->Resources.empty()) for (size_t Pos=0; PosFileNames.size(); Pos++) MI->Config->File_Size+=File::Size_Get(Sequences[Sequences_Pos]->FileNames[Pos]); else for (size_t Pos=0; PosResources.size(); Pos++) for (size_t Resource_FileNames_Pos=0; Resource_FileNames_PosResources[Pos]->FileNames.size(); Resource_FileNames_Pos++) MI->Config->File_Size+=File::Size_Get(Sequences[Sequences_Pos]->Resources[Pos]->FileNames[Resource_FileNames_Pos]); } } } } //--------------------------------------------------------------------------- void File__ReferenceFilesHelper::CountOfReferences_ForReadSize_Run () { //Computing read buffer size int64u File_Size_Total=0; int64u Buffer_Read_Size_Total=MI->Config->File_Buffer_Read_Size_Get(); for (sequences::iterator Reference_Temp=Sequences.begin(); Reference_Temp!=Sequences.end(); ++Reference_Temp) if ((*Reference_Temp)->MI && (*Reference_Temp)->MI->Config.File_Size!=(int64u)-1) File_Size_Total+=(*Reference_Temp)->MI->Config.File_Size; if (File_Size_Total) for (sequences::iterator Reference_Temp=Sequences.begin(); Reference_Temp!=Sequences.end(); ++Reference_Temp) if ((*Reference_Temp)->MI) { int64u Buffer_Read_Size_Temp=float64_int64s(((float64)(*Reference_Temp)->MI->Config.File_Size)/File_Size_Total*Buffer_Read_Size_Total); int64u Buffer_Read_Size=1; while (Buffer_Read_SizeMI->Config.File_Buffer_Read_Size_Set((size_t)Buffer_Read_Size); } } //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS void File__ReferenceFilesHelper::SubFile_Start() { if (Sequences[Sequences_Current]->StreamID!=StreamID_Previous) { Ztring FileName_Absolute, FileName_Relative; if (Sequences[Sequences_Current]->MI && Sequences[Sequences_Current]->MI->Config.File_Names_Pos && Sequences[Sequences_Current]->MI->Config.File_Names_PosMI->Config.File_Names.size()) FileName_Absolute=Sequences[Sequences_Current]->MI->Config.File_Names[Sequences[Sequences_Current]->MI->Config.File_Names_Pos-1]; else if (!Sequences[Sequences_Current]->FileNames.empty()) FileName_Absolute=Sequences[Sequences_Current]->FileNames[0]; else FileName_Absolute=Sequences[Sequences_Current]->Source.c_str(); Sequences[Sequences_Current]->MI->Config.Event_SubFile_Start(FileName_Absolute); StreamID_Previous=Sequences[Sequences_Current]->StreamID; } } #endif //MEDIAINFO_EVENTS } //NameSpace #endif //MEDIAINFO_REFERENCES_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Dvdv.h0000664000000000000000000000620012652076434020750 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DVD objects // (.ifo files on DVD-Video) // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DvdvH #define MediaInfo_File_DvdvH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 Sectors; //std::vector > Sectors_Times; //std::vector 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 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Umf.h0000664000000000000000000000266312652076434020605 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about UMF files // Unified Material Format // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_UmfH #define MediaInfo_File_UmfH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Aaf.cpp0000664000000000000000000005643412652076434021105 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_AAF_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Aaf.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "ZenLib/FileName.h" #include "ZenLib/File.h" #include "tinyxml2.h" using namespace ZenLib; using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** const char* AAf_tagSTGTY (int8u tagSTGTY) { switch (tagSTGTY) { case 0 : return "unknown"; case 1 : return "storage"; case 2 : return "stream"; case 3 : return "ILockBytes"; case 4 : return "IPropertyStorage"; case 5 : return "root"; default: return ""; } } const char* AAf_tagDECOLOR (int8u tagDECOLOR) { switch (tagDECOLOR) { case 0 : return "red"; case 1 : return "black"; default: return ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Aaf::File_Aaf() :File__Analyze() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Aaf; StreamIDs_Width[0]=16; #endif //MEDIAINFO_EVENTS //Temp ReferenceFiles=NULL; } //--------------------------------------------------------------------------- File_Aaf::~File_Aaf() { for (size_t Pos=0; PosParseReferences(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_Aaf::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { if (ReferenceFiles==NULL) return 0; return ReferenceFiles->Seek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Aaf::FileHeader_Begin() { if (File_Size<0x100) { Reject("Aaf"); return false; } //Element_Size if (Buffer_Size<0x18) return false; //Must wait for more data if (Buffer[ 0x0]!=0xD0 || Buffer[ 0x1]!=0xCF || Buffer[ 0x2]!=0x11 || Buffer[ 0x3]!=0xE0 || Buffer[ 0x4]!=0xA1 || Buffer[ 0x5]!=0xB1 || Buffer[ 0x6]!=0x1A || Buffer[ 0x7]!=0xE1 || Buffer[ 0x8]!=0x41 || Buffer[ 0x9]!=0x41 || Buffer[ 0xA]!=0x46 || Buffer[ 0xB]!=0x42 || Buffer[ 0xC]!=0x0D || Buffer[ 0xD]!=0x00 || Buffer[ 0xE]!=0x4F || Buffer[ 0xF]!=0x4D || Buffer[0x10]!=0x06 || Buffer[0x11]!=0x0E || Buffer[0x12]!=0x2B || Buffer[0x13]!=0x34 || Buffer[0x14]!=0x01 || Buffer[0x15]!=0x01 || Buffer[0x16]!=0x01 || Buffer[0x17]!=0xFF) { Reject("Aaf"); return false; } //Element_Size if (Buffer_Size109?109:csectFat); Pos++) { int32u sectFat; Get_L4 (sectFat, "sectFat"); sectsFat.push_back(sectFat); } if (csectFat<109) Skip_XX((109-csectFat)*4, "unused sectsFat"); Element_End(); Element_End(); FILLING_BEGIN(); Fill("Aaf"); Step=Step_Fat; sectsFat_Pos=0; if (sectsFat.empty()) { Finish(); } else GoTo((1+sectsFat[0])*(1<Size>SectorShift)-1; if (Pointers_PosStreamOffsets[0]); } } else Finish(); } else Finish(); } //--------------------------------------------------------------------------- void File_Aaf::Fat() { //Parsing while (Element_Offset>(SectorShift-MiniSectorShift); int32u MiniSectPos=Pointers_Pos&((((size_t)1)<<(SectorShift-MiniSectorShift))-1); Stream->StreamOffsets.push_back(((1+sectsMiniStream[SectPos])<StreamOffsets.push_back((1+Pointers_Pos)<=Streams.size() || Streams[Streams_Pos]->Size>=0x1000000) //TODO: more serious test about size return; //Incoherancy //Saving data if (Streams[Streams_Pos]->StreamOffsets.size()!=1) { Skip_XX(Element_Size, "Stream data"); int16u Shift=(Streams[Streams_Pos]->SizeBuffer==NULL) Streams[Streams_Pos]->Buffer=new int8u[(size_t)((1+(Streams[Streams_Pos]->Size>>Shift))<Buffer+Streams_Pos2*(((int64u)1)<=Streams[Streams_Pos]->StreamOffsets.size()) { Element_Offset=0; StreamElement_Parse(); Streams_Pos++; Streams_Pos2=0; } if (Streams_PosStreamOffsets[Streams_Pos2]); else Finish(); } //--------------------------------------------------------------------------- void File_Aaf::StreamElement_Parse() { //Searching emulation_prevention_three_byte const int8u* Save_Buffer=Buffer; int64u Save_File_Offset=File_Offset; size_t Save_Buffer_Offset=Buffer_Offset; int64u Save_Element_Size=Element_Size; if (Streams[Streams_Pos]->Buffer) { //We must change the buffer for keeping out Element_Size=Streams[Streams_Pos]->Size; File_Offset=Streams[Streams_Pos]->StreamOffsets[0]; Buffer_Offset=0; Buffer=Streams[Streams_Pos]->Buffer; } //Parsing Element_Info1(Streams[Streams_Pos]->Directory_Pos); Element_Info1(Streams[Streams_Pos]->Name); int16u Count; Skip_L2( "0x204C?"); Get_L2 (Count, "Count"); vector Sizes; vector Keys; for (int16u Pos=0; PosBuffer) { //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; Element_Offset=Element_Size; } } //--------------------------------------------------------------------------- void File_Aaf::MetaDictionary() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::Header() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::ClassDefinitions() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::TypeDefinitions() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::Identification() { Skip_B8( "Part2"); Skip_B8( "Part1"); } //--------------------------------------------------------------------------- void File_Aaf::Name() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::MetaDefinition() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::ParentClass() { Skip_B5( "WeakReference"); Skip_B8( "Part2"); Skip_B8( "Part1"); } //--------------------------------------------------------------------------- void File_Aaf::Properties() { Skip_UTF16L(xxxSize, "Data"); } //--------------------------------------------------------------------------- void File_Aaf::IsConcrete() { Skip_L1( "Data"); } //--------------------------------------------------------------------------- void File_Aaf::Type() { Skip_B8( "Part2"); Skip_B8( "Part1"); } //--------------------------------------------------------------------------- void File_Aaf::IsOptional() { Skip_L1( "Data"); } //--------------------------------------------------------------------------- void File_Aaf::LocalIdentification() { Skip_L2( "Data"); } //--------------------------------------------------------------------------- void File_Aaf::IsUniqueIdentifier() { Skip_L1( "Data"); } //--------------------------------------------------------------------------- void File_Aaf::Size() { Skip_L1( "Data"); } //--------------------------------------------------------------------------- void File_Aaf::Locked() { Skip_L1( "Data"); //Descriptors[Streams[Streams_Pos]->Directory_Pos].StreamKind=Stream_Audio; } //--------------------------------------------------------------------------- void File_Aaf::NetworkLocator() { Ztring Data; Get_UTF16L(xxxSize, Data, "Data"); sequence* Sequence=new sequence; Sequence->AddFileName(Data); ReferenceFiles->AddSequence(Sequence); //Locators[Streams[Streams_Pos]->Directory_Pos].EssenceLocator=Data; } } //NameSpace #endif //MEDIAINFO_AAF_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg4_Descriptors.h0000664000000000000000000001134212652076434023405 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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; size_t PosOfStream; 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Ogg_SubElement.h0000664000000000000000000000513712652076434022714 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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_OpusHead(); 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Ibi_Creation.cpp0000664000000000000000000005213712652076434022741 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if MEDIAINFO_IBIUSAGE //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Ibi_Creation.h" #include #include #include #include "base64.h" #include "ZenLib/File.h" #include "ZenLib/OS_Utils.h" #ifdef WINDOWS #undef __TEXT #include #endif using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** extern const Char* MediaInfo_Version; //*************************************************************************** // 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>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; PosContent=new int8u[1+int64u2Ebml(NULL, 1+int64u2Ebml(NULL, BlockSizeWithoutHeader))+BlockSizeWithoutHeader]; Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x05); //Source information Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, BlockSizeWithoutHeader); //Size Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x01); //Index creation date Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 8); //Size int64u2BigEndian(Buffer->Content+Buffer->Size, (int64u)CurrentDate); Buffer->Size+=8; //Content if (LastModifiedDate_IsValid) { Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x02); //Source file modification date Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 8); //Size int64u2BigEndian(Buffer->Content+Buffer->Size, (int64u)LastModifiedDate); Buffer->Size+=8; //Content } if (FileSize_IsValid) { Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x03); //Source file size Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 8); //Size int64u2BigEndian(Buffer->Content+Buffer->Size, (int64u)CurrentDate); Buffer->Size+=8; //Content } Buffers.push_back(Buffer); } //Writing application { string Version=Ztring(MediaInfo_Version).SubString(__T(" - v"), Ztring()).To_UTF8(); buffer* Buffer=new buffer; Buffer->Content=new int8u[1+int64u2Ebml(NULL, 1+1+9+1+int64u2Ebml(NULL, Version.size())+Version.size())+1+1+9+1+int64u2Ebml(NULL, Version.size())+Version.size()]; Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x03); //Writing application Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 1+1+9+1+1+Version.size()); //Size Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x01); //Writing application name Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 9); //Size std::memcpy(Buffer->Content+Buffer->Size, "MediaInfo", 9); Buffer->Size+=9; //Content Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x02); //Writing application version Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, Version.size()); //Size std::memcpy(Buffer->Content+Buffer->Size, Version.c_str(), Version.size()); Buffer->Size+=Version.size(); //Content Buffers.push_back(Buffer); } //InformData if (!Ibi.Inform_Data.empty()) { string Content(Ibi.Inform_Data.To_UTF8()); buffer* Buffer=new buffer; Buffer->Content=new int8u[1+int64u2Ebml(NULL, Content.size())+Content.size()]; Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x04); //InformData Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, Content.size()); //Size std::memcpy(Buffer->Content+Buffer->Size, Content.c_str(), Content.size()); Buffer->Size+=Content.size(); //Content Buffers.push_back(Buffer); } //Streams 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[16+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; PosContent=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); //Finish delete[] IbiByteOffset; //IbiByteOffset=NULL; delete[] IbiFrameNumber; //IbiFrameNumber=NULL; delete[] IbiDts; //IbiDts=NULL; } 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; PosSize; //Buffer creation int8u* Main=new int8u[Size]; size_t Main_Offset=0; //Header size_t Header_Offset=4+1+2+1+15+2+1+1; //Size (Code + Size + Content, twice) Main_Offset+=int64u2Ebml(Main+Main_Offset, 0x0A45DFA3); //EBML Main_Offset+=int64u2Ebml(Main+Main_Offset, Header_Offset-(4+1)); //Size (Complete header size minus header header size) 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; PosContent, Buffers[Pos]->Size); Main_Offset+=Buffers[Pos]->Size; } //Compressed if (Header_Offset < Main_Offset) { buffer Buffer; size_t UncompressedSize = Main_Offset - Header_Offset; int8u* Compressed = new int8u[UncompressedSize]; unsigned long CompressedSize = (unsigned long)Main_Offset; if (compress2(Compressed, &CompressedSize, Main + Header_Offset, (unsigned long)UncompressedSize, Z_BEST_COMPRESSION) == Z_OK && CompressedSize < UncompressedSize) { Main_Offset = Header_Offset; //Removing uncompressed content Main_Offset += int64u2Ebml(Main + Main_Offset, 0x02); //Compressed index Main_Offset += int64u2Ebml(Main + Main_Offset, int64u2Ebml(NULL, UncompressedSize) + CompressedSize); //Size Main_Offset += int64u2Ebml(Main + Main_Offset, UncompressedSize); //Uncompressed size //Filling Buffer.Size = Main_Offset + CompressedSize; Buffer.Content = new int8u[Buffer.Size]; std::memcpy(Buffer.Content, Main, Main_Offset); //File header + compressed data header std::memcpy(Buffer.Content + Main_Offset, Compressed, CompressedSize); //Compressed data } else { //Filling Buffer.Size = Size; Buffer.Content = new int8u[Buffer.Size]; std::memcpy(Buffer.Content, Main, Size); } std::string Data_Raw((const char*)Buffer.Content, Buffer.Size); std::string Data_Base64(Base64::encode(Data_Raw)); delete[] Main; //Main=NULL; return Ztring().From_UTF8(Data_Base64); } else { delete[] Main; //Main=NULL; return Ztring(); } } } //NameSpace #endif //MEDIAINFO_IBIUSAGE MediaInfoLib/Source/MediaInfo/Multiple/File_Ancillary.cpp0000664000000000000000000015047212652076434022331 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #if defined(MEDIAINFO_TIMECODE_YES) #include "MediaInfo/Multiple/File_Gxf_TimeCode.h" #endif #if defined(MEDIAINFO_ARIBSTDB24B37_YES) #include "MediaInfo/Text/File_AribStdB24B37.h" #endif #if defined(MEDIAINFO_SDP_YES) #include "MediaInfo/Text/File_Sdp.h" #endif #if defined(MEDIAINFO_MXF_YES) #include "MediaInfo/Multiple/File_Mxf.h" #endif #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- //*************************************************************************** // Infos //*************************************************************************** const char* Ancillary_DataID(int8u DataID, int8u SecondaryDataID) { // TODO: check http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.1364-2-201003-I!!PDF-E.pdf switch (DataID) { case 0x00 : return "Undefined"; case 0x08 : switch (SecondaryDataID) { case 0x0C : return "MPEG-2 Recoding Information"; //SMPTE ST 353 default : return "(Reserved for 8-bit applications)"; } break; case 0x40 : switch (SecondaryDataID) { case 0x01 : //SMPTE ST 305 case 0x02 : return "SDTI"; //SMPTE ST 348 case 0x04 : //SMPTE ST 427 case 0x05 : //SMPTE ST 427 case 0x06 : return "Link Encryption Key"; //SMPTE ST 427 default : return "(Internationally registered)"; } break; case 0x41 : switch (SecondaryDataID) { case 0x01 : return "Payload identifier"; //SMPTE ST 352 case 0x05 : return "Bar Data"; //SMPTE ST 2016 case 0x06 : return "Pan-Scan Information"; //SMPTE ST 2016 case 0x07 : return "ANSI/SCTE 104 Messages"; //SMPTE ST 2010 case 0x08 : return "DVB/SCTE VBI Data"; //SMPTE ST 2031 default : return "(Internationally registered)"; } break; case 0x43 : switch (SecondaryDataID) { case 0x02 : return "SDP"; //OP-47 SDP, also RDD 8 case 0x03 : return "Multipacket"; //OP-47 Multipacket, also RDD 8 case 0x05 : return "Acquisition Metadata"; //RDD 18 default : return "(Internationally registered)"; } break; case 0x44 : switch (SecondaryDataID) { case 0x44 : return "ISAN or UMID"; //SMPTE RP 223 default : return "(Internationally registered)"; } break; case 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 "(Internationally registered)"; } break; case 0x46 : switch (SecondaryDataID) { case 0x01 : return "Two-Frame Marker"; //SMPTE RP 2051 default : return "(Internationally registered)"; } break; case 0x50 : switch (SecondaryDataID) { case 0x01 : return "WSS"; //RDD 8 default : return "(Reserved)"; } break; case 0x51 : switch (SecondaryDataID) { case 0x01 : return "Film Transfer and Video Production Information"; //RP 215 default : return "(Reserved)"; } break; case 0x5F : switch (SecondaryDataID&0xF0) { case 0xD0 : return "ARIB STD B37"; //ARIB STD B37 default : return "(Reserved)"; } break; case 0x60 : switch (SecondaryDataID) { case 0x60 : return "ATC"; //SMPTE RP 188 / SMPTE ST 12-2 default : return "(Internationally registered)"; } break; case 0x61 : switch (SecondaryDataID) { case 0x01 : return "CDP"; //SMPTE 334 case 0x02 : return "CEA-608"; //SMPTE 334 default : return "(Internationally registered)"; } break; case 0x62 : switch (SecondaryDataID) { case 0x01 : return "Program description"; //SMPTE 334 case 0x02 : return "Data broadcast"; //SMPTE 334 case 0x03 : return "VBI data"; //SMPTE 334 default : return "(Internationally registered)"; } break; case 0x64 : switch (SecondaryDataID) { case 0x64 : return "LTC"; //SMPTE RP 196 case 0x6F : return "VITC"; //SMPTE RP 196 default : return "(Internationally registered)"; } break; case 0x80 : return "Marked for deletion"; case 0x84 : return "Data end marker"; case 0x88 : return "Data start marker"; default : if (DataID<=0x03) return "(Reserved)"; else if (DataID<=0x0F) return "(Reserved for 8-bit applications)"; else if (DataID<=0x3F) return "(Reserved)"; else if (DataID<=0x4F) return "(Internationally registered)"; else if (DataID<=0x5F) return "(Reserved)"; else if (DataID<=0x7F) return "(Internationally registered)"; else if (DataID<=0x83) return "(Reserved)"; else if (DataID<=0x87) return "(Reserved)"; else if (DataID<=0x9F) return "(Reserved)"; else if (DataID<=0xBF) return "(Internationally registered)"; else if (DataID<=0xCF) return "User application"; else return "(Internationally registered)"; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Ancillary::File_Ancillary() :File__Analyze() { //Configuration ParserName=__T("Ancillary"); #if MEDIAINFO_EVENTS StreamIDs_Width[0]=4; #endif //MEDIAINFO_EVENTS PTS_DTS_Needed=true; //In WithTenBit=false; WithChecksum=false; HasBFrames=false; InDecodingOrder=false; LineNumber_IsSecondField=false; AspectRatio=0; FrameRate=0; LineNumber=(int32u)-1; #if defined(MEDIAINFO_CDP_YES) Cdp_Parser=NULL; #endif //defined(MEDIAINFO_CDP_YES) #if defined(MEDIAINFO_ARIBSTDB24B37_YES) AribStdB34B37_Parser=NULL; #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) #if defined(MEDIAINFO_SDP_YES) Sdp_Parser=NULL; #endif //defined(MEDIAINFO_SDP_YES) #if defined(MEDIAINFO_MXF_YES) Rdd18_Parser=NULL; #endif //defined(MEDIAINFO_MXF_YES) } //--------------------------------------------------------------------------- File_Ancillary::~File_Ancillary() { #if defined(MEDIAINFO_CDP_YES) delete Cdp_Parser; //Cdp_Parser=NULL; for (size_t Pos=0; PosStatus[IsFinished] && Cdp_Parser->Status[IsAccepted]) { size_t StreamPos_Base=Count_Get(Stream_Text); Finish(Cdp_Parser); for (size_t StreamPos=0; StreamPosCount_Get(Stream_Text); StreamPos++) { Merge(*Cdp_Parser, Stream_Text, StreamPos, StreamPos_Base+StreamPos); Ztring MuxingMode=Cdp_Parser->Retrieve(Stream_Text, StreamPos, "MuxingMode"); Fill(Stream_Text, StreamPos_Last, "MuxingMode", __T("Ancillary data / ")+MuxingMode, true); } Ztring LawRating=Cdp_Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Cdp_Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } #endif //defined(MEDIAINFO_CDP_YES) #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (AribStdB34B37_Parser && !AribStdB34B37_Parser->Status[IsFinished] && AribStdB34B37_Parser->Status[IsAccepted]) { size_t StreamPos_Base=Count_Get(Stream_Text); Finish(AribStdB34B37_Parser); for (size_t StreamPos=0; StreamPosCount_Get(Stream_Text); StreamPos++) { Merge(*AribStdB34B37_Parser, Stream_Text, StreamPos, StreamPos_Base+StreamPos); Ztring MuxingMode=AribStdB34B37_Parser->Retrieve(Stream_Text, StreamPos, "MuxingMode"); Fill(Stream_Text,StreamPos_Last, "MuxingMode", __T("Ancillary data / ")+MuxingMode, true); } } #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) #if defined(MEDIAINFO_SDP_YES) if (Sdp_Parser && !Sdp_Parser->Status[IsFinished] && Sdp_Parser->Status[IsAccepted]) { size_t StreamPos_Base=Count_Get(Stream_Text); Finish(Sdp_Parser); for (size_t StreamPos=0; StreamPosCount_Get(Stream_Text); StreamPos++) { Merge(*Sdp_Parser, Stream_Text, StreamPos, StreamPos_Base+StreamPos); Ztring MuxingMode=Sdp_Parser->Retrieve(Stream_General, 0, General_Format); Fill(Stream_Text, StreamPos_Last, "MuxingMode", __T("Ancillary data / OP-47 / ")+MuxingMode, true); } } #endif //defined(MEDIAINFO_SDP_YES) #if defined(MEDIAINFO_MXF_YES) if (Rdd18_Parser && !Rdd18_Parser->Status[IsFinished] && Rdd18_Parser->Status[IsAccepted]) { size_t StreamPos_Base=Count_Get(Stream_Other); Finish(Rdd18_Parser); for (size_t StreamPos=0; StreamPosCount_Get(Stream_Other); StreamPos++) { Merge(*Rdd18_Parser, Stream_Other, StreamPos, StreamPos_Base+StreamPos); Fill(Stream_Other, StreamPos_Last, Other_Format, "Acquisition Metadata", Unlimited, true, true); Fill(Stream_Other, StreamPos_Last, Other_MuxingMode, "Ancillary data / RDD 18"); } } #endif //defined(MEDIAINFO_MXF_YES) //Unsupported streams for (DataID = 0; DataIDsecond.StreamKind); for (std::map::iterator Info=Stream->second.Infos.begin(); Info!=Stream->second.Infos.end(); ++Info) Fill(Stream->second.StreamKind, StreamPos_Last, Info->first.c_str(), Info->second); } } //*************************************************************************** // 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++; //Parsing last bytes if needed if (Buffer_Offset+6>Buffer_Size) { if (Buffer_Offset+5==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x00FFFF) Buffer_Offset++; if (Buffer_Offset+4==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x00FFFF) Buffer_Offset++; if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x00FFFF) Buffer_Offset++; if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x00FF) Buffer_Offset++; if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x00) Buffer_Offset++; return false; } if (!Status[IsAccepted]) { Accept(); } //Synched is OK return true; } //--------------------------------------------------------------------------- bool File_Ancillary::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)!=0x00FFFF) { Synched=false; if (IsSub) Buffer_Offset=Buffer_Size; // We don't trust the rest of the stream, we never saw real data when sync is lost and there are lot of false-positives if we sync only on 0x00FFFF } //We continue return true; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Ancillary::Read_Buffer_Continue() { if (Element_Size==0) { #if defined(MEDIAINFO_CDP_YES) if (!Cdp_Data.empty() && AspectRatio && FrameRate) { ((File_Cdp*)Cdp_Parser)->AspectRatio=AspectRatio; for (size_t Pos=0; PosPTS_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(); } #endif //defined(MEDIAINFO_CDP_YES) #if defined(MEDIAINFO_AFDBARDATA_YES) //Keeping only one, TODO: parse it without video stream for (size_t Pos=1; PosOpen_Buffer_Unsynch(); #endif //defined(MEDIAINFO_CDP_YES) #if defined(MEDIAINFO_AFDBARDATA_YES) for (size_t Pos=0; PosOpen_Buffer_Unsynch(); #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) #if defined(MEDIAINFO_SDP_YES) if (Sdp_Parser) Sdp_Parser->Open_Buffer_Unsynch(); #endif //defined(MEDIAINFO_SDP_YES) #if defined(MEDIAINFO_MXF_YES) if (Rdd18_Parser) Rdd18_Parser->Open_Buffer_Unsynch(); #endif //defined(MEDIAINFO_MXF_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]; Element_Begin1("Raw data"); for(int8u Pos=0; PosData=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; case 0x06 : //SMPTE ST 2016 if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="Pan-Scan Information"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 2016"; } break; case 0x07 : //SMPTE ST 2010 if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="ANSI/SCTE 104 Messages"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 2010"; } break; case 0x08 : //SMPTE ST 2031 if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="DVB/SCTE VBI Data"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 2031"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x43 : switch (SecondaryDataID) { case 0x02 : //OP-47 SDP, also RDD 8 #if defined(MEDIAINFO_SDP_YES) if (Sdp_Parser==NULL) { Sdp_Parser=new File_Sdp; Open_Buffer_Init(Sdp_Parser); } if (!Sdp_Parser->Status[IsFinished]) { if (Sdp_Parser->PTS_DTS_Needed) Sdp_Parser->FrameInfo=FrameInfo; Demux(Payload, (size_t)DataCount, ContentType_MainStream); Open_Buffer_Continue(Sdp_Parser, Payload, (size_t)DataCount); } #endif //defined(MEDIAINFO_SDP_YES) break; case 0x03 : //OP-47 Multipacket, also RDD 8 if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / OP-47 / Multipacket"; } break; case 0x05 : //RDD 18 #if defined(MEDIAINFO_MXF_YES) if (Rdd18_Parser==NULL) { Rdd18_Parser=new File_Mxf; Open_Buffer_Init(Rdd18_Parser); } if (!Rdd18_Parser->Status[IsFinished]) { Rdd18_Parser->Frame_Count=Frame_Count; Open_Buffer_Continue(Rdd18_Parser, Payload+1, (size_t)DataCount-1); } #endif //defined(MEDIAINFO_MXF_YES) break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x44 : switch (SecondaryDataID) { case 0x44 : //SMPTE RP 223 if (TestAndPrepare()) { switch (DataCount) { case 0x19: Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="ISAN"; break; case 0x20: case 0x40: Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="UMID"; break; } Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE RP 223"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } 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 if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="Audio Metadata"; if (SecondaryDataID>1) Unknown[DataID][SecondaryDataID][string()].Infos["Format_Settings"]=__T("Channel pair ")+Ztring::ToZtring((SecondaryDataID-1)*2-1)+__T('/')+Ztring::ToZtring((SecondaryDataID-1)*2); Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 2020"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x46 : switch (SecondaryDataID) { case 0x01 : // (from SMPTE ST 2051) if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="Two-Frame Marker"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 2051"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x50 : switch (SecondaryDataID) { case 0x01: //RDD 8 if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="WSS"; //TODO: inject it in the video stream when a sample is available Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / RDD 8"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x5F : // (from ARIB STD-B37) if ((SecondaryDataID&0xF0)==0xD0) //Digital Closed Caption { #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (AribStdB34B37_Parser==NULL) { AribStdB34B37_Parser=new File_AribStdB24B37; ((File_AribStdB24B37*)AribStdB34B37_Parser)->IsAncillaryData=true; ((File_AribStdB24B37*)AribStdB34B37_Parser)->ParseCcis=true; Open_Buffer_Init(AribStdB34B37_Parser); } if (!AribStdB34B37_Parser->Status[IsFinished]) { if (AribStdB34B37_Parser->PTS_DTS_Needed) AribStdB34B37_Parser->FrameInfo=FrameInfo; Open_Buffer_Continue(AribStdB34B37_Parser, Payload, (size_t)DataCount); } #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) } else if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } break; case 0x60 : switch (SecondaryDataID) { case 0x60 : // (from SMPTE RP 188 / SMPTE ST 12-2) // Time code ATC #if defined(MEDIAINFO_TIMECODE_YES) { File_Gxf_TimeCode Parser; Parser.IsAtc=true; Open_Buffer_Init(&Parser); Open_Buffer_Continue(&Parser, Payload, (size_t)DataCount); string Unique=Ztring().From_Number(LineNumber).To_UTF8()+(LineNumber_IsSecondField?"IsSecondField":"")+Parser.Settings; if (TestAndPrepare(&Unique)) { Unknown[DataID][SecondaryDataID][Unique].Infos["Type"]="Time code"; Unknown[DataID][SecondaryDataID][Unique].Infos["Format"]="SMPTE ATC"; Unknown[DataID][SecondaryDataID][Unique].Infos["TimeCode_FirstFrame"].From_UTF8(Parser.TimeCode_FirstFrame.c_str()); Unknown[DataID][SecondaryDataID][Unique].Infos["TimeCode_Settings"].From_UTF8(Parser.Settings.c_str()); Unknown[DataID][SecondaryDataID][Unique].Infos["MuxingMode"]="Ancillary data / SMPTE RP 188"; if (LineNumber!=(int32u)-1) Unknown[DataID][SecondaryDataID][Unique].Infos["ID"]=__T("Line")+Ztring::ToZtring(LineNumber); if (LineNumber_IsSecondField) Unknown[DataID][SecondaryDataID][Unique].Infos["IsSecondField"]="Yes"; } } #endif //defined(MEDIAINFO_TIMECODE_YES) break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x61 : //Defined data services (from SMPTE 334-1) switch (SecondaryDataID) { case 0x01 : //CDP (from SMPTE 334-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 334-1) if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].StreamKind=Stream_Text; Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="CEA-608"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE 334"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x62 : //Variable-format data services (from SMPTE 334-1) switch (SecondaryDataID) { case 0x01 : //Program description (from SMPTE 334-1), if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="Program description"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 334"; } break; case 0x02 : //Data broadcast (from SMPTE 334-1) if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="Data broadcast"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 334"; } break; case 0x03 : //VBI data (from SMPTE 334-1) if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]="VBI data"; Unknown[DataID][SecondaryDataID][string()].Infos["MuxingMode"]="Ancillary data / SMPTE ST 334"; } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x64 : switch (SecondaryDataID) { case 0x64 : // (from SMPTE RP 196) // LTC in HANC space { string Unique=Ztring().From_Number(LineNumber).To_UTF8(); if (TestAndPrepare(&Unique)) { Unknown[DataID][SecondaryDataID][Unique].Infos["Type"]="Time code"; Unknown[DataID][SecondaryDataID][Unique].Infos["Format"]="LTC"; Unknown[DataID][SecondaryDataID][Unique].Infos["MuxingMode"]="Ancillary data / SMPTE RP 196"; if (LineNumber!=(int32u)-1) Unknown[DataID][SecondaryDataID][Unique].Infos["ID"]=__T("Line")+Ztring::ToZtring(LineNumber); } } break; case 0x7F : // (from SMPTE RP 196) // VITC in HANC space { string Unique=Ztring().From_Number(LineNumber).To_UTF8(); if (TestAndPrepare(&Unique)) { Unknown[DataID][SecondaryDataID][Unique].Infos["Type"]="Time code"; Unknown[DataID][SecondaryDataID][Unique].Infos["Format"]="VITC"; Unknown[DataID][SecondaryDataID][Unique].Infos["MuxingMode"]="Ancillary data / SMPTE RP 196"; if (LineNumber!=(int32u)-1) Unknown[DataID][SecondaryDataID][Unique].Infos["ID"]=__T("Line")+Ztring::ToZtring(LineNumber); } } break; default : if (TestAndPrepare()) { Unknown[DataID][SecondaryDataID][string()].Infos["Format"]=Ztring().From_CC1(DataID)+__T('-')+Ztring().From_CC1(SecondaryDataID); } } break; case 0x00 : // Undefined format case 0x80 : // Marked for deletion case 0x84 : // End marker case 0x88 : // Start marker break; default : if (TestAndPrepare()) { Unknown[DataID][(DataID<0x80?SecondaryDataID:0)][string()].Infos["Format"]=Ztring().From_CC1(DataID)+((DataID<0x80)?(__T('-')+Ztring().From_CC1(SecondaryDataID)):Ztring()); } } FILLING_END(); delete[] Payload; //Payload=NULL } //*************************************************************************** // Presence //*************************************************************************** //--------------------------------------------------------------------------- bool File_Ancillary::TestAndPrepare(const string* Unique) { if (DataID>=Unknown.size()) Unknown.resize(DataID+1); int8u RealSecondaryDataID=(DataID<0x80?SecondaryDataID:0); if (RealSecondaryDataID>=Unknown[DataID].size()) Unknown[DataID].resize(RealSecondaryDataID+1); if (Unique) { perid::iterator Item = Unknown[DataID][RealSecondaryDataID].find(*Unique); if (Item!=Unknown[DataID][RealSecondaryDataID].end()) return false; } else { if (!Unknown[DataID][RealSecondaryDataID].empty()) return false; } return true; } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_ANCILLARY_YES MediaInfoLib/Source/MediaInfo/Multiple/File_DvDif.h0000664000000000000000000002216712652076434021053 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 Infos; }; std::vector Streams_Audio; //Temp #if defined(MEDIAINFO_EIA608_YES) std::vector CC_Parsers; #endif Ztring Recorded_Date_Date; Ztring Recorded_Date_Time; Ztring Encoded_Library_Settings; string TimeCode_FirstFrame; int64u Duration; int64u TimeCode_FirstFrame_ms; 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 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 Video_STA_Errors; //Per STA type std::vector Video_STA_Errors_Total; //Per STA type std::vector Audio_Errors; //Per Dseq std::vector audio_source_IsPresent; std::vector CH_IsPresent; std::vector > Audio_Errors_Total; //Per Channel and Dseq std::vector > Audio_Invalids; //Per Channel and Dseq std::vector > 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 Speed_RecZ; struct timeCodeZ_Single { int64u FramePos; Ztring TimeCode; timeCodeZ_Single() { FramePos=(int64u)-1; } }; struct timeCodeZ { timeCodeZ_Single First; timeCodeZ_Single Last; }; std::vector 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 Speed_TimeStampsZ; struct arb { std::vector 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 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; stts* Mpeg4_stts; size_t Mpeg4_stts_Pos; #endif //MEDIAINFO_DVDIF_ANALYZE_YES }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Rm.h0000664000000000000000000000324212652076434020426 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 - File header bool FileHeader_Begin(); //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 MediaInfoLib/Source/MediaInfo/Multiple/File_Mk.cpp0000664000000000000000000052663412652076434020771 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_HEVC_YES) #include "MediaInfo/Video/File_Hevc.h" #endif #if defined(MEDIAINFO_FFV1_YES) #include "MediaInfo/Video/File_Ffv1.h" #endif #if defined(MEDIAINFO_HUFFYUV_YES) #include "MediaInfo/Video/File_HuffYuv.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_PRORES_YES) #include "MediaInfo/Video/File_ProRes.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_OPUS_YES) #include "MediaInfo/Audio/File_Opus.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 "MediaInfo/MediaInfo_Config_MediaInfo.h" #include #include #include "base64.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constants //*************************************************************************** //--------------------------------------------------------------------------- // CRC_32_Table (Little Endian bitstream, ) // The CRC in use is the IEEE-CRC-32 algorithm as used in the ISO 3309 standard and in section 8.1.1.6.2 of ITU-T recommendation V.42, with initial value of 0xFFFFFFFF. The CRC value MUST be computed on a little endian bitstream and MUST use little endian storage. // A CRC is computed like this: // Init: int32u CRC32 ^= 0; // for each data byte do // CRC32=(CRC32>>8) ^ Mk_CRC32_Table[(CRC32&0xFF)^*Buffer_Current++]; // End: CRC32 ^= 0; int32u Mk_CRC32_Table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02Ef8D, }; //--------------------------------------------------------------------------- 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 ""; } } //--------------------------------------------------------------------------- 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 ""; } } //--------------------------------------------------------------------------- const char* Mk_OriginalSourceMedium_From_Source_ID (const Ztring &Value) { if (Value.size()==6 && Value[0] == __T('0') && Value[1] == __T('0')) return "Blu-ray"; if (Value.size()==6 && Value[0] == __T('0') && Value[1] == __T('1')) return "DVD-Video"; return ""; } //--------------------------------------------------------------------------- Ztring Mk_ID_From_Source_ID (const Ztring &Value) { if (Value.size()==6 && Value[0] == __T('0') && Value[1] == __T('0')) { // Blu-ray int16u ValueI=0; for (size_t Pos=2; 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 return Value; } return Ztring::ToZtring(ValueI); } if (Value.size()==6 && Value[0] == __T('0') && Value[1] == __T('1')) { // DVD-Video int16u ValueI=0; for (size_t Pos=2; 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 return Value; } int8u ID1 = ValueI&0xFF; int8u ID2 = 0; ValueI-=ID1; if (ValueI) ID2=ValueI>>8; return Ztring::ToZtring(ID1) + (ID2?(__T('-') + Ztring::ToZtring(ID2)):Ztring()); } return Value; } //--------------------------------------------------------------------------- Ztring Mk_ID_String_From_Source_ID (const Ztring &Value) { if (Value.size()==6 && Value[0] == __T('0') && Value[1] == __T('0')) { // Blu-ray int16u ValueI=0; for (size_t Pos=2; 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 return Value; } return Ztring::ToZtring(ValueI) + __T(" (0x") + Ztring::ToZtring(ValueI, 16) + __T(")"); } if (Value.size()==6 && Value[0] == __T('0') && Value[1] == __T('1')) { // DVD-Video int16u ValueI=0; for (size_t Pos=2; 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 return Value; } int8u ID1 = ValueI&0xFF; int8u ID2 = 0; ValueI-=ID1; if (ValueI) ID2=ValueI>>8; return Ztring::ToZtring(ID1) + __T(" (0x") + Ztring::ToZtring(ID1, 16) + __T(")") + (ID2?(__T('-') + Ztring::ToZtring(ID2) + __T(" (0x") + Ztring::ToZtring(ID2, 16) + __T(")")):Ztring()); } return Value; } //*************************************************************************** // 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 InvalidByteMax=(1<<(8-4))-1; //Default is max size of 4 bytes Format_Version=0; TimecodeScale=1000000; //Default value Duration=0; Segment_Info_Count=0; Segment_Tracks_Count=0; Segment_Cluster_Count=0; CurrentAttachmentIsCover=false; CoverIsSetFromAttachment=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); //Tags (General) for (tags::iterator Item=Segment_Tags_Tag_Items.begin(); Item!=Segment_Tags_Tag_Items.end(); ++Item) if (!Item->first || Item->first == (int64u)-1) { for (tagspertrack::iterator Tag=Item->second.begin(); Tag!=Item->second.end(); ++Tag) if ((Tag->first!=__T("Encoded_Library") || Retrieve(StreamKind_Last, StreamPos_Last, "Encoded_Library").empty()) // Prioritize Info block over tags && (Tag->first!=__T("Encoded_Date") || Retrieve(StreamKind_Last, StreamPos_Last, "Encoded_Date").empty()) && (Tag->first!=__T("Title") || Retrieve(StreamKind_Last, StreamPos_Last, "Title").empty())) Fill(Stream_General, 0, Tag->first.To_UTF8().c_str(), Tag->second); } for (std::map::iterator Temp=Stream.begin(); Temp!=Stream.end(); ++Temp) { StreamKind_Last=Temp->second.StreamKind; StreamPos_Last=Temp->second.StreamPos; //Tags (per track) if (Temp->second.TrackUID && Temp->second.TrackUID!=(int64u)-1) { tags::iterator Item=Segment_Tags_Tag_Items.find(Temp->second.TrackUID); if (Item != Segment_Tags_Tag_Items.end()) { for (tagspertrack::iterator Tag=Item->second.begin(); Tag!=Item->second.end(); ++Tag) if ((Tag->first!=__T("Language") || Retrieve(StreamKind_Last, StreamPos_Last, "Language").empty())) // Prioritize Tracks block over tags Fill(StreamKind_Last, StreamPos_Last, Tag->first.To_UTF8().c_str(), Tag->second); } } //Tags //Ztring Duration_Temp; float64 FrameRate_FromTags = 0.0; Ztring TagsList=Retrieve(StreamKind_Last, StreamPos_Last, "_STATISTICS_TAGS"); if (TagsList.size()) { bool Tags_Verified=false; { Ztring Happ = Retrieve(Stream_General, 0, "Encoded_Application"); Ztring Hutc = Retrieve(Stream_General, 0, "Encoded_Date"); Ztring App = Retrieve(StreamKind_Last, StreamPos_Last, "_STATISTICS_WRITING_APP"); Ztring Utc = Retrieve(StreamKind_Last, StreamPos_Last, "_STATISTICS_WRITING_DATE_UTC"); Clear(StreamKind_Last, StreamPos_Last, "_STATISTICS_WRITING_APP"); Clear(StreamKind_Last, StreamPos_Last, "_STATISTICS_WRITING_DATE_UTC"); Clear(StreamKind_Last, StreamPos_Last, "_STATISTICS_TAGS"); Hutc.FindAndReplace(__T("UTC "), Ztring()); if (App==Happ && Utc==Hutc) Tags_Verified=true; else Fill(StreamKind_Last, StreamPos_Last, "Statistics Tags Issue", App + __T(' ') + Utc + __T(" / ") + Happ + __T(' ') + Hutc); } Ztring TempTag; float64 Statistics_Duration=0; float64 Statistics_FrameCount=0; for (Ztring::iterator Back = TagsList.begin();;++Back) { if ((Back == TagsList.end()) || (*Back == ' ') || (*Back == '\0')) { if (TempTag.size()) { Ztring TagValue = Retrieve(StreamKind_Last, StreamPos_Last, TempTag.To_Local().c_str()); if (TagValue.size()) { Clear(StreamKind_Last, StreamPos_Last, TempTag.To_Local().c_str()); bool Set=false; if (TempTag==__T("BPS")) { if (Tags_Verified) { Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate), TagValue, true); Set=true; } else TempTag="BitRate"; } else if (TempTag==__T("DURATION")) { if (Tags_Verified) { ZtringList Parts; Parts.Separator_Set(0, ":"); Parts.Write(TagValue); Statistics_Duration=0; if (Parts.size()>=1) Statistics_Duration += Parts[0].To_float64()*60*60; if (Parts.size()>=2) Statistics_Duration += Parts[1].To_float64()*60; int8u Rounding=0; //Default is rounding to milliseconds, TODO: rounding to less than millisecond when "Duration" field is changed to seconds. if (Parts.size()>=3) { Statistics_Duration += Parts[2].To_float64(); if (Parts[2].size()>6) //More than milliseconds Rounding=Parts[2].size()-6; } Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Statistics_Duration*1000, Rounding, true); Set=true; //Duration_Temp = TagValue; } if (!Set) TempTag="Duration"; } else if (TempTag==__T("NUMBER_OF_FRAMES")) { if (Tags_Verified) { Statistics_FrameCount=TagValue.To_float64(); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameCount), TagValue, true); if (StreamKind_Last==Stream_Text) { const Ztring &Format=Retrieve(Stream_Text, StreamPos_Last, "Format"); if (Format.find(__T("608"))==string::npos && Format.find(__T("708"))==string::npos) Fill(Stream_Text, StreamPos_Last, Text_ElementCount, TagValue, true); // if not 608 or 708, this is used to be also the count of elements } Set=true; } else TempTag="FrameCount"; } else if (TempTag==__T("NUMBER_OF_BYTES")) { if (Tags_Verified) { Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), TagValue, true); Set=true; } else TempTag="StreamSize"; } else if (TempTag==__T("NUMBER_OF_BYTES_UNCOMPRESSED")) { if (Tags_Verified) { Fill(StreamKind_Last, StreamPos_Last, "StreamSize_Demuxed", TagValue, true); Set=true; } else TempTag="Stream Size (Uncompressed)"; } else if (TempTag==__T("SOURCE_ID")) { if (Tags_Verified) { Fill(StreamKind_Last, StreamPos_Last, "OriginalSourceMedium_ID", Mk_ID_From_Source_ID(TagValue), true); Fill(StreamKind_Last, StreamPos_Last, "OriginalSourceMedium_ID/String", Mk_ID_String_From_Source_ID(TagValue), true); Fill(Stream_General, 0, General_OriginalSourceMedium, Mk_OriginalSourceMedium_From_Source_ID(TagValue), Unlimited, true, true); Set=true; } else TempTag="OriginalSourceMedium_ID"; } if (!Set) { TempTag.insert(0, __T("FromStats_")); Fill(StreamKind_Last, StreamPos_Last, TempTag.To_Local().c_str(), TagValue.To_Local().c_str()); } } if (Back == TagsList.end()) break; TempTag.clear(); } } else TempTag+=*Back; } if (Statistics_Duration && Statistics_FrameCount) { FrameRate_FromTags = Statistics_FrameCount/Statistics_Duration; if (float64_int64s(FrameRate_FromTags) - FrameRate_FromTags*1.001 > -0.0001 && float64_int64s(FrameRate_FromTags) - FrameRate_FromTags*1.001 < +0.0001) { // Checking 1.001 frame rates, Statistics_Duration is has often only a 1 ms precision so we test between -1ms and +1ms float64 Duration_1001 = Statistics_FrameCount / float64_int64s(FrameRate_FromTags) * 1.001000; float64 Duration_1000 = Statistics_FrameCount / float64_int64s(FrameRate_FromTags) * 1.001001; bool CanBe1001 = false; bool CanBe1000 = false; if (abs((Duration_1000 - Duration_1001) * 10000) >= 15) { Ztring DurationS; DurationS.From_Number(Statistics_Duration, 3); Ztring DurationS_1001; DurationS_1001.From_Number(Duration_1001, 3); Ztring DurationS_1000; DurationS_1000.From_Number(Duration_1000, 3); CanBe1001=DurationS==DurationS_1001?true:false; CanBe1000=DurationS==DurationS_1000?true:false; if (CanBe1001 && !CanBe1000) FrameRate_FromTags = float64_int64s(FrameRate_FromTags) / 1.001; if (CanBe1000 && !CanBe1001) FrameRate_FromTags = float64_int64s(FrameRate_FromTags) / 1.001001; } // Duration from tags not reliable, checking TrackDefaultDuration if (CanBe1000 == CanBe1001) { float64 Duration_Default=((float64)1000000000)/Temp->second.TrackDefaultDuration; if (float64_int64s(Duration_Default) - Duration_Default*1.001000 > -0.000002 && float64_int64s(Duration_Default) - Duration_Default*1.001000 < +0.000002) // Detection of precise 1.001 (e.g. 24000/1001) taking into account precision of 32-bit float { FrameRate_FromTags = float64_int64s(FrameRate_FromTags) / 1.001; } if (float64_int64s(Duration_Default) - Duration_Default*1.001001 > -0.000002 && float64_int64s(Duration_Default) - Duration_Default*1.001001 < +0.000002) // Detection of rounded 1.001 (e.g. 23976/1000) taking into account precision of 32-bit float { FrameRate_FromTags = float64_int64s(FrameRate_FromTags) / 1.001001; } } } Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameRate), FrameRate_FromTags, 3, true); } } if (Temp->second.DisplayAspectRatio!=0) { //Corrections if (Temp->second.DisplayAspectRatio>=1.777 && Temp->second.DisplayAspectRatio<=1.778) Temp->second.DisplayAspectRatio=((float32)16)/9; if (Temp->second.DisplayAspectRatio>=1.333 && Temp->second.DisplayAspectRatio<=1.334) Temp->second.DisplayAspectRatio=((float32)4)/3; Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, Temp->second.DisplayAspectRatio, 3, true); int64u Width=Retrieve(Stream_Video, StreamPos_Last, Video_Width).To_int64u(); int64u Height=Retrieve(Stream_Video, StreamPos_Last, Video_Height).To_int64u(); if (Width) Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio, Temp->second.DisplayAspectRatio*Height/Width, 3, true); } if (Temp->second.Parser) { Fill(Temp->second.Parser); if (Config->ParseSpeed<=1.0) Temp->second.Parser->Open_Buffer_Unsynch(); } //Video specific if (StreamKind_Last==Stream_Video) { //FrameRate bool IsVfr=false; if (Temp->second.Segment_Cluster_BlockGroup_BlockDuration_Counts.size()>2) IsVfr=true; else if (Temp->second.TimeCodes.size()>1) { //Trying to detect VFR std::vector FrameRate_Between; std::sort(Temp->second.TimeCodes.begin(), Temp->second.TimeCodes.end()); //This is PTS, no DTS --> Some frames are out of order size_t FramesToAdd=0; for (size_t Pos=1; Possecond.TimeCodes.size(); Pos++) { int64u Duration=Temp->second.TimeCodes[Pos]-Temp->second.TimeCodes[Pos-1]; if (Duration) FrameRate_Between.push_back(Duration); else FramesToAdd++; } if (FrameRate_Between.size()>=60+32) //Minimal 1 seconds (@60 fps) FrameRate_Between.resize(FrameRate_Between.size()-16); //We 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.size()>2) { //Looking for 3 consecutive same values, in order to remove some missing frames from stats size_t i=FrameRate_Between.size()-1; int64s Previous = FrameRate_Between[i]; do { i--; if (FrameRate_Between[i]==Previous && FrameRate_Between[i-1]==Previous) break; Previous=FrameRate_Between[i]; } while (i>2); if (i>FrameRate_Between.size()/2) FrameRate_Between.resize(i+2); } if (FrameRate_Between.size()>=40) FrameRate_Between.resize(FrameRate_Between.size()-FrameRate_Between.size()/10); //We remove the last ones, in order to ignore skipped frames (bug of the muxer?) else if (FrameRate_Between.size()>=7) FrameRate_Between.resize(FrameRate_Between.size()-4); //We remove the last ones, in order to ignore skipped frames (bug of the muxer?) if (FrameRate_Between.size()>2 && FrameRate_Between[0]*0.9FrameRate_Between[FrameRate_Between.size()-1] && TimecodeScale) { float Time=0; for (size_t i=0; isecond.TrackDefaultDuration && Time>=Temp->second.TrackDefaultDuration/TimecodeScale*0.95 && Time<=Temp->second.TrackDefaultDuration/TimecodeScale*1.05) Time=(float)Temp->second.TrackDefaultDuration/TimecodeScale; //TrackDefaultDuration is maybe more precise than the time code if (Time) { float32 FrameRate_FromCluster=1000000000/Time/TimecodeScale; if (Temp->second.Parser) { float32 FrameRate_FromParser=Temp->second.Parser->Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).To_float32(); if (FrameRate_FromParser && FrameRate_FromParser*2>FrameRate_FromCluster*0.9 && FrameRate_FromParser*2 FrameRate_FromTags + (FrameRate_FromTags*(TimecodeScale*0.0000000010021))) IsVfr=true; } else Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate_FromCluster); } } else if (FrameRate_Between.size()>2) IsVfr=true; } else if (Temp->second.TrackDefaultDuration) { float32 FrameRate_FromCluster=1000000000/(float32)Temp->second.TrackDefaultDuration; if (Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).empty()) Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate_FromCluster); } Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, IsVfr?"VFR":"CFR"); } if (Temp->second.Parser) { //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 { int64u BitRate = Temp->second.Parser->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u(); if (BitRate == 0) BitRate = Temp->second.Parser->Retrieve(Stream_Audio, 0, Audio_BitRate_Nominal).To_int64u(); if (BitRate) Delay += ((float64)Temp->second.Parser->Buffer_TotalBytes_FirstSynched) * 1000 / BitRate; } } //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 Codec_Temp=Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec)); //We want to keep the 4CC; //if (Duration_Temp.empty()) Duration_Temp=Retrieve(StreamKind_Last, Temp->second.StreamPos, Fill_Parameter(StreamKind_Last, Generic_Duration)); //Duration from stream is sometimes false //else Duration_Temp.clear(); Finish(Temp->second.Parser); Merge(*Temp->second.Parser, StreamKind_Last, 0, StreamPos_Last); //if (!Duration_Temp.empty()) 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 //Special case: 5.1 if (StreamKind_Last==Stream_Audio && (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==__T("AC-3") || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==__T("E-AC-3") || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==__T("DTS")) && Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s__Original)==__T("6") && Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s_)==__T("5")) { Clear(Stream_Audio, StreamPos_Last, Audio_Channel_s__Original); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 6, 10, true); //Some muxers do not count LFE in the channel count, let's say it is normal } //VFR if (Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate_Mode)==__T("VFR") && Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate_Original).empty()) { Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Original, Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate)); Clear(Stream_Video, StreamPos_Last, Video_FrameRate); } //Crop if (Temp->second.PixelCropLeft || Temp->second.PixelCropRight) { Fill(Stream_Video, StreamPos_Last, Video_Width_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Width), true); Fill(Stream_Video, StreamPos_Last, Video_Width, Retrieve(Stream_Video, StreamPos_Last, Video_Width).To_int64u()-Temp->second.PixelCropLeft-Temp->second.PixelCropRight, 10, true); Fill(Stream_Video, StreamPos_Last, Video_Width_Offset, Temp->second.PixelCropLeft, 10, true); } if (Temp->second.PixelCropTop || Temp->second.PixelCropBottom) { Fill(Stream_Video, StreamPos_Last, Video_Height_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Height), true); Fill(Stream_Video, StreamPos_Last, Video_Height, Retrieve(Stream_Video, StreamPos_Last, Video_Height).To_int64u()-Temp->second.PixelCropTop-Temp->second.PixelCropBottom, 10, true); Fill(Stream_Video, StreamPos_Last, Video_Height_Offset, Temp->second.PixelCropTop, 10, true); } } if (Temp->second.FrameRate!=0 && Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).empty()) Fill(Stream_Video, StreamPos_Last, Video_FrameRate, Temp->second.FrameRate, 3); //Flags Fill(StreamKind_Last, StreamPos_Last, "Default", Temp->second.Default?"Yes":"No"); Fill(StreamKind_Last, StreamPos_Last, "Forced", Temp->second.Forced?"Yes":"No"); } //Chapters if (TimecodeScale) { for (EditionEntries_Pos=0; EditionEntries_PosInvalidByteMax) 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); //Incoherencies if (Element_Level<=2 && File_Offset+Buffer_Offset+Element_Offset+Size>File_Size) Fill(Stream_General, 0, "IsTruncated", "Yes"); } //--------------------------------------------------------------------------- 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 if (!CRC32Compute.empty()) CRC32_Check(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Mk::Zero() { Element_Name("Junk"); Skip_XX(Element_Size, "Junk"); } //--------------------------------------------------------------------------- void File_Mk::CRC32() { Element_Name("CRC-32"); //Parsing if (Element_Size!=4) UInteger_Info(); //Something is wrong, 4-byte integer is expected else { if (CRC32Compute.empty()) Fill(Stream_General, 0, "ErrorDetectionType", Element_Level==3?"Per level 1":"Custom", Unlimited, true, true); if (CRC32Compute.size() 8) { //Not expected, rejecting the file Reject(); return; } InvalidByteMax = (int8u)((1 << (8-Value))-1); FILLING_END(); } //--------------------------------------------------------------------------- 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; } 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"); if (!Status[IsAccepted]) { Accept("Matroska"); Fill(Stream_General, 0, General_Format, "Matroska"); //Default is Matroska } 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"); } //--------------------------------------------------------------------------- void File_Mk::Segment_Attachements_AttachedFile_FileData() { Element_Name("FileData"); //Parsing if (!CoverIsSetFromAttachment && CurrentAttachmentIsCover && Element_Size<=8*1024*1024) //TODO: option for setting the acceptable maximum size of the attachment { if (!Element_IsComplete_Get()) { Element_WaitForMoreData(); return; } std::string Data_Raw; Peek_String(Element_TotalSize_Get(), Data_Raw); std::string Data_Base64(Base64::encode(Data_Raw)); //Filling Fill(Stream_General, 0, General_Cover_Data, Data_Base64); Fill(Stream_General, 0, General_Cover, "Yes"); CoverIsSetFromAttachment=true; } Skip_XX(Element_TotalSize_Get(), "Data"); } //--------------------------------------------------------------------------- void File_Mk::Segment_Attachements_AttachedFile_FileDescription() { Element_Name("FileDescription"); //Parsing Local_Info(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Attachements_AttachedFile_FileName() { Element_Name("FileName"); //Parsing Ztring Data=UTF8_Get(); Fill(Stream_General, 0, "Attachments", Data); //Cover is in the first file which name contains "cover" if (!CoverIsSetFromAttachment && Data.MakeLowerCase().find(__T("cover")) != string::npos) CurrentAttachmentIsCover=true; } //--------------------------------------------------------------------------- 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::iterator Temp=Stream.begin(); if (!Segment_Cluster_Count) { 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 #ifdef MEDIAINFO_AAC_YES 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 #endif //MEDIAINFO_AAC_YES ++Temp; } //We must parse moov? if (Stream_Count==0) { //Jumping std::sort(Segment_Seeks.begin(), Segment_Seeks.end()); for (size_t Pos=0; PosFile_Offset+Buffer_Offset+Element_Size) { JumpTo(Segment_Seeks[Pos]); break; } if (File_GoTo==(int64u)-1) JumpTo(Segment_Offset_End); return; } } Segment_Cluster_Count++; Segment_Cluster_TimeCode_Value=0; //Default } //--------------------------------------------------------------------------- void File_Mk::Segment_Cluster_BlockGroup() { Element_Name("BlockGroup"); Segment_Cluster_BlockGroup_BlockDuration_Value=(int64u)-1; Segment_Cluster_BlockGroup_BlockDuration_TrackNumber=(int64u)-1; } //--------------------------------------------------------------------------- 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) { //Parsing int16u TimeCodeU; Get_B2 (TimeCodeU, "TimeCode"); // Should be signed, but we don't have signed integer reader int16s TimeCode = (int16s)TimeCodeU; Element_Info1(TimeCodeU); FILLING_BEGIN(); if (Segment_Cluster_TimeCode_Value+TimeCode128) Stream[TrackNumber].Searching_TimeStamps=false; } if (Segment_Cluster_BlockGroup_BlockDuration_Value!=(int64u)-1) { Stream[TrackNumber].Segment_Cluster_BlockGroup_BlockDuration_Counts[Segment_Cluster_BlockGroup_BlockDuration_Value]++; Segment_Cluster_BlockGroup_BlockDuration_Value=(int64u)-1; } FILLING_END(); if (Stream[TrackNumber].Searching_Payload) { std::vector 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; PosElement_Size) Stream[TrackNumber].Searching_Payload=false; //There is a problem if (Stream[TrackNumber].Searching_Payload) { Element_Begin1("Data"); Element_Parser(Stream[TrackNumber].Parser->ParserName.To_UTF8().c_str()); Element_Code=TrackNumber; //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 #if MEDIAINFO_DEMUX int8u Demux_Level_old=Demux_Level; if (Stream[TrackNumber].Parser && Stream[TrackNumber].Parser->Demux_Level==2) Demux_Level=4; Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream); Demux_Level=Demux_Level_old; #endif //MEDIAINFO_DEMUX Open_Buffer_Continue(Stream[TrackNumber].Parser, (size_t)Laces[Pos]); if (Stream[TrackNumber].Parser->Status[IsFinished] || (Stream[TrackNumber].PacketCount>=300 && MediaInfoLib::Config.ParseSpeed_Get()<1)) Stream[TrackNumber].Searching_Payload=false; Element_End0(); } else Skip_XX(Laces[Pos], "Data"); } //Positionning Element_Offset=Element_Size; FILLING_END(); } else { Skip_XX(Element_Size-Element_Offset, "Data"); } if (!Stream[TrackNumber].Searching_Payload && !Stream[TrackNumber].Searching_TimeStamps && !Stream[TrackNumber].Searching_TimeStamp_Start) Stream_Count--; } else { Skip_XX(Element_Size-Element_Offset, "Data"); } //Filling Frame_Count++; if (!Status[IsFilled] && ((Frame_Count>6 && (Stream_Count==0 ||Config->ParseSpeed==0.0)) || Frame_Count>512*Stream.size())) { Fill(); if (MediaInfoLib::Config.ParseSpeed_Get()<1) { //Jumping std::sort(Segment_Seeks.begin(), Segment_Seeks.end()); for (size_t Pos=0; PosFile_Offset+Buffer_Offset+Element_Size) { JumpTo(Segment_Seeks[Pos]); break; } if (File_GoTo==(int64u)-1) JumpTo(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 int64u Segment_Cluster_TimeCode_Value=UInteger_Get(); FILLING_BEGIN(); if (Segment_Cluster_BlockGroup_BlockDuration_TrackNumber!=(int64u)-1) { Stream[Segment_Cluster_BlockGroup_BlockDuration_TrackNumber].Segment_Cluster_BlockGroup_BlockDuration_Counts[Segment_Cluster_TimeCode_Value]++; Segment_Cluster_BlockGroup_BlockDuration_TrackNumber=(int64u)-1; } else Segment_Cluster_BlockGroup_BlockDuration_Value=Segment_Cluster_TimeCode_Value; FILLING_END(); } //--------------------------------------------------------------------------- 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_BlockDuration_Value=(int64u)-1; Segment_Cluster_BlockGroup_BlockDuration_TrackNumber=(int64u)-1; 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 TestMultipleInstances(); } //--------------------------------------------------------------------------- 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"); TestMultipleInstances(&Segment_Info_Count); } //--------------------------------------------------------------------------- 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority Duration=Float; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Info_MuxingApp() { Element_Name("MuxingApp"); //Parsing Ztring Data=UTF8_Get(); FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority TimecodeScale=UInteger; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Info_Title() { Element_Name("Title"); //Parsing Ztring Data=UTF8_Get(); FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority Fill(Stream_General, 0, "Title", Data); FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Info_WritingApp() { Element_Name("WritingApp"); //Parsing Ztring Data=UTF8_Get(); FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority 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"); //Previous tags tags::iterator Items0 = Segment_Tags_Tag_Items.find((int64u)-1); if (Items0 != Segment_Tags_Tag_Items.end()) { tagspertrack &Items = Segment_Tags_Tag_Items[0]; // Creates it if not yet present, else take the previous one //Change the key of the current tag for (tagspertrack::iterator Item=Items0->second.begin(); Item!=Items0->second.end(); ++Item) Items[Item->first] = Item->second; Segment_Tags_Tag_Items.erase(Items0); } //Init Segment_Tags_Tag_Targets_TrackUID_Value=0; // Default is all tracks } //--------------------------------------------------------------------------- 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("AERMS_OF_USE")) Segment_Tag_SimpleTag_TagNames[0]=__T("TermsOfUse"); //Typo in the source file if (Segment_Tag_SimpleTag_TagNames[0]==__T("BITSPS")) return; //Useless if (Segment_Tag_SimpleTag_TagNames[0]==__T("COMPATIBLE_BRANDS")) return; //QuickTime techinical info, useless if (Segment_Tag_SimpleTag_TagNames[0]==__T("CONTENT_TYPE")) Segment_Tag_SimpleTag_TagNames[0]=__T("ContentType"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("COPYRIGHT")) Segment_Tag_SimpleTag_TagNames[0]=__T("Copyright"); 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("DATE_RELEASE")) Segment_Tag_SimpleTag_TagNames[0]=__T("Released_Date"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("DATE_RELEASED")) Segment_Tag_SimpleTag_TagNames[0]=__T("Released_Date"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("DESCRIPTION")) Segment_Tag_SimpleTag_TagNames[0]=__T("Description"); 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("PART_NUMBER")) Segment_Tag_SimpleTag_TagNames[0]=__T("Track/Position"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("ORIGINAL_MEDIA_TYPE")) Segment_Tag_SimpleTag_TagNames[0]=__T("OriginalSourceForm"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("SAMPLE") && Segment_Tag_SimpleTag_TagNames.size()==2 && Segment_Tag_SimpleTag_TagNames[1]==__T("PART_NUMBER")) return; //Useless if (Segment_Tag_SimpleTag_TagNames[0]==__T("SAMPLE") && Segment_Tag_SimpleTag_TagNames.size()==2 && Segment_Tag_SimpleTag_TagNames[1]==__T("TITLE")) {Segment_Tag_SimpleTag_TagNames.resize(1); Segment_Tag_SimpleTag_TagNames[0]=__T("Title_More");} 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"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("TITLE")) Segment_Tag_SimpleTag_TagNames[0]=__T("Title"); if (Segment_Tag_SimpleTag_TagNames[0]==__T("TOTAL_PARTS")) Segment_Tag_SimpleTag_TagNames[0]=__T("Track/Position_Total"); for (size_t Pos=0; Possecond.begin(); Item!=Items0->second.end(); ++Item) Items[Item->first] = Item->second; Segment_Tags_Tag_Items.erase(Items0); } FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks() { Element_Name("Tracks"); TestMultipleInstances(&Segment_Tracks_Count); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry() { Element_Name("TrackEntry"); if (Segment_Info_Count>1) return; //First element has the priority //Clearing CodecID.clear(); InfoCodecID_Format_Type=InfoCodecID_Format_Matroska; TrackType=(int64u)-1; TrackNumber=(int64u)-1; 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, General_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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Float, 0, true); #ifdef MEDIAINFO_AAC_YES if (Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID).find(__T("A_AAC/"))==0) ((File_Aac*)Stream[TrackNumber].Parser)->AudioSpecificConfig_OutOfBand(float64_int64s(Float)); #endif //MEDIAINFO_AAC_YES 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(); if (Segment_Info_Count>1) return; //First element has the priority CodecID=Data; CodecID_Manage(); CodecPrivate_Manage(); FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression() { FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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"); if (Segment_Info_Count>1) { Skip_XX(Element_Size, "Data (not parsed)"); return; //First element has the priority } //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; } #if MEDIAINFO_DEMUX switch (Config->Demux_InitData_Get()) { case 0 : //In demux event { Demux_Level=2; //Container int64u Element_Code_Old=Element_Code; Element_Code=TrackNumber; Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_Header); Element_Code=Element_Code_Old; } 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(StreamKind_Last, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif // MEDIAINFO_DEMUX //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.Frame_Count_Valid=0; 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) { #if defined(MEDIAINFO_FFV1_YES) if (Compression==0x46465631) //FFV1 Open_Buffer_OutOfBand(Stream[TrackNumber].Parser); #endif #if defined(MEDIAINFO_FFV1_YES) if (Compression==0x46465648) //FFVH { ((File_HuffYuv*)Stream[TrackNumber].Parser)->IsOutOfBandData=true; //TODO: implement ISOutOfBandData in a generic maner Open_Buffer_Continue(Stream[TrackNumber].Parser); Element_Offset=Element_Size; } #endif } else Skip_XX(Element_Size-Element_Offset, "Unknown"); Element_End0(); } } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_DefaultDuration() { Element_Name("DefaultDuration"); //Parsing int64u UInteger=UInteger_Get(); FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].TrackDefaultDuration=UInteger; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_FlagDefault() { Element_Name("FlagDefault"); //Parsing int64u UInteger=UInteger_Get(); FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority TrackType=UInteger; switch(UInteger) { case 0x01 : Stream_Prepare(Stream_Video); 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(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].TrackUID=UInteger; Fill(StreamKind_Last, StreamPos_Last, General_UniqueID, UInteger); FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_Video() { Element_Name("Video"); //Preparing if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].FrameRate=Value; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropBottom() { Element_Name("PixelCropBottom"); //Parsing int64u UInteger=UInteger_Get(); //Filling FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].PixelCropBottom=UInteger; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropLeft() { Element_Name("PixelCropLeft"); //Parsing int64u UInteger=UInteger_Get(); //Filling FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].PixelCropLeft=UInteger; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropRight() { Element_Name("PixelCropRight"); //Parsing int64u UInteger=UInteger_Get(); //Filling FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].PixelCropRight=UInteger; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropTop() { Element_Name("PixelCropTop"); //Parsing int64u UInteger=UInteger_Get(); //Filling FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority Stream[TrackNumber].PixelCropTop=UInteger; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mk::Segment_Tracks_TrackEntry_Video_PixelHeight() { Element_Name("PixelHeight"); //Parsing int64u UInteger=UInteger_Get(); //Filling FILLING_BEGIN(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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(); if (Segment_Info_Count>1) return; //First element has the priority 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 #if defined(MEDIAINFO_MPEG4V_YES) || defined(MEDIAINFO_AVC_YES) || defined(MEDIAINFO_HEVC_YES) || defined(MEDIAINFO_VC1_YES) || defined(MEDIAINFO_DIRAC_YES) || defined(MEDIAINFO_MPEGV_YES) || defined(MEDIAINFO_VP8_YES) || defined(MEDIAINFO_OGG_YES) || defined(MEDIAINFO_DTS_YES) const Ztring &Format=MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Type, CodecID, InfoCodecID_Format); #endif 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; } #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_HEVC_YES) else if (Format==__T("HEVC")) { Stream[TrackNumber].Parser=new File_Hevc; ((File_Hevc*)Stream[TrackNumber].Parser)->FrameIsAlwaysComplete=true; if (InfoCodecID_Format_Type==InfoCodecID_Format_Matroska) { ((File_Hevc*)Stream[TrackNumber].Parser)->MustSynchronize=false; ((File_Hevc*)Stream[TrackNumber].Parser)->MustParse_VPS_SPS_PPS=true; ((File_Hevc*)Stream[TrackNumber].Parser)->MustParse_VPS_SPS_PPS_FromMatroska=true; ((File_Hevc*)Stream[TrackNumber].Parser)->SizedBlocks=true; #if MEDIAINFO_DEMUX if (Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get()) { Stream[TrackNumber].Parser->Demux_Level=2; //Container Stream[TrackNumber].Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX } } #endif #if defined(MEDIAINFO_FFV1_YES) else if (Format==__T("FFV1")) { Stream[TrackNumber].Parser=new File_Ffv1; ((File_Ffv1*)Stream[TrackNumber].Parser)->Width=Retrieve(Stream_Video, StreamPos_Last, Video_Width).To_int32u(); ((File_Ffv1*)Stream[TrackNumber].Parser)->Height=Retrieve(Stream_Video, StreamPos_Last, Video_Height).To_int32u(); } #endif #if defined(MEDIAINFO_HUFFYUV_YES) else if (Format==__T("HuffYUV")) { Stream[TrackNumber].Parser=new File_HuffYuv; } #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; } #endif #if defined(MEDIAINFO_DIRAC_YES) else if (Format==__T("Dirac")) { Stream[TrackNumber].Parser=new File_Dirac; } #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; } #endif #if defined(MEDIAINFO_PRORES_YES) else if (Format==__T("ProRes")) { Stream[TrackNumber].Parser=new File_ProRes; } #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; } #endif #if defined(MEDIAINFO_DTS_YES) else if (Format==__T("DTS")) { Stream[TrackNumber].Parser=new File_Dts; } #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"); int64s sampling_frequency=Retrieve(Stream_Audio, StreamPos_Last, Audio_SamplingRate).To_int64s(); 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_OPUS_YES) else if (CodecID.find(__T("A_OPUS"))==0) //http://wiki.xiph.org/MatroskaOpus { Stream[TrackNumber].Parser=new File_Opus; } #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 Element_Code=TrackNumber; 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)"); } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- void File_Mk::JumpTo (int64u GoToValue) { //Clearing CRC data for (size_t i = 0; iParseSpeed >= 1.0) { //Probing, checking if CRC-32 is present if (Element_Size < 1) { Element_WaitForMoreData(); return; } if (Buffer[Buffer_Offset] == 0xBF) //CRC-32 element ParseAll=true; } if ((!Instances || *Instances) && !ParseAll) Skip_XX(Element_TotalSize_Get(), "No need, skipping"); if (Instances) (*Instances)++; } //--------------------------------------------------------------------------- void File_Mk::CRC32_Check () { for (size_t i = 0; i= CRC32Compute[i].From) { CRC32_Compute(CRC32Compute[i].Computed, Buffer + Buffer_Offset - (size_t)Header_Size, Buffer + Buffer_Offset + (size_t)(Element_WantNextLevel?Element_Offset:Element_Size)); if (File_Offset + Buffer_Offset + (Element_WantNextLevel?Element_Offset:Element_Size) >= CRC32Compute[i].UpTo) { CRC32Compute[i].Computed ^= 0xFFFFFFFF; #if MEDIAINFO_TRACE if (Trace_Activated) { //Searching and replacing CRC-32 information //TODO: better implementation without this ugly hack Ztring &TraceData = Details_Get(i); Ztring ToSearch=__T("Not tested ")+Ztring::ToZtring(i)+__T(' ')+Ztring::ToZtring(CRC32Compute[i].Expected); size_t Pos = TraceData.find(ToSearch); if (Pos != string::npos) { TraceData.erase(Pos, ToSearch.size()); TraceData.insert(Pos, CRC32Compute[i].Computed == CRC32Compute[i].Expected?__T("OK"):__T("NOK")); } //Debug //size_t Element_Level_Save=Element_Level; //Element_Level=i; //Element_Info(CRC32Compute[i].Computed == CRC32Compute[i].Expected ? __T("CRC32 check OK"):__T("CRC32 check NOK")); //Element_Level=Element_Level_Save; } #endif //MEDIAINFO_TRACE if (CRC32Compute[i].Computed != CRC32Compute[i].Expected) { Fill(Stream_General, 0, "CRC_Error_Pos", CRC32Compute[i].Pos); } CRC32Compute[i].UpTo=0; } } } //--------------------------------------------------------------------------- void File_Mk::CRC32_Compute(int32u &CRC32, int32u Init, const int8u* Buffer_Current, const int8u* Buffer_End) { CRC32 ^= Init; CRC32_Compute(CRC32, Buffer_Current, Buffer_End); CRC32 ^= Init; } //--------------------------------------------------------------------------- void File_Mk::CRC32_Compute(int32u &CRC32, const int8u* Buffer_Current, const int8u* Buffer_End) { while(Buffer_Current>8) ^ Mk_CRC32_Table[(CRC32&0xFF)^*Buffer_Current++]; } } //NameSpace #endif //MEDIAINFO_MK_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Wm_Elements.cpp0000664000000000000000000025175012652076434022633 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 ""; } } 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 ""; } } #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(const 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 ""; } } const char* Wm_ExclusionType(const int128u ExclusionType) { switch (ExclusionType.hi) { case Elements::Header_StreamProperties_Audio : return "Language"; case Elements::Header_StreamProperties_Video : return "Bitrate"; default : return ""; } } //*************************************************************************** // 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"); Header_StreamProperties_StreamOrder=0; 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); Stream[Stream_Number].Info["StreamOrder"].From_Number(Header_StreamProperties_StreamOrder); Header_StreamProperties_StreamOrder++; } //--------------------------------------------------------------------------- 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"); //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+Element_Offset), (size_t)10);//Element_Size-(Element_Offset)); std::string Data_Base64(Base64::encode(Data_Raw)); Fill(Stream_Audio, StreamPos_Last, "Demux_InitBytes", Data_Base64); (*Stream_More)[Stream_Audio][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } break; default : ; } #endif //MEDIAINFO_DEMUX //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); (*Stream_More)[Stream_Video][StreamPos_Last](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } 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; Pos0) Skip_XX(ExtensionSystemInfoLength, "Extension System Info"); Element_End0(); //Filling Stream[StreamNumber].Payload_Extension_Systems.push_back(Payload_Extension_System); } //Header_StreamProperties if (Element_Offset=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; Pos0) { 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; Pos0) Skip_UTF16L(Length*2, "Command Type"); Element_End0(); } for (int16u Pos=0; Pos0) 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; Pos0) 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; Pos0) 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; Pos0) 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::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_Pos0) { 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::iterator Strea=Stream.find(Stream_Number); if (Strea!=Stream.end() && Strea->second.StreamKind==Stream_Video) { Strea->second.PresentationTimes.insert(PresentationTime); } } 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"); } if (Element_Offset+PayloadLength+Data_Parse_Padding>Element_Size) { Trusted_IsNot("Payload Length problem"); } else { //Demux Element_Code=Stream_Number; Demux(Buffer+(size_t)Element_Offset, (size_t)PayloadLength, ContentType_MainStream); //Analyzing if (Stream[Stream_Number].Parser && Stream[Stream_Number].SearchingPayload) { //Handling of spanned on multiple chunks #if defined(MEDIAINFO_VC1_YES) bool FrameIsAlwaysComplete=true; #endif if (PayloadLength!=SizeOfMediaObject) { if (SizeOfMediaObject_BytesAlreadyParsed==0) SizeOfMediaObject_BytesAlreadyParsed=SizeOfMediaObject-PayloadLength; else SizeOfMediaObject_BytesAlreadyParsed-=PayloadLength; if (SizeOfMediaObject_BytesAlreadyParsed==0) Element_Show_Count++; #if defined(MEDIAINFO_VC1_YES) else FrameIsAlwaysComplete=false; #endif } 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 Open_Buffer_Continue(Stream[Stream_Number].Parser, (size_t)PayloadLength); if (Stream[Stream_Number].Parser->Status[IsFinished] || (Stream[Stream_Number].PresentationTimes.size()>=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].PresentationTimes.size()>=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>28; int8u H2=(TimeCode_First>>24)&0xF; int8u M1=(TimeCode_First>>20)&0xF; int8u M2=(TimeCode_First>>16)&0xF; int8u S1=(TimeCode_First>>12)&0xF; int8u S2=(TimeCode_First>> 8)&0xF; int8u F1=(TimeCode_First>> 4)&0xF; int8u F2= TimeCode_First &0xF; if (H1<10 && H2<10 && M1<10 && M2<10 && S1<10 && S2<10 && F1<10 && F2<10) { string TC; TC+='0'+H1; TC+='0'+H2; TC+=':'; TC+='0'+M1; TC+='0'+M2; TC+=':'; TC+='0'+S1; TC+='0'+S2; TC+=':'; TC+='0'+F1; TC+='0'+F2; Fill(Stream_Other, StreamPos_Last, Other_TimeCode_FirstFrame, TC.c_str()); } } FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_WM_YES MediaInfoLib/Source/MediaInfo/Multiple/File_HdsF4m.cpp0000664000000000000000000001211712652076434021471 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_HDSF4M_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_HdsF4m.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "ZenLib/FileName.h" #include "ZenLib/File.h" #include "tinyxml2.h" using namespace ZenLib; using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_HdsF4m::File_HdsF4m() :File__Analyze() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_HdsF4m; StreamIDs_Width[0]=16; #endif //MEDIAINFO_EVENTS //Temp ReferenceFiles=NULL; } //--------------------------------------------------------------------------- File_HdsF4m::~File_HdsF4m() { delete ReferenceFiles; //ReferenceFiles=NULL; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_HdsF4m::Streams_Finish() { if (ReferenceFiles==NULL) return; ReferenceFiles->ParseReferences(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_HdsF4m::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { if (ReferenceFiles==NULL) return 0; return ReferenceFiles->Seek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_HdsF4m::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; { XMLElement* Root=document.FirstChildElement("manifest"); if (Root) { const char* Attribute=Root->Attribute("xmlns"); if (Attribute==NULL || Ztring().From_UTF8(Attribute)!=__T("http://ns.adobe.com/f4m/1.0")) { Reject("HdsF4m"); return false; } Accept("HdsF4m"); Fill(Stream_General, 0, General_Format, "HDS F4M"); Config->File_ID_OnlyRoot_Set(false); ReferenceFiles=new File__ReferenceFilesHelper(this, Config); //Parsing main elements Ztring BaseURL; for (XMLElement* Root_Item=Root->FirstChildElement(); Root_Item; Root_Item=Root_Item->NextSiblingElement()) { //Common information if (string(Root_Item->Value())=="BaseURL") { if (BaseURL.empty()) //Using the first one BaseURL=Root_Item->GetText(); } //Period if (string(Root_Item->Value())=="media") { sequence* Sequence=new sequence; const char* Attribute; //Attributes - mineType Attribute=Root_Item->Attribute("url"); if (Attribute) Sequence->AddFileName(Ztring().From_UTF8(Attribute)+__T("Seg1.f4f")); Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } } } else { Reject("HdsF4m"); return false; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_HDSF4M_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Ibi.h0000664000000000000000000000526612652076434020563 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Ibi files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_IbiH #define MediaInfo_File_IbiH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Classe File_Ibi //*************************************************************************** class File_Ibi : public File__Analyze { public : File_Ibi(); ~File_Ibi(); //In #if MEDIAINFO_IBIUSAGE ibi* Ibi; #endif //MEDIAINFO_IBIUSAGE private : #if MEDIAINFO_IBIUSAGE //Get information const Ztring &Get (stream_t StreamKind, size_t StreamNumber, const Ztring &Parameter, info_t KindOfInfo=Info_Text, info_t KindOfSearch=Info_Name); #endif //MEDIAINFO_IBIUSAGE //Streams management void Streams_Accept(); #if MEDIAINFO_IBIUSAGE void Streams_Finish(); #endif //MEDIAINFO_IBIUSAGE //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(); void WritingApplication(); void WritingApplication_Name(); void WritingApplication_Version(); void InformData(); void SourceInfo(); void SourceInfo_IndexCreationDate(); void SourceInfo_SourceModificationDate(); void SourceInfo_SourceSize(); //Data int64u UInteger_Get(); int128u UInteger16_Get(); void UInteger_Info(); //Temp Ztring Get_Temp; int64u ID_Current; #if MEDIAINFO_IBIUSAGE bool Ibi_MustDelete; #endif //MEDIAINFO_IBIUSAGE }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Rm.cpp0000664000000000000000000011643212652076434020767 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_RM_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include #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 - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Rm::FileHeader_Begin() { if (IsSub) return true; if (4>Buffer_Size) return false; if (Buffer[0]!=0x2E //".RMF" || Buffer[1]!=0x52 || Buffer[2]!=0x4D || Buffer[3]!=0x46) { Reject(); return false; } return true; } //*************************************************************************** // 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; Pos10) { 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; PosSequence=Common; #if MEDIAINFO_DEMUX if (Resources.empty()) { NewResource->Demux_Offset_DTS=0; } #endif //MEDIAINFO_DEMUX if (Pos>=Resources.size()) Resources.push_back(NewResource); else Resources.insert(Resources.begin()+Pos, NewResource); } //--------------------------------------------------------------------------- void sequence::UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName) { size_t Resources_Size=Resources.size(); for (size_t Resources_Pos=0; Resources_PosUpdateFileName(OldFileName, NewFileName); for (size_t Pos=0; PosFileNames.size(); Pos++) if (Resource->FileNames[Pos]==NewFileName) Infos["UniqueID"]=OldFileName; } } //--------------------------------------------------------------------------- void sequence::FrameRate_Set(float64 NewFrameRate) { FrameRate=NewFrameRate; } } //NameSpace #endif //MEDIAINFO_REFERENCES_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Dvdv.cpp0000664000000000000000000020425312652076434021313 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 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 (Pos0x001F) 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 (Pos0x001F) 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()) { 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_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_Pos0) Skip_XX(Offset-16, "Unknown"); Element_End0(); for (int16u PGC_Pos=0; PGC_Pos=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 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=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 Stream_Control_Audio; vector Stream_Control_SubPicture_43; vector Stream_Control_SubPicture_Wide; vector Stream_Control_SubPicture_Letterbox; vector Stream_Control_SubPicture_PanScan; vector CellDurations; vector 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_OffsetElement_Size) { Skip_XX(Element_Size-Element_Offset, "Unknown"); return; } 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; Pos0) { Element_Begin1("Post commands"); for (int16u Pos=0; Pos0) { Element_Begin1("Cell commands"); for (int16u Pos=0; Pos0) { if (Element_Offset0) { if (Element_Offset0) { if (Element_Offset=Program_Count) End=Cells+1; else End=ProgramMap[Pos+1]; int64u ProgramDuration=0; if (Pos=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 MediaInfoLib/Source/MediaInfo/Multiple/File_Gxf_TimeCode.cpp0000664000000000000000000003651212652076434022706 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_TIMECODE_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Gxf_TimeCode.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constants //*************************************************************************** //--------------------------------------------------------------------------- #if defined(MEDIAINFO_GXF_YES) extern double Gxf_FrameRate(int32u Content); #else //defined(MEDIAINFO_GXF_YES) double Gxf_FrameRate(int32u Content) //TODO: remove any relationship with GXF { 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; } } #endif //defined(MEDIAINFO_GXF_YES) //--------------------------------------------------------------------------- const char* Atc_PayloadType (int8u PayloadType) { switch (PayloadType) { case 0 : return "ATC_LTC"; case 1 : return "ATC_VITC1"; case 2 : return "ATC_VITC2"; default : return ""; } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Gxf_TimeCode::File_Gxf_TimeCode() :File__Analyze() { //Configuration ParserName=__T("Time code"); #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Gxf; StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Demux_Level=2; //Container #endif //MEDIAINFO_DEMUX //In FrameRate_Code=(int32u)-1; FieldsPerFrame_Code=(int32u)-1; IsAtc=false; //Out TimeCode_FirstFrame_ms=(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_FirstFrame_ms); if (TimeCode_FirstFrame.size()==11) Fill(Stream_Video, StreamPos_Last, Video_Delay_DropFrame, TimeCode_FirstFrame[8]==';'?"Yes":"No"); Fill(Stream_Video, 0, Video_Delay_Source, "Container"); Fill(Stream_Video, 0, Video_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); //Fill(Stream_Video, 0, Video_TimeCode_Source, "Time code track"); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Delay, TimeCode_FirstFrame_ms); if (TimeCode_FirstFrame.size()==11) Fill(Stream_Audio, StreamPos_Last, Audio_Delay_DropFrame, TimeCode_FirstFrame[8]==';'?"Yes":"No"); Fill(Stream_Audio, 0, Audio_Delay_Source, "Container"); Fill(Stream_Audio, 0, Video_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); //Fill(Stream_Audio, 0, Video_TimeCode_Source, "Time code track"); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Gxf_TimeCode::Read_Buffer_Continue() { int8u Validity[504]; if (!IsAtc) { 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"); 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<(IsAtc?(size_t)1:(size_t)504); Pos++) { if (IsAtc || Validity[Pos]) { Element_Begin1("TimeCode"); int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens; bool DropFrame; int8u DBB1=0, DBB2=0; if (IsAtc) { bool Temp; BS_Begin(); Get_S1 (4, Frames_Units, "Frames (Units)"); Get_SB ( Temp, "DBB1_0"); if (Temp) DBB1|=(1<<0); Skip_S1(3, "Zero"); Skip_S1(4, "BG1"); Get_SB ( Temp, "DBB1_1"); if (Temp) DBB1|=(1<<1); Skip_S1(3, "Zero"); Skip_SB( "CF - Color fame"); Get_SB ( DropFrame, "DP - Drop frame"); Get_S1 (2, Frames_Tens, "Frames (Tens)"); Get_SB ( Temp, "DBB1_2"); if (Temp) DBB1|=(1<<2); Skip_S1(3, "Zero"); Skip_S1(4, "BG2"); Get_SB ( Temp, "DBB1_3"); if (Temp) DBB1|=(1<<3); Skip_S1(3, "Zero"); Get_S1 (4, Seconds_Units, "Seconds (Units)"); Get_SB ( Temp, "DBB1_4"); if (Temp) DBB1|=(1<<4); Skip_S1(3, "Zero"); Skip_S1(4, "BG3"); Get_SB ( Temp, "DBB1_5"); if (Temp) DBB1|=(1<<5); Skip_S1(3, "Zero"); Skip_SB( "FM - Frame Mark"); Get_S1 (3, Seconds_Tens, "Seconds (Tens)"); Get_SB ( Temp, "DBB1_6"); if (Temp) DBB1|=(1<<6); Skip_S1(3, "Zero"); Skip_S1(4, "BG4"); Get_SB ( Temp, "DBB1_7"); if (Temp) DBB1|=(1<<7); Skip_S1(3, "Zero"); Get_S1 (4, Minutes_Units, "Minutes (Units)"); Get_SB ( Temp, "DBB2_0"); if (Temp) DBB2|=(1<<0); Skip_S1(3, "Zero"); Skip_S1(4, "BG5"); Get_SB ( Temp, "DBB2_1"); if (Temp) DBB2|=(1<<1); Skip_S1(3, "Zero"); Skip_SB( "BGF0"); Get_S1 (3, Minutes_Tens, "Minutes (Tens)"); Get_SB ( Temp, "DBB2_2"); if (Temp) DBB2|=(1<<2); Skip_S1(3, "Zero"); Skip_S1(4, "BG6"); Get_SB ( Temp, "DBB2_3"); if (Temp) DBB2|=(1<<3); Skip_S1(3, "Zero"); Get_S1 (4, Hours_Units, "Hours (Units)"); Get_SB ( Temp, "DBB2_4"); if (Temp) DBB2|=(1<<4); Skip_S1(3, "Zero"); Skip_S1(4, "BG7"); Get_SB ( Temp, "DBB2_5"); if (Temp) DBB2|=(1<<5); Skip_S1(3, "Zero"); Skip_SB( "BGF2"); Skip_SB( "BGF1"); Get_S1 (2, Hours_Tens, "Hours (Tens)"); Get_SB ( Temp, "DBB2_6"); if (Temp) DBB2|=(1<<6); Skip_S1(3, "Zero"); Skip_S1(4, "BG8"); Get_SB ( Temp, "DBB2_7"); if (Temp) DBB2|=(1<<7); Skip_S1(3, "Zero"); BS_End(); } else { 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)"); 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 + (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))))); if (TimeCode_FirstFrame.empty()) { TimeCode_FirstFrame+=('0'+Hours_Tens); TimeCode_FirstFrame+=('0'+Hours_Units); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Minutes_Tens); TimeCode_FirstFrame+=('0'+Minutes_Units); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Seconds_Tens); TimeCode_FirstFrame+=('0'+Seconds_Units); TimeCode_FirstFrame+=DropFrame?';':':'; TimeCode_FirstFrame+=('0'+Frames_Tens); TimeCode_FirstFrame+=('0'+Frames_Units); } #if MEDIAINFO_TRACE string TimeCode; TimeCode+=('0'+Hours_Tens); TimeCode+=('0'+Hours_Units); TimeCode+=':'; TimeCode+=('0'+Minutes_Tens); TimeCode+=('0'+Minutes_Units); TimeCode+=':'; TimeCode+=('0'+Seconds_Tens); TimeCode+=('0'+Seconds_Units); TimeCode+=DropFrame?';':':'; TimeCode+=('0'+Frames_Tens); TimeCode+=('0'+Frames_Units); Element_Info1(TimeCode.c_str()); #endif //MEDIAINFO_TRACE if (IsAtc) { Settings=Atc_PayloadType(DBB1); Element_Info1(__T("PayloadType=")+Ztring().From_UTF8(Settings.c_str())); Element_Info1(__T("VitcLineSelect=")+Ztring::ToZtring(DBB2&0x1F)); } Element_End0(); FILLING_BEGIN(); if (TimeCode_FirstFrame_ms==(int64u)-1) TimeCode_FirstFrame_ms=TimeCode_Ms; FILLING_END(); } else Skip_XX(8, "Junk"); } //bitmap, already parsed Element_Offset+=64; FILLING_BEGIN(); if (!Status[IsFilled] && TimeCode_FirstFrame_ms!=(int64u)-1) { Accept(); Fill(); if (MediaInfoLib::Config.ParseSpeed_Get()<1) Finish(); } FILLING_END(); } } //NameSpace #endif //MEDIAINFO_TIMECODE_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Ibi.cpp0000664000000000000000000007242112652076434021113 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Ibi::File_Ibi() :File__Analyze() { //Configuration #if MEDIAINFO_DEMUX Demux_Level=2; //Container #endif //MEDIAINFO_DEMUX DataMustAlwaysBeComplete=false; #if MEDIAINFO_IBIUSAGE //In Ibi=NULL; //Temp Ibi_MustDelete=false; #endif //MEDIAINFO_IBIUSAGE } //--------------------------------------------------------------------------- File_Ibi::~File_Ibi() { #if MEDIAINFO_IBIUSAGE if (Ibi_MustDelete) delete Ibi; //Ibi=NULL; #endif //MEDIAINFO_IBIUSAGE } //*************************************************************************** // Get information //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_IBIUSAGE 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; Possecond->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; } #endif //MEDIAINFO_IBIUSAGE //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Ibi::Streams_Accept() { Fill(Stream_General, 0, General_Format, "Ibi"); #if MEDIAINFO_IBIUSAGE if (Ibi==NULL) { Ibi=new ibi(); Ibi_MustDelete=true; } #endif //MEDIAINFO_IBIUSAGE } //--------------------------------------------------------------------------- #if MEDIAINFO_IBIUSAGE void File_Ibi::Streams_Finish() { Config->File_KeepInfo_Set(true); //In order to let Get() available if (Count_Get(Stream_Video)==0) //If not yet done by Inform part 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); } } #endif //MEDIAINFO_IBIUSAGE //*************************************************************************** // Buffer //*************************************************************************** //--------------------------------------------------------------------------- void File_Ibi::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) { 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 Stream=1; const int64u Stream_Header=1; const int64u Stream_ByteOffset=2; const int64u Stream_FrameNumber=3; const int64u Stream_Dts=4; const int64u CompressedIndex=2; const int64u WritingApplication=3; const int64u WritingApplication_Name=1; const int64u WritingApplication_Version=2; const int64u InformData=4; const int64u SourceInfo=5; const int64u SourceInfo_IndexCreationDate=1; const int64u SourceInfo_SourceModificationDate=2; const int64u SourceInfo_SourceSize=3; } //--------------------------------------------------------------------------- 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) LIST(WritingApplication) ATOM_BEGIN ATOM(WritingApplication_Name) ATOM(WritingApplication_Version) ATOM_END_MK LIST(SourceInfo) ATOM_BEGIN ATOM(SourceInfo_IndexCreationDate) ATOM(SourceInfo_SourceModificationDate) ATOM(SourceInfo_SourceSize) ATOM_END_MK ATOM(InformData) 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; } 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 MEDIAINFO_IBIUSAGE 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); } } #else //MEDIAINFO_IBIUSAGE Stream_Prepare(Stream_Video); Fill(Stream_Video, StreamPos_Last, General_ID, ID_Current); #endif //MEDIAINFO_IBIUSAGE FILLING_END(); } void File_Ibi::Stream_ByteOffset() { Element_Name("Byte Offset"); //Parsing #if MEDIAINFO_IBIUSAGE size_t Pos=0; #endif //MEDIAINFO_IBIUSAGE int64u Offset=0; while (Element_OffsetStreams[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(); #endif //MEDIAINFO_IBIUSAGE } } void File_Ibi::Stream_FrameNumber() { Element_Name("Frame Number"); //Parsing #if MEDIAINFO_IBIUSAGE size_t Pos=0; #endif //MEDIAINFO_IBIUSAGE int64u Offset=0; while (Element_OffsetStreams[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(); #endif //MEDIAINFO_IBIUSAGE } } void File_Ibi::Stream_Dts() { Element_Name("DTS"); //Parsing int64u Item; Get_EB (Item, "DtsFrequencyNumerator"); #if MEDIAINFO_IBIUSAGE FILLING_BEGIN(); if (Ibi) Ibi->Streams[ID_Current]->DtsFrequencyNumerator=Item; FILLING_END(); #endif //MEDIAINFO_IBIUSAGE Get_EB (Item, "DtsFrequencyDenominator"); #if MEDIAINFO_IBIUSAGE FILLING_BEGIN(); if (Ibi) { Ibi->Streams[ID_Current]->DtsFrequencyDenominator=Item; //Handling of previous inverted Numerator/Denominator if (Ibi->Streams[ID_Current]->DtsFrequencyNumeratorStreams[ID_Current]->DtsFrequencyDenominator) std::swap(Ibi->Streams[ID_Current]->DtsFrequencyNumerator, Ibi->Streams[ID_Current]->DtsFrequencyDenominator); } FILLING_END(); #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE size_t Pos=0; #endif //MEDIAINFO_IBIUSAGE int64u Offset=0; while (Element_OffsetStreams[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(); #endif //MEDIAINFO_IBIUSAGE } } void File_Ibi::CompressedIndex() { if (!Status[IsAccepted]) { Reject("Ibi"); return; } 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; try { Dest=new int8u[Dest_Size]; } catch (...) { //Memory error Reject(); return; } 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 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_SizeIbi_UseIbiInfoIfAvailable_Get()) { ZtringListList Fields(InformData_FromFile); for (size_t Pos=0; PosFields.size() || Fields[Pos].size()<1) break; //End or problem if (Fields[Pos][0]==__T("General")) ; //Nothing to do else if (Fields[Pos][0]==__T("Video")) Stream_Prepare(Stream_Video); else if (Fields[Pos][0]==__T("Audio")) Stream_Prepare(Stream_Audio); else if (Fields[Pos][0]==__T("Text")) Stream_Prepare(Stream_Text); else if (Fields[Pos][0]==__T("Other")) Stream_Prepare(Stream_Other); else if (Fields[Pos][0]==__T("Image")) Stream_Prepare(Stream_Image); else if (Fields[Pos][0]==__T("Menu")) Stream_Prepare(Stream_Menu); else break; //Problem Pos++; } Fill(StreamKind_Last, StreamPos_Last, Fields[Pos][0].To_UTF8().c_str(), Fields[Pos][1], true); if (Info_Options #endif //defined(MEDIAINFO_ANCILLARY_YES) //--------------------------------------------------------------------------- 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 void Read_Buffer_AfterParsing(); //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; struct tc { int64u Milliseconds; string String; tc() { Milliseconds=(int64u)-1; } }; std::map TimeCodes; //Key is StreamID bool Material_Fields_First_IsValid; bool Material_Fields_Last_IsValid; bool Material_File_Size_IsValid; //Temp - Stream struct stream { std::vector Parsers; 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 Infos; #if MEDIAINFO_DEMUX bool Demux_EventWasSent; #endif //MEDIAINFO_DEMUX stream() { FirstFrameDuration=0; StreamKind=Stream_Max; StreamPos=(size_t)-1; TimeStamp_Start = (int32u)-1; TimeStamp_End = (int32u)-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; #if MEDIAINFO_DEMUX Demux_EventWasSent=false; #endif //MEDIAINFO_DEMUX } ~stream() { for (size_t Pos=0; Pos Streams; File__Analyze* UMF_File; int64u SizeToAnalyze; //Total size of a chunk to analyse, it may be changed by the parser int64u IsParsingMiddle_MaxOffset; 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); void TryToFinish(); #if MEDIAINFO_DEMUX bool Demux_HeaderParsed; #endif //MEDIAINFO_DEMUX #if MEDIAINFO_SEEK int32u Flt_FieldPerEntry; std::vector Flt_Offsets; //In 1024-byte struct seek { int64u FrameNumber; int32u StreamOffset; //In 1024-byte }; std::vector Seeks; bool IFrame_IsParsed; #endif //MEDIAINFO_SEEK }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Dxw.h0000664000000000000000000000306512652076434020615 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DXW files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DxwH #define MediaInfo_File_DxwH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper.h0000664000000000000000000000775112652076434024241 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__ReferenceFilesHelperH #define File__ReferenceFilesHelperH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper_Sequence.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper_Common.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Class File__ReferenceFilesHelper //*************************************************************************** class File__ReferenceFilesHelper { public : //Constructor / Destructor File__ReferenceFilesHelper(File__Analyze* MI, MediaInfo_Config_MediaInfo* Config); ~File__ReferenceFilesHelper(); //In void AddSequence(sequence* NewSequence); void UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName); bool TestContinuousFileNames; bool ContainerHasNoId; int64u ID_Max; //Streams management void ParseReferences(); private : sequences Sequences; size_t Sequences_Current; //Temp rfh_common* Common; public: size_t Sequences_Size() {return Sequences.size();} void Clear() {Sequences.clear();} bool FilesForStorage; bool HasMainFile; bool HasMainFile_Filled; //Streams management bool ParseReference_Init(); #if MEDIAINFO_SEEK size_t 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; bool Init_Done; bool Demux_Interleave; size_t CountOfReferencesToParse; size_t CountOfReferences_ForReadSize; float64 FrameRate; float64 Duration; stream_t StreamKind_Last; size_t StreamPos_From; size_t StreamPos_To; #if MEDIAINFO_NEXTPACKET int64u DTS_Minimal; int64u DTS_Interval; #endif //MEDIAINFO_NEXTPACKET //Helpers size_t Stream_Prepare(stream_t StreamKind, size_t StreamPos=(size_t)-1); void FileSize_Compute(); void CountOfReferences_ForReadSize_Run(); MediaInfo_Internal* MI_Create(); #if MEDIAINFO_ADVANCED || MEDIAINFO_HASH void List_Compute(); #endif //MEDIAINFO_ADVANCED || MEDIAINFO_HASH #if MEDIAINFO_EVENTS void SubFile_Start(); int64u StreamID_Previous; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX int64u Offset_Video_DTS; #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_MpegPs.cpp0000664000000000000000000063156412652076434021614 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_HEVC_YES) #include "MediaInfo/Video/File_Hevc.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_M2ts.h" #endif #if defined(MEDIAINFO_PCM_YES) #include "MediaInfo/Audio/File_Pcm_Vob.h" #endif #if defined(MEDIAINFO_SMPTEST0302_YES) #include "MediaInfo/Audio/File_SmpteSt0302.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_ARIBSTDB24B37_YES) #include "MediaInfo/Text/File_AribStdB24B37.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 #include #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_IBIUSAGE && MEDIAINFO_SEEK #include "MediaInfo/Multiple/File_Ibi.h" #endif //MEDIAINFO_IBIUSAGE && MEDIAINFO_SEEK 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 #if defined(MEDIAINFO_ARIBSTDB24B37_YES) FromAribStdB24B37=false; #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) //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].StreamRegistration_Count) //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 video_stream_PTS_Between; for (size_t Pos=1; Posvideo_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]); Ztring LawRating=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } //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 /*|| StreamID==0xBF*/)) { bool StreamIsDetected=false; for (size_t Pos=0; Pos16) { 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; StreamPosRetrieve(StreamKind_Last, StreamPos, General_ID).empty()) ID+=__T("-")+Temp.Parsers[0]->Retrieve(StreamKind_Last, StreamPos, General_ID); 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(")"); if (!Temp.Parsers[0]->Retrieve(StreamKind_Last, StreamPos, General_ID_String).empty()) ID_String+=__T("-")+Temp.Parsers[0]->Retrieve(StreamKind_Last, StreamPos, General_ID_String); else if (!Temp.Parsers[0]->Retrieve(StreamKind_Last, StreamPos, General_ID).empty()) ID_String+=__T("-")+Temp.Parsers[0]->Retrieve(StreamKind_Last, StreamPos, General_ID); 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_Update() { //For each Streams for (size_t StreamID=0; StreamID<0x100; StreamID++) for (size_t Pos=0; PosOpen_Buffer_Update(); //For each private Streams for (size_t StreamID=0; StreamID<0x100; StreamID++) for (size_t Pos=0; PosOpen_Buffer_Update(); //For each extension Streams for (size_t StreamID=0; StreamID<0x100; StreamID++) for (size_t Pos=0; PosOpen_Buffer_Update(); } //--------------------------------------------------------------------------- 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 StreamOrder_CountOfPrivateStreams_Temp=0; 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; StreamPossecond && IbiStream_Temp->second->DtsFrequencyNumerator==1000000000 && IbiStream_Temp->second->DtsFrequencyDenominator==1) { bool IsOk=true; for (size_t Pos=0; Possecond->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; Possecond->Infos.size(); Pos++) { int64u Temp=IbiStream_Temp->second->Infos[Pos].Dts*90/1000000; IbiStream_Temp->second->Infos[Pos].Dts=Temp; } } } } } #endif //MEDIAINFO_IBIUSAGE } //--------------------------------------------------------------------------- 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; #if MEDIAINFO_EVENTS Temp.Parsers[0]->PES_FirstByte_IsAvailable=false; #endif //MEDIAINFO_EVENTS Open_Buffer_Continue(Temp.Parsers[0], Buffer, 0, false); 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); if (!IsSub) { switch (KindOfStream) { case KindOfStream_Private : if (Streams[0xBD].StreamOrder!=(size_t)-1) Fill(StreamKind_Last, StreamPos_Last, General_StreamOrder, Streams[0xBD].StreamOrder+StreamOrder_CountOfPrivateStreams_Temp); if (StreamOrder_CountOfPrivateStreams_Minus1 && StreamOrder_CountOfPrivateStreams_TempCount_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_PosRetrieve(Stream_Text, Parser_Pos, Text_ID); StreamPos_Last=(size_t)-1; for (size_t Pos=0; PosRetrieve(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); if (!IsSub) { switch (KindOfStream) { case KindOfStream_Private : if (Streams[0xBD].StreamOrder!=(size_t)-1) Fill(Stream_Text, StreamPos_Last, General_StreamOrder, Streams[0xBD].StreamOrder); break; case KindOfStream_Extension : if (Streams[0xFD].StreamOrder!=(size_t)-1) Fill(Stream_Text, StreamPos_Last, General_StreamOrder, Streams[0xFD].StreamOrder); break; default : if (Temp.StreamOrder!=(size_t)-1) Fill(Stream_Text, StreamPos_Last, General_StreamOrder, Temp.StreamOrder); } Fill(StreamKind_Last, StreamPos_Last, General_FirstPacketOrder, Temp.FirstPacketOrder); } } StreamKind_Last=Temp.StreamKind; StreamPos_Last=Temp.StreamPos; } //Law rating Ztring LawRating=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Temp.Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } //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, ByteDifference=(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 (Temp.TimeStamp_Start.PTS.File_Pos0x100000000LL) //Testing coherancy: no 13 hours long files. End+=0x200000000LL; //33 bits, cyclic if (Start10000000000LL) Duration=0; } 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 } Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Duration/90, 10, true); } } } } //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-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_OffsetBuffer_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 FirstPacketOrder_Last=0; //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 || CC4(Buffer)==0x000001FE)) { 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 Streams[0xFE].Searching_Payload=true; //extension_stream? Streams[0xFE].Searching_TimeStamp_Start=true; //extension_stream? Streams[0xFE].Searching_TimeStamp_End=true; //extension_stream? } // Frequency_c=90000; } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_MpegPs::Read_Buffer_Init() { #if MEDIAINFO_DEMUX // Demux_UnpacketizeContainer=Config->Demux_Unpacketize_Get(); #endif //MEDIAINFO_DEMUX } //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED2 void File_MpegPs::Read_Buffer_SegmentChange() { if (!Streams.empty()) for (size_t StreamID=0; StreamID<0x100; StreamID++) { for (size_t Pos=0; PosOpen_Buffer_SegmentChange(); for (size_t Pos=0; PosOpen_Buffer_SegmentChange(); for (size_t Pos=0; PosOpen_Buffer_SegmentChange(); } } #endif //MEDIAINFO_ADVANCED2 //--------------------------------------------------------------------------- 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; PosUnsynch_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; PosUnsynch_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; PosUnsynch_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 #if MEDIAINFO_IBIUSAGE 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; Possecond->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 } #endif //#if MEDIAINFO_IBIUSAGE 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_IBIUSAGE { 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; Possecond->Infos.size(); Pos++) { if (Value<=IbiStream_Temp->second->Infos[Pos].Dts) { if (Valuesecond->Infos[Pos].Dts && Pos) Pos--; //Checking continuity of Ibi if (!IbiStream_Temp->second->Infos[Pos].IsContinuous && Pos+1second->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_Posfirst].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_IBIUSAGE return (size_t)-2; //Not supported / IBI disabled #endif //MEDIAINFO_IBIUSAGE case 3 : //FrameNumber #if MEDIAINFO_IBIUSAGE { 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; Possecond->Infos.size(); Pos++) { if (Value<=IbiStream_Temp->second->Infos[Pos].FrameNumber) { if (Valuesecond->Infos[Pos].FrameNumber && Pos) Pos--; if (!Streams[(size_t)IbiStream_Temp->first].Parsers.empty()) for (size_t Parser_Pos=0; Parser_Posfirst].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_IBIUSAGE return (size_t)-2; //Not supported / IBI disabled #endif //MEDIAINFO_IBIUSAGE 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, false); 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, false); 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, false); 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 MEDIAINFO_EVENTS if (FromTS) { PES_FirstByte_IsAvailable=true; PES_FirstByte_Value=false; } #endif //MEDIAINFO_EVENTS 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-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 } if (Element_Size) { 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=0; extension_stream_Count=0; SL_packetized_stream_Count=0; } //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+SizeToAnalyzeParseSpeed<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 #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) { 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-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 MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer && Buffer_Offset+6+PES_packet_length>Buffer_Size) return false; #endif //MEDIAINFO_DEMUX 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)); //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) { 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_OffsetBuffer_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 #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) 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; #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) while (FrameInfo.PTS+0x100000000LL=0x100000000LL) //Hack in case DTS is negative (currently not supported by MI). TODO: negative DTS. FrameInfo.DTS=0; 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; #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) while (FrameInfo.DTS+0x100000000LL=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(); #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) 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; } #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) 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; #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) while (FrameInfo.PTS+0x100000000LLElement_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; } #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) 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; #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) while (FrameInfo.PTS+0x100000000LL=0x100000000LL) //Hack in case DTS is negative (currently not supported by MI). TODO: negative DTS. FrameInfo.DTS=0; 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 (Frame_Count<16 &&FrameInfo.DTS>=0x100000000LL) //Hack in case DTS is negative (currently not supported by MI). TODO: negative DTS. FrameInfo.DTS=0; #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; #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (!FromAribStdB24B37) #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) while (FrameInfo.DTS+0x100000000LLElement_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"); int32u Code; Peek_B4(Code); if (Code==0x43434953) // "CCIS" { if (Streams_Private1[private_stream_1_ID].Parsers.size()>1) { //Should not happen, this is only in case the previous packet was without CCIS Streams_Private1[private_stream_1_ID].Parsers.clear(); Streams_Private1[private_stream_1_ID].StreamRegistration_Count=0; } if (!Streams_Private1[private_stream_1_ID].StreamRegistration_Count) { Streams_Private1[private_stream_1_ID].Parsers.push_back(ChooseParser_AribStdB24B37(true)); Open_Buffer_Init(Streams_Private1[private_stream_1_ID].Parsers[0]); Streams_Private1[private_stream_1_ID].StreamRegistration_Count++; } if (Streams_Private1[private_stream_1_ID].Parsers.size()==1) { File_AribStdB24B37* Parser=(File_AribStdB24B37*)Streams_Private1[private_stream_1_ID].Parsers[0]; Parser->ParseCcis=true; Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, 16); } else Skip_B16( "PES_private_data"); } else 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 0xFE : video_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!"); } #if MEDIAINFO_EVENTS PES_FirstByte_IsAvailable=false; #endif //MEDIAINFO_EVENTS } //--------------------------------------------------------------------------- //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>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=(((int64u)(Buffer[Buffer_Pos ] & 0x38)) << 30) | (((int64u)(Buffer[Buffer_Pos ] & 0x03)) << 28) | (((int64u)(Buffer[Buffer_Pos + 1] )) << 20) | (((int64u)(Buffer[Buffer_Pos + 2] & 0xF8)) << 15) | (((int64u)(Buffer[Buffer_Pos + 2] & 0x03)) << 13) | (((int64u)(Buffer[Buffer_Pos + 3] )) << 5) | (((int64u)(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=((int64u)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_IBIUSAGE if (!IsSub) Ibi_SynchronizationOffset_Current=File_Offset+Buffer_Offset-Header_Size; #endif //MEDIAINFO_IBIUSAGE 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; //StreamOrder StreamOrder_CountOfPrivateStreams_Minus1=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; size_t StreamOrder=0; 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 : ; } if (stream_id==0xBD && Streams[stream_id].StreamOrder!=(size_t)-1) StreamOrder_CountOfPrivateStreams_Minus1++; else if (stream_id>0xB9) { Streams[stream_id].StreamOrder=StreamOrder; StreamOrder++; } 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].StreamRegistration_Count) { //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].StreamRegistration_Count++; Streams_Private1[private_stream_1_ID].StreamRegistration_Count++; 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; Streams_Private1[private_stream_1_ID].FirstPacketOrder=FirstPacketOrder_Last; FirstPacketOrder_Last++; //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 defined(MEDIAINFO_SMPTEST0337_YES) Streams_Private1[private_stream_1_ID].Parsers.push_back(ChooseParser_SmpteSt0302()); #endif #if defined(MEDIAINFO_ARIBSTDB24B37_YES) Streams_Private1[private_stream_1_ID].Parsers.push_back(ChooseParser_AribStdB24B37()); #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; PosCA_system_ID_MustSkipSlices=CA_system_ID_MustSkipSlices; 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_OffsetDemux_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_SmpteSt0302(); //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+"); } } #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"); } break; 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].StreamRegistration_Count) { //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].StreamRegistration_Count++; Streams[stream_id].FirstPacketOrder=FirstPacketOrder_Last; FirstPacketOrder_Last++; //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; PosCA_system_ID_MustSkipSlices=CA_system_ID_MustSkipSlices; 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 #if MEDIAINFO_EVENTS StreamIDs[StreamIDs_Size-1]=Element_Code; #endif //MEDIAINFO_EVENTS 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].StreamRegistration_Count) { //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].StreamRegistration_Count++; Streams[stream_id].FirstPacketOrder=FirstPacketOrder_Last; FirstPacketOrder_Last++; //New parsers switch (Streams[stream_id].stream_type) { case 0x01 : case 0x02 : case 0x80 : Streams[stream_id].Parsers.push_back(ChooseParser_Mpegv() ); break; case 0x10 : Streams[stream_id].Parsers.push_back(ChooseParser_Mpeg4v()); break; case 0x1B : Streams[stream_id].Parsers.push_back(ChooseParser_Avc() ); break; case 0x24 : case 0x27 : Streams[stream_id].Parsers.push_back(ChooseParser_Hevc() ); 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_HEVC_YES) Streams[stream_id].Parsers.push_back(ChooseParser_Hevc()); #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; PosCA_system_ID_MustSkipSlices=CA_system_ID_MustSkipSlices; Open_Buffer_Init(Streams[stream_id].Parsers[Pos]); #if MEDIAINFO_IBIUSAGE 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_IBIUSAGE #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 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 #if MEDIAINFO_EVENTS StreamIDs[StreamIDs_Size-1]=Element_Code; #endif //MEDIAINFO_EVENTS 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].StreamRegistration_Count) { //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].StreamRegistration_Count++; Streams[stream_id].FirstPacketOrder=FirstPacketOrder_Last; FirstPacketOrder_Last++; 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; PosCA_system_ID_MustSkipSlices=CA_system_ID_MustSkipSlices; 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, OCRflag=false, accessUnitStartFlag=false; if (SLConfig->useAccessUnitStartFlag) Get_SB (accessUnitStartFlag, "accessUnitStartFlag"); if (SLConfig->useAccessUnitEndFlag) Skip_SB( "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)) { bool DegPrioflag=false; 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) { bool decodingTimeStampFlag=false, compositionTimeStampFlag=false, instantBitrateFlag=false; 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 #if MEDIAINFO_EVENTS StreamIDs[StreamIDs_Size-1]=Element_Code; #endif //MEDIAINFO_EVENTS 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].StreamRegistration_Count) { //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].StreamRegistration_Count++; Streams_Extension[stream_id_extension].StreamRegistration_Count++; 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; Streams_Extension[stream_id_extension].FirstPacketOrder=FirstPacketOrder_Last; FirstPacketOrder_Last++; //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>=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; PosCA_system_ID_MustSkipSlices=CA_system_ID_MustSkipSlices; 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()) { #if MEDIAINFO_EVENTS //Multiple substreams in 1 stream StreamIDs[StreamIDs_Size-1]=Element_Code; StreamIDs[StreamIDs_Size]=Element_Code=0x71; StreamIDs_Width[StreamIDs_Size]=2; ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext; StreamIDs_Size++; #endif //MEDIAINFO_EVENTS xxx_stream_Parse(Streams_Extension[0x71], extension_stream_Count); #if MEDIAINFO_EVENTS StreamIDs_Size--; Element_Code=StreamIDs[StreamIDs_Size-1]; #endif //MEDIAINFO_EVENTS #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()) { #if MEDIAINFO_EVENTS //Multiple substreams in 1 stream StreamIDs[StreamIDs_Size-1]=Element_Code; StreamIDs[StreamIDs_Size]=Element_Code=0x76; StreamIDs_Width[StreamIDs_Size]=2; ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext; StreamIDs_Size++; #endif //MEDIAINFO_EVENTS xxx_stream_Parse(Streams_Extension[0x76], extension_stream_Count); #if MEDIAINFO_EVENTS StreamIDs_Size--; Element_Code=StreamIDs[StreamIDs_Size-1]; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent) { Demux_StreamIsBeingParsed_type=2; Demux_StreamIsBeingParsed_stream_id=0x76; } #endif //MEDIAINFO_DEMUX } } else { #if MEDIAINFO_EVENTS //Multiple substreams in 1 stream StreamIDs[StreamIDs_Size-1]=Element_Code; StreamIDs[StreamIDs_Size]=Element_Code=stream_id_extension; StreamIDs_Width[StreamIDs_Size]=2; ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext; StreamIDs_Size++; #endif //MEDIAINFO_EVENTS xxx_stream_Parse(Streams_Extension[stream_id_extension], extension_stream_Count); #if MEDIAINFO_EVENTS StreamIDs_Size--; Element_Code=StreamIDs[StreamIDs_Size-1]; #endif //MEDIAINFO_EVENTS #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 0xBF : 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.File_Pos=File_Offset+Buffer_Offset; 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 /*|| stream_id==0xBF*/) private_stream_1_Element_Info1(); #endif //MEDIAINFO_TRACE for (size_t Pos=0; PosStatus[IsFinished]) { //PTS/DTS if (Temp.Parsers[Pos]->PTS_DTS_Needed) { if (FrameInfo.PCR!=(int64u)-1) Temp.Parsers[Pos]->FrameInfo.PCR=FrameInfo.PCR; TS_Set(Temp.Parsers[Pos]); } #if MEDIAINFO_TRACE if (Temp.Parsers.size()>1) Element_Begin1("Test"); #endif //MEDIAINFO_TRACE #if MEDIAINFO_IBIUSAGE Temp.Parsers[Pos]->Ibi_SynchronizationOffset_Current=Ibi_SynchronizationOffset_Current; #endif //MEDIAINFO_IBIUSAGE #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Temp.Parsers[Pos]->ServiceDescriptors=ServiceDescriptors; #endif 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; Pos2Status[IsFilled]) { stream_Count--; Temp.IsFilled=true; } //Checking cases with B-frames displayed before the first I-frame if (Temp.Parsers.size()==1 && Temp.Parsers[0]->PTS_Begin!=(int64u)-1 && Temp.TimeStamp_Start.PTS.TimeStamp!=(int64u)-1 && float64_int64s(((float64)Temp.Parsers[0]->PTS_Begin)*90/1000000)PTS_Begin)*90/1000000); //TODO: same denominator for the time stamp } } //FrameInfo.PCR=(int64u)-1; TS_Clear(); 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[0] && SubStream_Demux->Buffers[0]->DTSBuffers[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 && MEDIAINFO_IBIUSAGE 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; PosInfos.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 && MEDIAINFO_IBIUSAGE } //*************************************************************************** // 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 /*&& stream_id!=0xBF)*/ || !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].StreamRegistration_Count || 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) return false; //Not enough data } if (Buffer_Offset_Temp+1>=Buffer_Size) return false; //Not enough data if (Buffer_Offset_TempBuffer_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-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=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->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; #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_Hevc() { //Filling #if defined(MEDIAINFO_HEVC_YES) File_Hevc* Parser=new File_Hevc; #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, "HEVC"); Parser->Fill(Stream_Video, 0, Video_Format, "HEVC"); #endif return Parser; } //--------------------------------------------------------------------------- File__Analyze* File_MpegPs::ChooseParser_VC1() { //Filling #if defined(MEDIAINFO_VC1_YES) File_Vc1* Parser=new File_Vc1; #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; #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; #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(); #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(); #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__Analyze* Parser; switch (FromTS_stream_type) { case 0x80 : Parser=new File_Pcm_M2ts(); break; default : Parser=new File_Pcm_Vob(); } #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_AribStdB24B37(bool HasCcis) { //Filling #if defined(MEDIAINFO_ARIBSTDB24B37_YES) File_AribStdB24B37* Parser=new File_AribStdB24B37(); Parser->HasCcis=HasCcis; #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, "ARIB STD B24/B37"); Parser->Fill(Stream_Text, 0, Text_Codec, "ARIB STD B24/B37"); #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_Teletext* Parser=new File_Teletext(); Parser->FromMpegPs=true; #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_SmpteSt0302() { //Filling #if defined(MEDIAINFO_SMPTEST0302_YES) File_SmpteSt0302* Parser=new File_SmpteSt0302(); #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, "SMPTE ST 302"); Parser->Fill(Stream_Audio, 0, Audio_Codec, "SMPTE ST 302"); #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_PosOutput_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_PosOutput_Buffer_Get(Pos_)) return Size; return 0; } } //Namespace #endif //MEDIAINFO_MPEGPS_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Nut.cpp0000664000000000000000000002472612652076434021163 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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::FileHeader_Parse() { //Parsing Element_Begin1("Nut header"); std::string file_id_string; int8u file_id_string_zero; Get_String(24, file_id_string, "file_id_string"); Get_B1 (file_id_string_zero, "file_id_string zero"); Element_End0(); FILLING_BEGIN(); //Integrity if (file_id_string!="nut/multimedia container" || file_id_string_zero) { Reject("Nut"); return; } //Filling Accept("Nut"); Fill(Stream_General, 0, General_Format, "Nut"); FILLING_END(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- 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); Finish(); } } //--------------------------------------------------------------------------- void File_Nut::Data_Parse() { #define ELEMENT_CASE(_NAME) \ case Elements::_NAME : _NAME(); break; //Parsing if (Element_Size < 4) { Skip_XX(Element_Size, "Unknown"); return; } Element_Size-=4; #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, "Data"); } Element_Size+=4; if (Element_Offset+4!=Element_Size) Skip_XX(Element_Size - 4 - Element_Offset, "Unknown"); 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; i0) Skip_VS( "tmp_pts"); //TODO: signed 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) Get_VS(count, "count"); else count=tmp_mul-tmp_size; for(int64u j=6; j using namespace tinyxml2; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_DcpCpl::File_DcpCpl() :File__Analyze() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_DcpCpl; 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_DcpCpl::~File_DcpCpl() { delete ReferenceFiles; //ReferenceFiles=NULL; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpCpl::Streams_Finish() { if (ReferenceFiles==NULL) return; ReferenceFiles->ParseReferences(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_DcpCpl::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { if (ReferenceFiles==NULL) return 0; return ReferenceFiles->Seek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_DcpCpl::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; bool IsDcp=false, IsImf=false; XMLElement* Root=document.FirstChildElement("CompositionPlaylist"); if (!Root) { Reject("DcpCpl"); return false; } const char* Attribute=Root->Attribute("xmlns"); if (!Attribute) { Reject("DcpCpl"); return false; } if (!strcmp(Attribute, "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#") ||!strcmp(Attribute, "http://www.smpte-ra.org/schemas/429-7/2006/CPL")) IsDcp=true; if (!strcmp(Attribute, "http://www.smpte-ra.org/schemas/2067-3/XXXX") //Some muxers use XXXX instead of year || !strcmp(Attribute, "http://www.smpte-ra.org/schemas/2067-3/2013")) IsImf=true; if (!IsDcp && !IsImf) { Reject("DcpCpl"); return false; } Accept("DcpCpl"); Fill(Stream_General, 0, General_Format, IsDcp?"DCP CPL":"IMF CPL"); Config->File_ID_OnlyRoot_Set(false); ReferenceFiles=new File__ReferenceFilesHelper(this, Config); //Parsing main elements for (XMLElement* CompositionPlaylist_Item=Root->FirstChildElement(); CompositionPlaylist_Item; CompositionPlaylist_Item=CompositionPlaylist_Item->NextSiblingElement()) { //CompositionTimecode if (IsImf && (!strcmp(CompositionPlaylist_Item->Value(), "CompositionTimecode") || !strcmp(CompositionPlaylist_Item->Value(), "cpl:CompositionTimecode"))) { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Other; Sequence->Infos["Type"]=__T("Time code"); Sequence->Infos["Format"]=__T("CPL TC"); Sequence->Infos["TimeCode_Striped"]=__T("Yes"); bool IsDropFrame=false; for (XMLElement* CompositionTimecode_Item=CompositionPlaylist_Item->FirstChildElement(); CompositionTimecode_Item; CompositionTimecode_Item=CompositionTimecode_Item->NextSiblingElement()) { //TimecodeDropFrame if (!strcmp(CompositionTimecode_Item->Value(), "TimecodeDropFrame") || !strcmp(CompositionTimecode_Item->Value(), "cpl:TimecodeDropFrame")) { if (strcmp(CompositionTimecode_Item->GetText(), "") && strcmp(CompositionTimecode_Item->GetText(), "0")) IsDropFrame=true; } //TimecodeRate if (!strcmp(CompositionTimecode_Item->Value(), "TimecodeRate") || !strcmp(CompositionTimecode_Item->Value(), "cpl:TimecodeRate")) Sequence->Infos["FrameRate"].From_UTF8(CompositionTimecode_Item->GetText()); //TimecodeStartAddress if (!strcmp(CompositionTimecode_Item->Value(), "TimecodeStartAddress") || !strcmp(CompositionTimecode_Item->Value(), "cpl:TimecodeStartAddress")) Sequence->Infos["TimeCode_FirstFrame"].From_UTF8(CompositionTimecode_Item->GetText()); } //Adaptation if (IsDropFrame) { std::map::iterator Info=Sequence->Infos.find("TimeCode_FirstFrame"); if (Info!=Sequence->Infos.end() && Info->second.size()>=11 && Info->second[8]!=__T(';')) Info->second[8]=__T(';'); } Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_ID, Sequence->StreamID); for (std::map::iterator Info=Sequence->Infos.begin(); Info!=Sequence->Infos.end(); ++Info) Fill(Stream_Other, StreamPos_Last, Info->first.c_str(), Info->second); } //ReelList / SegmentList if ((IsDcp && !strcmp(CompositionPlaylist_Item->Value(), "ReelList")) || (IsImf && !strcmp(CompositionPlaylist_Item->Value(), "SegmentList"))) { for (XMLElement* ReelList_Item=CompositionPlaylist_Item->FirstChildElement(); ReelList_Item; ReelList_Item=ReelList_Item->NextSiblingElement()) { //Reel if ((IsDcp && !strcmp(ReelList_Item->Value(), "Reel")) || (IsImf && !strcmp(ReelList_Item->Value(), "Segment"))) { for (XMLElement* Reel_Item=ReelList_Item->FirstChildElement(); Reel_Item; Reel_Item=Reel_Item->NextSiblingElement()) { //AssetList if ((IsDcp && !strcmp(Reel_Item->Value(), "AssetList")) || (IsImf && !strcmp(Reel_Item->Value(), "SequenceList"))) { for (XMLElement* AssetList_Item=Reel_Item->FirstChildElement(); AssetList_Item; AssetList_Item=AssetList_Item->NextSiblingElement()) { //File //if ((IsDcp && (!strcmp(AssetList_Item->Value(), "MainPicture") || !strcmp(AssetList_Item->Value(), "MainSound"))) // || (IsImf && (!strcmp(AssetList_Item->Value(), "cc:MainImageSequence") || !strcmp(AssetList_Item->Value(), "cc:MainImage")))) { sequence* Sequence=new sequence; Ztring Asset_Id; if ((IsDcp && !strcmp(AssetList_Item->Value(), "MainPicture")) || (IsImf && !strcmp(AssetList_Item->Value(), "cc:MainImageSequence"))) Sequence->StreamKind=Stream_Video; if ((IsDcp && !strcmp(AssetList_Item->Value(), "MainSound")) || (IsImf && !strcmp(AssetList_Item->Value(), "cc:MainAudioSequence"))) Sequence->StreamKind=Stream_Audio; for (XMLElement* File_Item=AssetList_Item->FirstChildElement(); File_Item; File_Item=File_Item->NextSiblingElement()) { //Id if (!strcmp(File_Item->Value(), "Id") && Asset_Id.empty()) Asset_Id.From_UTF8(File_Item->GetText()); //ResourceList if (IsImf && !strcmp(File_Item->Value(), "ResourceList")) { for (XMLElement* ResourceList_Item=File_Item->FirstChildElement(); ResourceList_Item; ResourceList_Item=ResourceList_Item->NextSiblingElement()) { //Resource if (!strcmp(ResourceList_Item->Value(), "Resource")) { Ztring Resource_Id; resource* Resource=new resource; for (XMLElement* Resource_Item=ResourceList_Item->FirstChildElement(); Resource_Item; Resource_Item=Resource_Item->NextSiblingElement()) { //EditRate if (!strcmp(Resource_Item->Value(), "EditRate")) { const char* EditRate=Resource_Item->GetText(); Resource->EditRate=atof(EditRate); const char* EditRate2=strchr(EditRate, ' '); if (EditRate2!=NULL) { float64 EditRate2f=atof(EditRate2); if (EditRate2f) Resource->EditRate/=EditRate2f; } } //EntryPoint if (!strcmp(Resource_Item->Value(), "EntryPoint")) { Resource->IgnoreEditsBefore=atoi(Resource_Item->GetText()); if (Resource->IgnoreEditsAfter!=(int64u)-1) Resource->IgnoreEditsAfter+=Resource->IgnoreEditsBefore; } //Id if (!strcmp(File_Item->Value(), "Id") && Resource_Id.empty()) Resource_Id.From_UTF8(File_Item->GetText()); //SourceDuration if (!strcmp(Resource_Item->Value(), "SourceDuration")) Resource->IgnoreEditsAfter=Resource->IgnoreEditsBefore+atoi(Resource_Item->GetText()); //TrackFileId if (!strcmp(Resource_Item->Value(), "TrackFileId")) Resource->FileNames.push_back(Ztring().From_UTF8(Resource_Item->GetText())); } if (Resource->FileNames.empty()) Resource->FileNames.push_back(Resource_Id); Sequence->AddResource(Resource); } } } } if (Sequence->Resources.empty()) { resource* Resource=new resource; Resource->FileNames.push_back(Asset_Id); Sequence->AddResource(Resource); } Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } } } } } } } } Element_Offset=File_Size; //Getting files names FileName Directory(File_Name); Ztring Assetmap_FileName=Directory.Path_Get()+PathSeparator+__T("ASSETMAP.xml"); bool IsOk=false; if (File::Exists(Assetmap_FileName)) IsOk=true; else { Assetmap_FileName.resize(Assetmap_FileName.size()-4); //Old fashion, without ".xml" if (File::Exists(Assetmap_FileName)) IsOk=true; } if (IsOk) { 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()); MI.Option(__T("File_IsReferenced"), __T("1")); size_t MiOpenResult=MI.Open(Assetmap_FileName); 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("DCP AM") || MI.Get(Stream_General, 0, General_Format)==__T("IMF AM"))) { MergeFromAm(((File_DcpAm*)MI.Info)->Streams); } } ReferenceFiles->FilesForStorage=true; //All should be OK... return true; } //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpCpl::MergeFromAm (File_DcpPkl::streams &StreamsToMerge) { for (File_DcpPkl::streams::iterator StreamToMerge=StreamsToMerge.begin(); StreamToMerge!=StreamsToMerge.end(); ++StreamToMerge) if (!StreamToMerge->ChunkList.empty()) // Note: ChunkLists with more than 1 file are not yet supported) ReferenceFiles->UpdateFileName(Ztring().From_UTF8(StreamToMerge->Id), Ztring().From_UTF8(StreamToMerge->ChunkList[0].Path)); } } //NameSpace #endif //MEDIAINFO_DCP_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg_Psi.cpp0000664000000000000000000036322412652076434022117 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include 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"; case 0x24 : case 0x27 : return "HEVC"; 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 0x86 : return "SCTE 35"; 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 0x91 : return "PGS"; case 0x92 : return "TEXTST"; //Blu-ray subtitle text 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"; case 0x24 : case 0x27 : return "HEVC"; 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 0x91 : return "PGS"; case 0x92 : return "TEXTST"; //Blu-ray Subtitle Text 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 : case 0x02 : case 0x10 : case 0x1B : case 0x1E : case 0x1F : case 0x20 : case 0x24 : case 0x27 : return Stream_Video; case 0x03 : case 0x04 : case 0x0F : case 0x11 : case 0x1C : return Stream_Audio; case 0x1D : return Stream_Text; 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 0x91 : return Stream_Text; case 0x92 : 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 0x24 : case 0x27 : return "ITU-T Rec. H.265 | ISO/IEC 23008-2 MPEG-H Part 2 / HEVC video stream"; 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 0x91 : return "BluRay - PGS"; case 0x92 : return "BluRay - TEXTST"; 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>24)^(*CRC_32_Buffer)]; CRC_32_Buffer++; } if (CRC_32) { Trusted_IsNot("CRC error"); 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 (table_id<=0x06 && !section_syntax_indicator) { Skip_XX(Element_Size, "Data (section_syntax_indicator 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 && Config->ParseSpeed>=0.5 && 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=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; Complete_Stream->Transport_Streams[table_id_extension].programs_List.clear(); //Saving previous status std::map program_numbers_Previous=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs; //Reseting std::vector 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; PosStreams[0x0000]->Table_IDs[0x00]->Table_ID_Extensions.erase(Table_ID_Extension_List[Pos]); //Parsing while (Element_OffsetFile_Filter_Get(program_number) #endif //MEDIAINFO_FILTER ) { program_number_Update(); std::map::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::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_Offset0) 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_NotParsedCount--; Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].IsParsed=true; } //Saving previous status std::vector 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 transport_stream_id=Complete_Stream->transport_stream_id; program_number=table_id_extension; program_number_IsValid=true; if (Descriptors_Size>0) Descriptors(); //Parsing while (Element_OffsetTransport_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 MIs; MIs.resize(List.size()); size_t FileWithRightPID_Pos=(size_t)-1; for (size_t Pos=0; PosOption(__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; PosStreams[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; Pos0) 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; PosTransport_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 //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 } if (Buffer_Offset>=4) { Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].ExtraInfos_Content["pointer_field"].From_Number(Buffer_Offset-4); Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].ExtraInfos_Option["pointer_field"]=__T("N NT"); } Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].ExtraInfos_Content["section_length"].From_Number(Element_Size+4); Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].ExtraInfos_Option["section_length"]=__T("N NT"); FILLING_END(); } //--------------------------------------------------------------------------- void File_Mpeg_Psi::Table_03() { //Parsing if (Element_Offset0) 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_Offset0) 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_Offset0) 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_Offset0) 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_Offset0) 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; Pos0) 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; Pos0) 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; PosFile_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_Pos0) 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; PosGPS_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; Postransport_stream_id; //SCTE 35 is automaticly linked to the current transport_stream_id if (Descriptors_Size>0) Descriptors(); } if (Element_Offset+4Element_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=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; Complete_Stream->Transport_Streams[table_id_extension].programs_List.push_back(program_number); 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; PosTransport_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; PosStreams[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 && !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::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; PosStreams[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 && !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].HasNotDisplayableStreams=true; 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; PosStreams[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; PosTransport_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; PosStreams[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 && !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 MediaInfoLib/Source/MediaInfo/Multiple/File_Wm.h0000664000000000000000000001374012652076434020437 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_WmH #define MediaInfo_File_WmH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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 Info; bool IsCreated; //if Stream_Prepare() is done bool SearchingPayload; std::set PresentationTimes; std::vector 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; 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 Stream; int16u Stream_Number; //In header: current pos, in Data: Count of enabled parsers std::vector Languages; std::vector 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; size_t Header_StreamProperties_StreamOrder; 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Cdxa.cpp0000664000000000000000000002525512652076434021272 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_IsReferenced"), __T("1")); //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_SizeInform().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 MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper_Resource.cpp0000664000000000000000000000554512652076434026442 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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/Multiple/File__ReferenceFilesHelper_Sequence_Common.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper_Common.h" #include "ZenLib/FileName.h" #include "ZenLib/Format/Http/Http_Utils.h" #if MEDIAINFO_AES #include "base64.h" #endif //MEDIAINFO_AES #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events_Internal.h" #include "MediaInfo/MediaInfo_Config_PerPackage.h" #endif //MEDIAINFO_EVENTS using namespace std; using namespace ZenLib; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** resource::resource() { //In FileNames.Separator_Set(0, __T(",")); EditRate=0; IgnoreEditsBefore=0; IgnoreEditsAfter=(int64u)-1; //Config Sequence=NULL; #if MEDIAINFO_NEXTPACKET Demux_Offset_Frame=(int64u)-1; Demux_Offset_DTS=(int64u)-1; #endif //MEDIAINFO_NEXTPACKET //Private MI=NULL; IgnoreEditsAfterDuration=(int64u)-1; #if MEDIAINFO_DEMUX Demux_Offset_FileSize=0; #endif //MEDIAINFO_DEMUX } resource::~resource() { delete MI; } //*************************************************************************** // In //*************************************************************************** //--------------------------------------------------------------------------- void resource::UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName) { size_t FileNames_Size=FileNames.size(); for (size_t Pos=0; PosDuplicates_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::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; Possecond.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 Targets_ToAdd; std::vector Targets_ToRemove; std::vector Orders_ToAdd; std::vector Orders_ToRemove; for (ZtringList::iterator Current=List.begin(); Currentfind(__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::iterator Order=Orders_ToAdd.begin(); Order::iterator Target=Targets_ToAdd.begin(); TargetDuplicates.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::iterator Order=Orders_ToAdd.begin(); OrderDuplicates[**Target]->Configure(**Order, false); //For each order to remove for (std::vector::iterator Order=Orders_ToRemove.begin(); OrderDuplicates[**Target]->Configure(**Order, true); } //For each target to remove for (std::vector::iterator Target=Targets_ToRemove.begin(); Target::iterator Pointer=Complete_Stream->Duplicates.find(**Target); if (Pointer!=Complete_Stream->Duplicates.end()) { //Duplicates_Speed for (std::vector::iterator Duplicate=Complete_Stream->Duplicates_Speed.begin(); DuplicateDuplicates_Speed.end(); ++Duplicate) if (*Duplicate==Pointer->second) *Duplicate=NULL; //Duplicates_Speed_FromPID for (std::vector >::iterator Duplicate_FromPID=Complete_Stream->Duplicates_Speed_FromPID.begin(); Duplicate_FromPIDDuplicates_Speed_FromPID.end(); ++Duplicate_FromPID) for (std::vector::iterator Duplicate=Duplicate_FromPID->begin(); Duplicateend(); ++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 &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; PosWrite(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; PosDuplicates_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_Posprogram_map_PIDs[program_map_PIDs_Pos]) { bool AlreadyPresent=false; for (size_t Duplicates_Speed_FromPID_Pos=0; Duplicates_Speed_FromPID_PosDuplicates_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_Poselementary_PIDs[elementary_PIDs_Pos]) { bool AlreadyPresent=false; for (size_t Duplicates_Speed_FromPID_Pos=0; Duplicates_Speed_FromPID_PosDuplicates_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::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_PosOutput_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 && PosDuplicates_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_PosStreams.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 MediaInfoLib/Source/MediaInfo/Multiple/File_Umf.cpp0000664000000000000000000003300012652076434021125 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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=Element_Size) break; } for (int32u Pos=0; Pos=Element_Size) break; } while (Element_Offset18) 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Ogg.cpp0000664000000000000000000003602612652076434021125 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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::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::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-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; PosBuffer_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; PosInAnotherContainer=IsSub; StreamsToDo++; } ((File_Ogg_SubElement*)Stream_Item.Parser)->MultipleStreams=Stream.size()>1; //has no sens for the first init, must check allways //Parsing File_Ogg_SubElement* Parser=(File_Ogg_SubElement*)Stream_Item.Parser; if (Stream_Item.SearchingPayload) //For each chunk for (size_t Chunk_Sizes_Pos=0; Chunk_Sizes_PosFile_Offset!=Parser->File_Size) Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, Chunk_Sizes[Chunk_Sizes_Pos]); if (Chunk_Sizes_PosFile_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_Item.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::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 MediaInfoLib/Source/MediaInfo/Multiple/File_Ogg_SubElement.cpp0000664000000000000000000007611512652076434023253 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include #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_OPUS_YES) #include "MediaInfo/Audio/File_Opus.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(kateTags, 6B617465, 00000000, 8) OGG_ID(KW_DIRAC, 4B572D44, 49524143, 8) OGG_ID(OggMIDI, 4D67674D, 49444900, 8) OGG_ID(MNG, 8A4D4E47, 0D0A1A0A, 8) OGG_ID(OpusHead, 4F707573, 48656164, 8) OGG_ID(OpusTags, 4F707573, 54616773, 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; if (Identified && WithType) { bool lenbytes0, lenbytes1, lenbytes2; 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(OpusHead) 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_OpusHead() { #if defined(MEDIAINFO_OPUS_YES) StreamKind_Last=Stream_Audio; Parser=new File_Opus; #else Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, "Opus"); Fill(Stream_Audio, 0, Audio_Codec, "Opus"); #endif WithType=false; absolute_granule_position_Resolution=48000; // From specs: "It is possible to run a decoder at other sampling rates, but the format and this specification always count samples assuming a 48 kHz decoding rate." } //--------------------------------------------------------------------------- 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_OffsetFrameIsAlwaysComplete=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_OffsetFrame_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>(64-8*Elements::Identifier_##_NAME##3)==(((int64u)Elements::Identifier_##_NAME##1)*0x100000000LL|Elements::Identifier_##_NAME##2)) #else //__BORLANDC__ #define ELEMENT_CASE(_NAME) \ else if (ID_Identification>>(64-8*Elements::Identifier_##_NAME##3)==Elements::Identifier_##_NAME) #endif //__BORLANDC__ int32u ID_Identification_Size; if (0) ; ELEMENT_CASE(OpusTags) ID_Identification_Size=8; else if (WithType) { if (0) ; ELEMENT_CASE(kateTags) ID_Identification_Size=8; else ID_Identification_Size=6; //Default } else return; //Not a comment Element_Name("Comment"); 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) { if (!WithType) Comment(); //In case of comments Open_Buffer_Continue(Parser); if (Identified && Parser->Status[IsFilled]) Finish("OggSubElement"); } else if (Element_OffsetOpen_Buffer_Unsynch(); } //--------------------------------------------------------------------------- void File_Dpg::Read_Buffer_Continue() { if (!Parser) return; //Not ready #if defined(MEDIAINFO_MPEGA_YES) || defined(MEDIAINFO_MPEGV_YES) if (Audio_Size) { #if defined(MEDIAINFO_MPEGA_YES) Open_Buffer_Continue(Parser, (size_t)((File_Offset+Buffer_SizeStatus[IsAccepted]) { Parser->Open_Buffer_Unsynch(); Finish(Parser); Merge(*Parser, Stream_Audio, 0, 0); #if defined(MEDIAINFO_MPEGV_YES) Audio_Size=0; 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_SizeStatus[IsAccepted]) { //Merging Parser->Open_Buffer_Unsynch(); Finish(Parser); Merge(*Parser, Stream_Video, 0, 0); Finish("DPG"); } #endif } #endif //defined(MEDIAINFO_MPEGA_YES) || defined(MEDIAINFO_MPEGV_YES) //Positioning Buffer_Offset=Buffer_Size; //We have already parsed this data } } //NameSpace #endif //MEDIAINFO_DPG_YES MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper_Resource.h0000664000000000000000000000361712652076434026105 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__ReferenceFilesHelper_ResourceH #define File__ReferenceFilesHelper_ResourceH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include "MediaInfo/MediaInfo_Internal.h" #include #if MEDIAINFO_EVENTS #include #endif //MEDIAINFO_EVENTS //--------------------------------------------------------------------------- namespace MediaInfoLib { class rfhs_common; class resource { public: //Constructor/Desctructor resource(); ~resource(); //In void UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName); ZtringList FileNames; //Source file name (relative path) float64 EditRate; int64u IgnoreEditsBefore; int64u IgnoreEditsAfter; //Config rfhs_common* Sequence; #if MEDIAINFO_NEXTPACKET int64u Demux_Offset_Frame; int64u Demux_Offset_DTS; #endif //MEDIAINFO_NEXTPACKET MediaInfo_Internal* MI; int64u IgnoreEditsAfterDuration; //temporary value, some formats have duration instead of frame position #if MEDIAINFO_DEMUX int64u Demux_Offset_FileSize; #endif //MEDIAINFO_DEMUX }; typedef std::vector resources; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Hls.cpp0000664000000000000000000002013112652076434021125 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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/Multiple/File__ReferenceFilesHelper.h" #include "ZenLib/File.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->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_SizeFile_Size-1) { Reject("HLS"); return false; } Ztring LinesSeparator; if (Document[LinesSeparator_Pos]==__T('\r') && LinesSeparator_Pos+1ContainerHasNoId=true; sequence* Sequence=new sequence; bool IsGroup=false; for (size_t Line=0; LineEncryption_Key_Get().empty()) { File KeyFile; if (KeyFile.Open(File_Name+__T(".key"))) { if (KeyFile.Size_Get()==16) { int8u Key[16]; if (KeyFile.Read(Key, 16)==16) Config->Encryption_Key_Set(Key, 16); } else Fill(Stream_General, 0, "Encryption_Key_Problem", KeyFile.Size_Get()); } } #endif } Fill(Stream_General, 0, General_Encryption, List[Pos](1)); } } } else if (Lines[Line].find(__T("#EXT-X-STREAM-INF:"))==0) { IsGroup=true; } else if (Lines[Line][0]==__T('#')) ; else { if (IsGroup) { Sequence->AddFileName(Lines[Line]); Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); IsGroup=false; Sequence=new sequence(); #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_HlsIndex; StreamIDs_Width[0]=sizeof(size_t); #endif //MEDIAINFO_EVENTS } else Sequence->AddFileName(Lines[Line]); } } } if (!Sequence->FileNames.empty()) { ReferenceFiles->AddSequence(Sequence); Fill(Stream_General, 0, General_Format_Profile, "Media"); } else { Fill(Stream_General, 0, General_Format_Profile, "Master"); } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_HLS_YES MediaInfoLib/Source/MediaInfo/Multiple/File_DvDif.cpp0000664000000000000000000020655012652076434021406 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 ParserName=__T("DV"); 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_FirstFrame_ms=(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; PosFile_DvDif_DisableAudioIfIsInContainer_Get()) for (size_t Pos=0; Pos::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"); Clear(Stream_Video, 0, Video_BitDepth); //MXF files say that DVCPRO HD streams are 8 or 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_FirstFrame_ms!=(int64u)-1) { Fill(Stream_Video, 0, Video_Delay, TimeCode_FirstFrame_ms); if (TimeCode_FirstFrame.size()==11) Fill(Stream_Video, 0, Video_Delay_DropFrame, TimeCode_FirstFrame[8]==';'?"Yes":"No"); Fill(Stream_Video, 0, Video_Delay_Source, "Stream"); Fill(Stream_Video, 0, Video_TimeCode_FirstFrame, TimeCode_FirstFrame.c_str()); Fill(Stream_Video, 0, Video_TimeCode_Source, "Subcode time code"); for (size_t Pos=0; PosStatus[IsAccepted]) { Finish(CC_Parsers[Pos]); for (size_t Pos2=0; Pos2Count_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 (!IsSub && FrameInfo.DTS==(int64u)-1) FrameInfo.DTS=0; //No DTS in container if (!IsSub && FrameInfo.PTS==(int64u)-1) FrameInfo.PTS=0; //No PTS in container if (!IsSub && 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 Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens; 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, Frames_Tens, "Frames (Tens)"); Frames+=Frames_Tens*10; Get_S1 (4, Frames_Units, "Frames (Units)"); Frames+=Frames_Units; 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, Seconds_Tens, "Seconds (Tens)"); MilliSeconds+=Seconds_Tens*10*1000; Get_S1 (4, Seconds_Units, "Seconds (Units)"); MilliSeconds+=Seconds_Units*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, Minutes_Tens, "Minutes (Tens)"); MilliSeconds+=Minutes_Tens*10*60*1000; Get_S1 (4, Minutes_Units, "Minutes (Units)"); MilliSeconds+=Minutes_Units*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, Hours_Tens, "Hours (Tens)"); MilliSeconds+=Hours_Tens*10*60*60*1000; Get_S1 (4, Hours_Units, "Hours (Units)"); MilliSeconds+=Hours_Units*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_FirstFrame_ms==(int64u)-1 && MilliSeconds!=167185000) //if all bits are set to 1, this is not a valid timestamp { TimeCode_FirstFrame_ms=MilliSeconds; if (DSF_IsValid && Frames!=45) //all bits are set to 1 TimeCode_FirstFrame_ms+=(int64u)(Frames/(DSF?25.000:29.970)*1000); TimeCode_FirstFrame+=('0'+Hours_Tens); TimeCode_FirstFrame+=('0'+Hours_Units); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Minutes_Tens); TimeCode_FirstFrame+=('0'+Minutes_Units); TimeCode_FirstFrame+=':'; TimeCode_FirstFrame+=('0'+Seconds_Tens); TimeCode_FirstFrame+=('0'+Seconds_Units); TimeCode_FirstFrame+=DropFrame?';':':'; TimeCode_FirstFrame+=('0'+Frames_Tens); TimeCode_FirstFrame+=('0'+Frames_Units); } } //--------------------------------------------------------------------------- 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 && Streams_Audio.empty() && Dv_Audio_SamplingRate[SamplingRate] && Dv_Audio_BitDepth[Resolution]) { //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()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 MediaInfoLib/Source/MediaInfo/Multiple/File_Bdmv.h0000664000000000000000000000522012652076434020736 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Blu-ray Movie files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_BdmvH #define MediaInfo_File_BdmvH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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(int8u SubPath_type, int16u Pos); 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 Types; //Key is the start address int64u Mpls_PlayList_Duration; int64u Mpls_PlayList_PlayItem_Duration; int16u Mpls_PlayList_number_of_SubPaths; bool Mpls_PlayList_IsParsed; std::set Clip_Information_file_names; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Riff_Elements.cpp0000664000000000000000000044775312652076434023150 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Elements part // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" #include #include using namespace std; using namespace ZenLib; //--------------------------------------------------------------------------- //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- #if defined(MEDIAINFO_RIFF_YES) || defined(MEDIAINFO_MK_YES) //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- 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; } } //--------------------------------------------------------------------------- #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #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_FFV1_YES) #include "MediaInfo/Video/File_Ffv1.h" #endif #if defined(MEDIAINFO_HUFFYUV_YES) #include "MediaInfo/Video/File_HuffYuv.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_PRORES_YES) #include "MediaInfo/Video/File_ProRes.h" #endif #if defined(MEDIAINFO_AVC_YES) #include "MediaInfo/Video/File_Avc.h" #endif #if defined(MEDIAINFO_CANOPUS_YES) #include "MediaInfo/Video/File_Canopus.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_DTS_YES) #include "MediaInfo/Audio/File_Dts.h" #endif #if defined(MEDIAINFO_JPEG_YES) #include "MediaInfo/Image/File_Jpeg.h" #endif #if defined(MEDIAINFO_SUBRIP_YES) #include "MediaInfo/Text/File_SubRip.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_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.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 #endif #endif //MEDIAINFO_GXF_YES #include #include "MediaInfo/MediaInfo_Config_MediaInfo.h" using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // 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"); Stream_Prepare(Stream_Audio); Kind=Kind_Aiff; #if MEDIAINFO_EVENTS StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS } //--------------------------------------------------------------------------- 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"); Stream_Prepare(Stream_Audio); Kind=Kind_Aiff; #if MEDIAINFO_EVENTS StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS } //--------------------------------------------------------------------------- void File_Riff::AIFF_COMM() { Element_Name("Common"); 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"); } //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); //Compute the current codec ID Element_Code=(int64u)-1; Stream_ID=(int32u)-1; stream_Count=1; //Specific cases #if defined(MEDIAINFO_SMPTEST0337_YES) if (Retrieve(Stream_Audio, 0, Audio_CodecID).empty() && numChannels==2 && sampleSize<=32 && sampleRate==48000) //Some SMPTE ST 337 streams are hidden in PCM stream { File_SmpteSt0337* Parser=new File_SmpteSt0337; Parser->Endianness='B'; Parser->Container_Bits=(int8u)sampleSize; Parser->ShouldContinueParsing=true; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get()) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Demux_Level=4; //Intermediate } #endif //MEDIAINFO_DEMUX Stream[Stream_ID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_PCM_YES) File_Pcm* Parser=new File_Pcm; Parser->Codec=Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID); if (Parser->Codec.empty() || Parser->Codec==__T("NONE")) Parser->Endianness='B'; Parser->BitDepth=(int8u)sampleSize; #if MEDIAINFO_DEMUX if (Demux_Rate) Parser->Frame_Count_Valid = float64_int64s(Demux_Rate); if (Config->Demux_Unpacketize_Get()) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Demux_Level=4; //Intermediate } #else //MEDIAINFO_DEMUX Parser->Frame_Count_Valid=(int64u)-1; //Disabling it, waiting for SMPTE ST 337 parser reject #endif //MEDIAINFO_DEMUX Stream[Stream_ID].Parsers.push_back(Parser); Stream[Stream_ID].IsPcm=true; Stream[Stream_ID].StreamKind=Stream_Audio; #endif #if MEDIAINFO_DEMUX BlockAlign=numChannels*sampleSize/8; AvgBytesPerSec=(int32u)float64_int64s(BlockAlign*(float64)sampleRate); #endif //MEDIAINFO_DEMUX Element_Code=(int64u)-1; for (size_t Pos=0; Pos0) 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_OffsetElement_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_OffsetFrame_Count_Valid=2; Parser->ShouldContinueParsing=true; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get() && Retrieve(Stream_General, 0, General_Format)==__T("Wave")) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Demux_Level=4; //Intermediate } #endif //MEDIAINFO_DEMUX Stream[Stream_ID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_SMPTEST0337_YES) { File_SmpteSt0337* Parser=new File_SmpteSt0337; Parser->Container_Bits=(int8u)BitsPerSample; Parser->Aligned=true; Parser->ShouldContinueParsing=true; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get() && Retrieve(Stream_General, 0, General_Format)==__T("Wave")) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Demux_Level=4; //Intermediate } #endif //MEDIAINFO_DEMUX Stream[Stream_ID].Parsers.push_back(Parser); } #endif } #endif //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")) { File_Dts* Parser=new File_Dts; Parser->Frame_Count_Valid=2; 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")) { File_Pcm* Parser=new File_Pcm; Parser->Codec=Codec; Parser->Endianness='L'; Parser->BitDepth=(int8u)BitsPerSample; #if MEDIAINFO_DEMUX if (Demux_Rate) Parser->Frame_Count_Valid = float64_int64s(Demux_Rate); if (Config->Demux_Unpacketize_Get() && Retrieve(Stream_General, 0, General_Format)==__T("Wave")) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Demux_Level=4; //Intermediate } #else //MEDIAINFO_DEMUX Parser->Frame_Count_Valid=(int64u)-1; //Disabling it, waiting for SMPTE ST 337 parser reject #endif //MEDIAINFO_DEMUX Stream[Stream_ID].Parsers.push_back(Parser); Stream[Stream_ID].IsPcm=true; } #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; PosElement_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 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; PosElement_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; PosCodec=Ztring().From_GUID(SubFormat); Parser->Endianness='L'; Parser->Sign='S'; Parser->BitDepth=(int8u)BitsPerSample; #if MEDIAINFO_DEMUX if (Config->Demux_Unpacketize_Get() && Retrieve(Stream_General, 0, General_Format)==__T("Wave")) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Demux_Level=4; //Intermediate } #endif //MEDIAINFO_DEMUX Stream[Stream_ID].Parsers.push_back(Parser); Stream[Stream_ID].IsPcm=true; } #endif for (size_t Pos=0; PosAuxToAnalyze=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=0x80000000?(-((int32s)Height)):Height, 10, true); // AVI can use negative height for raw to signal that it's coded top-down, not bottom-up 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 (MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression)).find(__T("Canopus"))!=std::string::npos) //Canopus codecs Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/3); 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); Stream[Stream_ID].StreamKind=StreamKind_Last; //Creating the parser if (0); #if defined(MEDIAINFO_FFV1_YES) else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==__T("FFV1")) { File_Ffv1* Parser=new File_Ffv1; Parser->Width=Width; Parser->Height=Height; Stream[Stream_ID].Parsers.push_back(Parser); } #endif #if defined(MEDIAINFO_HUFFYUV_YES) else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==__T("HuffYUV")) { File_HuffYuv* Parser=new File_HuffYuv; Stream[Stream_ID].Parsers.push_back(Parser); } #endif #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_PRORES_YES) else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==__T("ProRes")) { File_ProRes* Parser=new File_ProRes; 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_CANOPUS_YES) else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==__T("Canopus HQ")) { File_Canopus* Parser=new File_Canopus; 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=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 if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==__T("FFV1")) AVI__hdlr_strl_strf_vids_Ffv1(); else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==__T("HuffYUV")) AVI__hdlr_strl_strf_vids_HuffYUV(Resolution, Height); 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_strf_vids_Ffv1() { //Parsing Element_Begin1("FFV1 options"); #if defined(MEDIAINFO_FFV1_YES) File_Ffv1* Parser=(File_Ffv1*)Stream[Stream_ID].Parsers[0]; Open_Buffer_OutOfBand(Parser); #else //MEDIAINFO_FFV1_YES Skip_XX(Element_Size-Element_Offset, "(FFV1 headers)"); #endif Element_End0(); } //--------------------------------------------------------------------------- void File_Riff::AVI__hdlr_strl_strf_vids_HuffYUV(int16u BitCount, int32u Height) { //Parsing Element_Begin1("HuffYUV options"); #if defined(MEDIAINFO_HUFFYUV_YES) File_HuffYuv* Parser=(File_HuffYuv*)Stream[Stream_ID].Parsers[0]; Parser->IsOutOfBandData=true; Parser->BitCount=BitCount; Parser->Height=Height; Open_Buffer_Continue(Parser); #else //MEDIAINFO_HUFFYUV_YES Skip_XX(Element_Size-Element_Offset, "(HuffYUV 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_Offset0 && 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"); vector VideoYValidStartLines; for (int32u Pos=0; PosVideoYValidStartLines[1]) Fill(Stream_Video, 0, Video_ScanOrder, "BFF"); default: ; } 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 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& Stream_Item=Stream[StreamID]; Stream_Item.StreamSize+=Size; Stream_Item.PacketCount++; stream_structure& Stream_Structure_Item=Stream_Structure[Idx1_Offset+Offset]; Stream_Structure_Item.Name=StreamID; Stream_Structure_Item.Size=Size; Element_Offset+=16; } //Interleaved size_t Pos0=0; size_t Pos1=0; for (std::map::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); switch (Element_Code) { case Elements::AVI__INFO_ISMP : INFO_ISMP=Value; break; case Elements::AVI__INFO_IGNR : { Ztring ISGN=Retrieve(Stream_General, 0, General_Genre); Clear(Stream_General, 0, General_Genre); Fill(StreamKind, StreamPos, General_Genre, Value); if (!ISGN.empty()) Fill(StreamKind, StreamPos, General_Genre, ISGN); } break; default : 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); Skip_XX(Element_Size, "Data"); } //--------------------------------------------------------------------------- void File_Riff::AVI__MD5_() { //Parsing while (Element_Offset::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; } } //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; //Filling if (!SecondPass) movi_Size+=Element_TotalSize_Get(); //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; } if (Element_Code!=(int64u)-1) Stream_ID=(int32u)(Element_Code&0xFFFF0000); else Stream_ID=(int32u)-1; 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; Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream); Element_Code=Element_Code_Old; Frame_Count_NotParsedIncluded=(int64u)-1; } 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; PosFrameInfo.PTS=FrameInfo.PTS; if (FrameInfo.DTS!=(int64u)-1) Stream[Stream_ID].Parsers[Pos]->FrameInfo.DTS=FrameInfo.DTS; 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; Pos2Demux_EventWasSent) { Demux_Parser=Stream[Stream_ID].Parsers[Pos]; return; } #endif //MEDIAINFO_DEMUX } Element_Offset=Element_Size; //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; int32u GAB2; Peek_B4(GAB2); if (GAB2==0x47414232 && Element_Size>=17) { 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"); if (Element_Offset>Element_Size) Element_Offset=Element_Size; //Problem } //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))) { 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 { #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong() && SecondPass) Hash_ParseUpTo=File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2); else #endif //MEDIAINFO_HASH 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)) { #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong() && SecondPass) Hash_ParseUpTo=File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2); else #endif //MEDIAINFO_HASH 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::iterator Temp=Stream.begin(); while (Temp!=Stream.end()) { for (size_t Pos=0; Possecond.Parsers.size(); ++Pos) { Temp->second.Parsers[Pos]->Fill(); 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 && Config->ParseSpeed<1.0)); 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)) { #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong() && SecondPass) Hash_ParseUpTo=File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2); else #endif //MEDIAINFO_HASH 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) { #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong() && SecondPass) Hash_ParseUpTo=ToJump; else #endif //MEDIAINFO_HASH GoTo(ToJump, "AVI"); //Not just after } } else Finish("AVI"); } } //--------------------------------------------------------------------------- void File_Riff::AVI__PrmA() { Element_Name("Adobe Premiere PrmA"); //Parsing int32u FourCC, Size; Get_C4 (FourCC, "FourCC"); Get_B4 (Size, "Size"); switch (FourCC) { case 0x50415266: if (Size==20) { int32u PAR_X, PAR_Y; Skip_B4( "Unknown"); Get_B4 (PAR_X, "PAR_X"); Get_B4 (PAR_Y, "PAR_Y"); if (PAR_Y) PAR=((float64)PAR_X)/PAR_Y; } else Skip_XX(Element_Size-Element_Offset, "Unknown"); break; default: for (int32u Pos=8; PosStreamKind=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; PosFrameInfo.DTS=FrameInfo.DTS; 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"); rcrd_fld__anc__pos__LineNumber=(int32u)-1; } //--------------------------------------------------------------------------- void File_Riff::rcrd_fld__anc__pos_() { Element_Name("Ancillary data sample description"); //Parsing Get_L4 (rcrd_fld__anc__pos__LineNumber, "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; (*Ancillary)->LineNumber=rcrd_fld__anc__pos__LineNumber; 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"); Fill(Stream_Audio, 0, Audio_StreamSize, Buffer_DataToParse_End-Buffer_DataToParse_Begin); Stream_Prepare(Stream_Audio); //Creating parser #if defined(MEDIAINFO_MPEGA_YES) File_Mpega* Parser=new File_Mpega; Parser->CalculateDelay=true; Parser->ShouldContinueParsing=true; Open_Buffer_Init(Parser); stream& StreamItem=Stream[(int32u)-1]; StreamItem.StreamKind=Stream_Audio; StreamItem.StreamPos=0; StreamItem.Parsers.push_back(Parser); #else //MEDIAINFO_MPEG4_YES Fill(Stream_Audio, 0, Audio_Format, "MPEG Audio"); Skip_XX(Buffer_DataToParse_End-Buffer_DataToParse_Begin, "Data"); #endif } //--------------------------------------------------------------------------- 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 Element_Code=(int64u)-1; 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 #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong()) Element_Offset=Element_Size+(SMV_FrameCount-1)*SMV_BlockSize; #endif //MEDIAINFO_HASH 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"); Kind=Kind_Wave; #if MEDIAINFO_EVENTS StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS } //--------------------------------------------------------------------------- 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_OffsetBitRate*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(); } //--------------------------------------------------------------------------- void File_Riff::WAVE_data_Continue() { #if MEDIAINFO_DEMUX Element_Code=(int64u)-1; if (AvgBytesPerSec && Demux_Rate) { FrameInfo.DTS=float64_int64s((File_Offset+Buffer_Offset-Buffer_DataToParse_Begin)*1000000000.0/AvgBytesPerSec); FrameInfo.PTS=FrameInfo.DTS; Frame_Count_NotParsedIncluded=float64_int64s(((float64)FrameInfo.DTS)/1000000000.0*Demux_Rate); } Demux_random_access=true; Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream); Frame_Count_NotParsedIncluded=(int64u)-1; #endif //MEDIAINFO_DEMUX Element_Code=(int64u)-1; 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 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 Element_Code=(int64u)-1; Stream_ID=(int32u)-1; stream_Count=1; Stream[(int32u)-1].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 #include 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 float64 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 //Streams #if defined(MEDIAINFO_ANCILLARY_YES) Ancillary=NULL; #endif //defined(MEDIAINFO_ANCILLARY_YES) //Temp LookingForLastFrame=false; Stream_Count=0; Info_General_StreamSize=0; Video_Sizes_Pos=(size_t)-1; Audio_Sizes_Pos=(size_t)-1; //Demux #if MEDIAINFO_DEMUX DemuxParser=NULL; #endif //MEDIAINFO_DEMUX //Seek #if MEDIAINFO_SEEK SeekRequest=(int64u)-1; #endif //MEDIAINFO_SEEK FrameRate=0; TimeStamp_Rate=720000; Duration_Detected=false; LastAudio_BufferOffset=(int64u)-1; } //--------------------------------------------------------------------------- File_Lxf::~File_Lxf() { for (size_t Pos=0; PosBuffer_Size) return false; if (Buffer[0]!=0x4C //"LEITCH" || Buffer[1]!=0x45 || Buffer[2]!=0x49 || Buffer[3]!=0x54 || Buffer[4]!=0x43 || Buffer[5]!=0x48 || Buffer[6]!=0x00 || Buffer[7]!=0x00) { Reject(); return false; } return true; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Lxf::Streams_Fill() { Fill(Stream_General, 0, General_Format_Version, __T("Version "+Ztring::ToZtring(Version))); for (size_t Pos=2; PosCount_Get(Stream_Audio) && Config->File_Audio_MergeMonoStreams_Get() && Parser->Retrieve(Stream_Audio, 0, Audio_Format)==__T("PCM")) { 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_PosRetrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); #if MEDIAINFO_DEMUX if (Config->Demux_ForceIds_Get()) for (size_t StreamKind=Stream_General+1; StreamKindCount_Get((stream_t)StreamKind); StreamPos++) { Ztring ID; if (Parser->Count_Get(Stream_Audio) && Parser->Retrieve(Stream_Audio, 0, Audio_MuxingMode)==__T("SMPTE ST 337") && Parser_Pos%2) ID+=Ztring::ToZtring(0x100*Container_StreamKind+Parser_Pos-1)+__T(" / "); 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 } if (Format!=(int8u)-1) Fill(Container_StreamKind, Container_StreamKind==Stream_Video?0:Parser_Pos, Fill_Parameter(Container_StreamKind, Generic_CodecID), Format); if (Container_StreamKind==Stream_Video) for (size_t Pos=Count_Get(Stream_Audio)-Parser->Count_Get(Stream_Audio); PosRetrieve(Stream_General, 0, General_Format)); } //--------------------------------------------------------------------------- void File_Lxf::Streams_Finish() { if (Videos.size()>1 && Videos[1].Parsers.size()==1) //TODO: better handling of fill/finish for Ancillary data { Finish(Videos[1].Parsers[0]); Streams_Fill_PerStream(Videos[1].Parsers[0], Stream_Video, 1); } if (Videos.size()>2 && Videos[2].Parsers.size()==1) { Finish(Videos[2].Parsers[0]); Merge(*Videos[2].Parsers[0], Stream_Video, 0, 0); Ztring LawRating=Videos[2].Parsers[0]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Videos[2].Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } if (Audios_Header.TimeStamp_End!=(int64u)-1 && Audios_Header.TimeStamp_Begin!=(int64u)-1 && Audios_Header.Duration_First!=(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_First); for (size_t Pos=0; Pos=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(); } #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_PosBuffer_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; PosOpen_Buffer_Unsynch(); for (size_t Pos=0; PosOpen_Buffer_Unsynch(); } //--------------------------------------------------------------------------- void File_Lxf::Read_Buffer_Continue() { #if MEDIAINFO_DEMUX if (DemuxParser) { Open_Buffer_Continue(DemuxParser, Buffer+Buffer_Offset, 0, false); if (!Config->Demux_EventWasSent) DemuxParser=NULL; //No more need of it } #endif //MEDIAINFO_DEMUX } //--------------------------------------------------------------------------- #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; PosUnsynch_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_Pos1) { //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=FrameInfo.PTS=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=FrameInfo.PTS=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 VideoFormat, 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*(BitRate>60?10:(BitRate>50?5:1))-(BitRate>60?500:(BitRate>50?200:0)))*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"); if (!Video_Sizes.empty()) Video_Sizes[2]=Size; BlockSize+=Size; Get_L4(Size, "VBI data size"); if (!Video_Sizes.empty()) Video_Sizes[1]=Size; BlockSize+=Size; Skip_L4( "Zero"); Get_L4(Size, "Meta data size"); if (!Video_Sizes.empty()) 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 (2>Videos.size()) Videos.resize(2+1); if (!Video_Sizes.empty()) Videos[2].Format=VideoFormat; 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; 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"); 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; PosBuffer_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)6 && (Stream_Count==0 ||Config->ParseSpeed==0.0)) || Frame_Count>512)) //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*6/Frame_Count); Open_Buffer_Unsynch(); } } } } FILLING_END(); } //*************************************************************************** // Elements //*************************************************************************** //--------------------------------------------------------------------------- void File_Lxf::Header() { Element_Name("Header"); for (size_t Pos=0; PosNextPacket_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"); Skip_C8( "ID"); 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"); BS_Begin_LE(); Skip_T1(7, "recordDate - Year"); Skip_T1(4, "recordDate - Month"); Skip_T1(5, "recordDate - Day"); Skip_T1(7, "killDate - Year"); Skip_T1(4, "killDate - Month"); Skip_T1(5, "killDate - Day"); BS_End_LE(); Skip_L1( "tc_type"); Skip_L1( "status"); Skip_L1( "disk"); Skip_String(26, "description"); Skip_String(16, "agency"); Skip_String( 6, "description"); 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=Audios.size()) Audios.resize(Pos+1); Audios[Pos].Format=Format; } BS_End_LE(); } break; case 24 : //Audio Tag Info { for (int8u Pos=0; PosParseSpeed<1 && Pos=Audios.size()) Audios.resize(Pos+1); if (Audios[Pos].Parsers.empty()) { //Trying to detect if this is PCM /* switch (Audios[Pos].Format) { case (int8u)-1 : //PCM without codec identifier (default) case 0 : //PCM { #ifdef MEDIAINFO_SMPTEST0337_YES { File_ChannelGrouping* Parser=new File_ChannelGrouping; if (Pos%2 && !Audios[Pos-1].Parsers.empty()) { Parser->Channel_Pos=1; Parser->Common=((File_ChannelGrouping*)Audios[Pos-1].Parsers[0])->Common; Parser->StreamID=Pos-1; Element_Code--; } else { Parser->Channel_Pos=0; Parser->SampleRate=48000; } Parser->Channel_Total=2; Parser->ByteDepth=SampleSize/8; Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_SMPTEST0337_YES Audios[Pos].BytesPerFrame=Audio_Sizes[Pos]; #ifdef MEDIAINFO_PCM_YES File_Pcm* Parser=new File_Pcm; Parser->SamplingRate=48000; Parser->Channels=1; Parser->BitDepth=SampleSize; Parser->Endianness='L'; #if !defined(MEDIAINFO_MPEGA_YES) && !defined(MEDIAINFO_SMPTEST0337_YES) Parser->Frame_Count_Valid=1; #else Parser->Frame_Count_Valid=2; #endif #else //MEDIAINFO_PCM_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_PCM_YES Open_Buffer_Init(Parser); #ifndef MEDIAINFO_PCM_YES Parser->Accept(); Parser->Stream_Prepare(Stream_Audio); int64u BitRate=float64_int64s(Audio_Sizes[Pos]*TimeStamp_Rate*8/(Audios_Header.TimeStamp_End-Audios_Header.TimeStamp_Begin)); Parser->Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, BitRate); Parser->Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR"); Parser->Fill(Stream_Audio, StreamPos_Last, Audio_Format, "PCM"); Parser->Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 48000); Parser->Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1); Parser->Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, SampleSize); Parser->Fill(); #endif //MEDIAINFO_PCM_YES Audios[Pos].Parsers.push_back(Parser); #ifdef MEDIAINFO_MPEGA_YES { File_Mpega* Parser=new File_Mpega(); Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_MPEGA_YES } break; case 1 : //DTS { #ifdef MEDIAINFO_DTS_YES File_Dts* Parser=new File_Dts(); #else //MEDIAINFO_DTS_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_DTS_YES Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } break; case 2 : //AC-3 case 5 : //E-AC-3 { #ifdef MEDIAINFO_AC3_YES File_Ac3* Parser=new File_Ac3; #else //MEDIAINFO_AAC_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_AAC_YES Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } break; case 3 : //Dolby E { #ifdef MEDIAINFO_SMPTEST0337_YES { File_ChannelGrouping* Parser=new File_ChannelGrouping; if (Pos%2 && !Audios[Pos-1].Parsers.empty()) { Parser->Channel_Pos=1; Parser->Common=((File_ChannelGrouping*)Audios[Pos-1].Parsers[0])->Common; Parser->StreamID=Pos-1; Element_Code--; } else { Parser->Channel_Pos=0; Parser->SampleRate=48000; } Parser->Channel_Total=2; Parser->ByteDepth=SampleSize/8; Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_SMPTEST0337_YES #ifdef MEDIAINFO_DOLBYE_YES File_DolbyE* Parser=new File_DolbyE(); #else //MEDIAINFO_DOLBYE_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_DOLBYE_YES Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } case 4 : { #ifdef MEDIAINFO_MPEGA_YES File_Mpega* Parser=new File_Mpega(); #else //MEDIAINFO_MPEGA_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_MPEGA_YES Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } break; case 6 : { #ifdef MEDIAINFO_AAC_YES File_Aac* Parser=new File_Aac(); Parser->Mode=File_Aac::Mode_ADTS; #else //MEDIAINFO_AAC_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_AAC_YES Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } break; default : { File__Analyze* Parser=new File__Analyze; Open_Buffer_Init(Parser); Audios[Pos].Parsers.push_back(Parser); } } */ #ifdef MEDIAINFO_SMPTEST0337_YES if (!(Pos%2 && Audios[Pos-1].Parsers.size()<=1)) //If the first half-stream was already rejected, don't try this one { File_ChannelGrouping* Parser=new File_ChannelGrouping; if (Pos%2 && !Audios[Pos-1].Parsers.empty()) { Parser->Channel_Pos=1; Parser->Common=((File_ChannelGrouping*)Audios[Pos-1].Parsers[0])->Common; Parser->StreamID=Pos-1; } else Parser->Channel_Pos=0; Parser->BitDepth=SampleSize; Parser->Channel_Total=2; Parser->SamplingRate=48000; Parser->Endianness='L'; Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_SMPTEST0337_YES #ifdef MEDIAINFO_SMPTEST0337_YES { File_SmpteSt0337* Parser=new File_SmpteSt0337; Parser->Container_Bits=SampleSize; Parser->Endianness='L'; Parser->Aligned=true; Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_SMPTEST0337_YES #ifdef MEDIAINFO_AC3_YES Audios[Pos].Parsers.push_back(new File_Ac3()); #endif //MEDIAINFO_AC3_YES #ifdef MEDIAINFO_DTS_YES Audios[Pos].Parsers.push_back(new File_Dts()); #endif //MEDIAINFO_DTS_YES #ifdef MEDIAINFO_MPEGA_YES Audios[Pos].Parsers.push_back(new File_Mpega()); #endif //MEDIAINFO_MPEGA_YES #ifdef MEDIAINFO_AAC_YES { File_Aac* Parser=new File_Aac; Parser->Mode=File_Aac::Mode_ADTS; Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_AAC_YES #ifdef MEDIAINFO_PCM_YES { File_Pcm* Parser=new File_Pcm; Parser->SamplingRate=48000; Parser->Channels=1; Parser->BitDepth=SampleSize; Parser->Endianness='L'; #if !defined(MEDIAINFO_SMPTEST0337_YES) && !defined(MEDIAINFO_MPEGA_YES) Parser->Frame_Count_Valid=1; #else Parser->Frame_Count_Valid=2; #endif Audios[Pos].Parsers.push_back(Parser); } #endif //MEDIAINFO_PCM_YES for (size_t Pos2=0; Pos2Demux_Unpacketize_Get()) { Audios[Pos].Parsers[Pos2]->Demux_Level=2; //Container Audios[Pos].Parsers[Pos2]->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX } Stream_Count++; } /* #if MEDIAINFO_DEMUX #if MEDIAINFO_SEEK if (SeekRequest==(int64u)-1) #endif //MEDIAINFO_SEEK { Element_Code=0x200+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); delete[] SixteenBit; } else if (SampleSize==20 && Config->Demux_PCM_20bitTo24bit_Get()) { //Padding bits 3-0 (Little endian) int8u* Output=new int8u[(size_t)Audio_Sizes[Pos]*24/20]; size_t Output_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) { Output[Output_Pos ] = Buffer[Buffer_Pos+0]<<4 ; Output[Output_Pos+1] = (Buffer[Buffer_Pos+1]<<4 ) | (Buffer[Buffer_Pos+0]>>4 ); Output[Output_Pos+2] = (Buffer[Buffer_Pos+2]<<4 ) | (Buffer[Buffer_Pos+1]>>4 ); Output[Output_Pos+3] = Buffer[Buffer_Pos+2]&0xF0 ; Output[Output_Pos+4] = Buffer[Buffer_Pos+3] ; Output[Output_Pos+5] = Buffer[Buffer_Pos+4] ; Buffer_Pos+=5; Output_Pos+=6; } Demux(Output, Output_Pos, ContentType_MainStream); delete[] Output; } else Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Audio_Sizes[Pos], ContentType_MainStream); } #endif //MEDIAINFO_DEMUX */ #if MEDIAINFO_DEMUX #if MEDIAINFO_SEEK if (SeekRequest==(int64u)-1) #endif //MEDIAINFO_SEEK { Element_Code=0x200+Pos; Frame_Count_NotParsedIncluded=float64_int64s(((float64)(Audios_Header.TimeStamp_End-Audios_Header.Duration))/TimeStamp_Rate*FrameRate); Demux_Level=4; //Intermediate Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Audio_Sizes[Pos], ContentType_MainStream); } #endif //MEDIAINFO_DEMUX //Parsing Frame_Count_NotParsedIncluded=float64_int64s(((float64)(Audios_Header.TimeStamp_End-Audios_Header.Duration))/TimeStamp_Rate*FrameRate); for (size_t Pos2=0; Pos2FrameInfo.DTS==(int64u)-1 || !((FrameInfo.DUR/2>FrameInfo.DTS || Audios[Pos].Parsers[Pos2]->FrameInfo.DTS>=FrameInfo.DTS-FrameInfo.DUR/2) && Audios[Pos].Parsers[Pos2]->FrameInfo.DTSFrameInfo=FrameInfo; Open_Buffer_Continue(Audios[Pos].Parsers[Pos2], Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Audio_Sizes[Pos]); if (Audios[Pos].Parsers.size()>1) { if (!Audios[Pos].Parsers[Pos2]->Status[IsAccepted] && Audios[Pos].Parsers[Pos2]->Status[IsFinished]) { delete *(Audios[Pos].Parsers.begin()+Pos2); Audios[Pos].Parsers.erase(Audios[Pos].Parsers.begin()+Pos2); Pos2--; } else if (Audios[Pos].Parsers.size()>1 && Audios[Pos].Parsers[Pos2]->Status[IsAccepted]) { File__Analyze* Parser=Audios[Pos].Parsers[Pos2]; for (size_t Pos3=0; Pos3Status[IsFilled]) { if (Stream_Count>0) Stream_Count--; Audios[Pos].IsFilled=true; } #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent) DemuxParser=Audios[Pos].Parsers[0]; #endif //MEDIAINFO_DEMUX } Element_Offset+=Audio_Sizes[Pos]; } //--------------------------------------------------------------------------- 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 || (Config->ParseSpeed<1 && Pos=Videos.size()) Videos.resize(Pos+1); switch (Pos) { case 1 : Video_Stream_1(); break; case 2 : Video_Stream_2(); break; default: ; } } //--------------------------------------------------------------------------- void File_Lxf::Video_Stream_1() { if (Video_Sizes[1]<2) { Skip_XX(Video_Sizes[1], "Unknown"); return; } int8u Lines_Allocated, Lines_Used; Get_L1 (Lines_Allocated, "Lines allocated"); Get_L1 (Lines_Used, "Lines used"); if (Lines_Allocated==0 || Lines_Used>Lines_Allocated || Video_Sizes[1]<2+Lines_Used) { Skip_XX(Video_Sizes[1]-2, "Unknown"); return; } Videos[1].BytesPerFrame=Video_Sizes[1]-(2+Lines_Allocated); int64u BytesPerLine=Videos[1].BytesPerFrame/Lines_Allocated; std::vector FieldNumbers; std::vector FieldNumbers_IsSecondField; BS_Begin_LE(); for (int8u Pos=0; PosInDecodingOrder=true; Ancillary->WithChecksum=true; Ancillary->MustSynchronize=true; Open_Buffer_Init(Ancillary); Videos[1].Parsers.push_back(Ancillary); Stream_Count++; } Videos[1].Parsers[0]->FrameInfo=FrameInfo; ((File_Ancillary*)Videos[1].Parsers[0])->LineNumber=FieldNumbers[Pos]; ((File_Ancillary*)Videos[1].Parsers[0])->LineNumber_IsSecondField=FieldNumbers_IsSecondField[Pos]; Open_Buffer_Continue(Videos[1].Parsers[0], Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)BytesPerLine); if (Videos[1].Parsers[0]->Status[IsFilled]) { if (Stream_Count>0) Stream_Count--; Videos[1].IsFilled=true; } Element_Offset+=BytesPerLine; Element_End0(); #else Skip_XX(BytesPerLine, "VBI/VANC data"); #endif } Skip_XX((Lines_Allocated-Lines_Used)*BytesPerLine, "Unused lines"); if (Element_OffsetStream_Prepare(Stream_Video); Parser->Fill(Stream_Video, 0, Video_Format, "MPEG Video"); if (Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin) { FrameRate=((float64)1)*TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin); if (FrameRate) Parser->Fill(Stream_Video, 0, Video_FrameRate, FrameRate); } #endif //MEDIAINFO_MPEGV_YES Videos[2].Parsers.push_back(Parser); } break; case 0x04 : case 0x05 : case 0x06 : { #ifdef MEDIAINFO_DVDIF_YES File_DvDif* Parser=new File_DvDif(); #else //MEDIAINFO_DVDIF_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_DVDIF_YES Open_Buffer_Init(Parser); #ifndef MEDIAINFO_DVDIF_YES Parser->Stream_Prepare(Stream_Video); Parser->Fill(Stream_Video, 0, Video_Format, "DV"); if (Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin) { FrameRate=((float64)1)*TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin); if (FrameRate) Parser->Fill(Stream_Video, 0, Video_FrameRate, FrameRate); int64u BitRate=float64_int64s(((float64)Video_Sizes[1])*TimeStamp_Rate*8/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin)); if (BitRate) Parser->Fill(Stream_Video, 0, Video_BitRate, BitRate); Parser->Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR"); } #endif //MEDIAINFO_DVDIF_YES Videos[2].Parsers.push_back(Parser); } #ifdef MEDIAINFO_VC3_YES if (Videos[2].Format==0x06) // One file with VideoFormat = 6 has VC-3 { File_Vc3* Parser=new File_Vc3(); Open_Buffer_Init(Parser); Videos[2].Parsers.push_back(Parser); } #endif //MEDIAINFO_VC3_YES break; case 0x0A : case 0x0B : case 0x0C : case 0x0D : { #ifdef MEDIAINFO_AVC_YES File_Avc* Parser=new File_Avc(); #else //MEDIAINFO_AVC_YES File__Analyze* Parser=new File__Analyze; #endif //MEDIAINFO_AVC_YES Open_Buffer_Init(Parser); #ifndef MEDIAINFO_AVC_YES Parser->Accept(); Parser->Stream_Prepare(Stream_Video); Parser->Fill(Stream_Video, 0, Video_Format, "AVC"); if (Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin) { FrameRate=((float64)1)*TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin); if (FrameRate) Parser->Fill(Stream_Video, 0, Video_FrameRate, FrameRate); } #endif //MEDIAINFO_AVC_YES Videos[2].Parsers.push_back(Parser); } break; default : { File__Analyze* Parser=new File__Analyze; Open_Buffer_Init(Parser); Videos[2].Parsers.push_back(Parser); } } */ #ifdef MEDIAINFO_DVDIF_YES Videos[2].Parsers.push_back(new File_DvDif()); #endif //MEDIAINFO_DVDIF_YES #ifdef MEDIAINFO_MPEGV_YES { File_Mpegv* Parser=new File_Mpegv(); #if defined(MEDIAINFO_ANCILLARY_YES) Parser->Ancillary=&Ancillary; #endif //defined(MEDIAINFO_ANCILLARY_YES) Videos[2].Parsers.push_back(Parser); } #endif //MEDIAINFO_MPEGV_YES #ifdef MEDIAINFO_AVC_YES Videos[2].Parsers.push_back(new File_Avc()); #endif //MEDIAINFO_AVC_YES #ifdef MEDIAINFO_VC3_YES Videos[2].Parsers.push_back(new File_Vc3()); #endif //MEDIAINFO_VC3_YES for (size_t Pos2=0; Pos2FrameInfo=FrameInfo; Open_Buffer_Continue(Videos[2].Parsers[Pos2], Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Video_Sizes[2]); Element_Show(); if (Videos[2].Parsers.size()>1) { if (!Videos[2].Parsers[Pos2]->Status[IsAccepted] && Videos[2].Parsers[Pos2]->Status[IsFinished]) { delete *(Videos[2].Parsers.begin()+Pos2); Videos[2].Parsers.erase(Videos[2].Parsers.begin()+Pos2); Pos2--; } else if (Videos[2].Parsers.size()>1 && Videos[2].Parsers[Pos2]->Status[IsAccepted]) { File__Analyze* Parser=Videos[2].Parsers[Pos2]; for (size_t Pos3=0; Pos3Status[IsFilled]) { if (Stream_Count>0) Stream_Count--; Videos[2].IsFilled=true; } } Element_Offset+=Video_Sizes[2]; } } //NameSpace #endif //MEDIAINFO_LXF_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Dxw.cpp0000664000000000000000000001645312652076434021155 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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/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_Dxw; 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->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") { sequence* Sequence=new sequence; Attribute=Track->Attribute("file"); if (Attribute) { Sequence->AddFileName(Ztring().From_UTF8(Attribute)); Attribute=Track->Attribute("type"); if (Attribute) { Ztring StreamKind; StreamKind.From_UTF8(Attribute); if (StreamKind==__T("video")) Sequence->StreamKind=Stream_Video; if (StreamKind==__T("audio")) Sequence->StreamKind=Stream_Audio; if (StreamKind==__T("data")) Sequence->StreamKind=Stream_Text; //Not sure this is a right mapping, but this is only used when file is missing } Attribute=Track->Attribute("source"); if (Attribute) { Ztring StreamKind; StreamKind.From_UTF8(Attribute); if (StreamKind==__T("main")) Sequence->IsMain=true; } Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; } Attribute=Track->Attribute("framerate"); if (Attribute) { Sequence->FrameRate_Set(Ztring().From_UTF8(Attribute).To_float64()); Attribute=Track->Attribute("type"); if (Attribute) { Ztring StreamKind; StreamKind.From_UTF8(Attribute); if (StreamKind==__T("video")) Sequence->StreamKind=Stream_Video; if (StreamKind==__T("audio")) Sequence->StreamKind=Stream_Audio; if (StreamKind==__T("data")) Sequence->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) Sequence->AddFileName(Ztring().From_UTF8(Attribute)); } Frame=Frame->NextSiblingElement(); } } Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } Track=Track->NextSiblingElement(); } } else { Reject("DXW"); return false; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_DXW_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Riff.h0000664000000000000000000002411512652076434020740 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about RIFF files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_RiffH #define MediaInfo_File_RiffH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #if defined(MEDIAINFO_ANCILLARY_YES) #include #endif //defined(MEDIAINFO_ANCILLARY_YES) #include //--------------------------------------------------------------------------- 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 #if MEDIAINFO_DEMUX void Read_Buffer_Continue (); #endif //MEDIAINFO_DEMUX void Read_Buffer_Unsynched(); //Buffer - Per element bool Header_Begin(); void Header_Parse(); void Data_Parse(); bool BookMark_Needed(); //Data struct stream { std::vector 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; bool IsPcm; 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; IsPcm=false; } ~stream() { for (size_t Pos=0; Pos Stream; int32u Stream_ID; struct stream_structure { int64u Name; int64u Size; }; std::map Stream_Structure; std::map::iterator Stream_Structure_Temp; std::map 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 PAR; 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; #if defined(MEDIAINFO_GXF_YES) int32u rcrd_fld__anc__pos__LineNumber; #endif //defined(MEDIAINFO_GXF_YES) 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_strf_vids_Ffv1(); void AVI__hdlr_strl_strf_vids_HuffYUV(int16u BitCount, int32u Height); 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(); //Temp #if MEDIAINFO_DEMUX File__Analyze* Demux_Parser; #endif //MEDIAINFO_DEMUX }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Aaf.h0000664000000000000000000001071312652076434020540 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about AAF files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_AafH #define MediaInfo_File_AafH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; //*************************************************************************** // Class File_Aaf //*************************************************************************** class File_Aaf : public File__Analyze { public : //Constructor/Destructor File_Aaf(); ~File_Aaf(); 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 void Read_Buffer_Continue (); //Buffer - File header bool FileHeader_Begin(); //Buffer - Per element void Header_Parse(); void Data_Parse(); //Elements void FatSect(); void Fat(); void MiniFat(); void Directory(); void Directory_Entry(); void StreamElement(); void StreamElement_Parse(); void MetaDictionary(); //0x0001 void Header(); //0x0002 void ClassDefinitions(); //0x0003 void TypeDefinitions(); //0x0004 void Identification(); //0x0005 void Name(); //0x0006 void MetaDefinition(); //0x0007 void ParentClass(); //0x0008 void Properties(); //0x0009 void IsConcrete(); //0x000A void Type(); //0x000B void IsOptional(); //0x000C void LocalIdentification(); //0x000D void IsUniqueIdentifier(); //0x000E void Size(); //0x000F void Locked(); //0x3D02 void NetworkLocator(); //0x4001 //Temp int16u xxxSize; int16u SectorShift; int16u MiniSectorShift; int32u sectMiniFatStart; int32u sectDirStart; int32u MiniSectorCutoff; typedef enum step { Step_None, Step_Fat, Step_MiniFat, Step_Directory, Step_Stream, } step; step Step; vector sectsFat; vector sectsMiniStream; vector Pointers; vector MiniPointers; typedef struct stream { Ztring Name; size_t Directory_Pos; int32u ChildSID; int64u Size; int8u* Buffer; vector StreamOffsets; stream(const Ztring Name_, size_t Directory_Pos_, int64u Size_) : Name(Name_), Directory_Pos(Directory_Pos_), ChildSID((int32u)-1), Size(Size_), Buffer(NULL) { } private: stream &operator=(const stream &v); stream(); } stream; vector Streams; size_t sectsFat_Pos; size_t Streams_Pos; size_t Streams_Pos2; size_t Directory_Pos; File__ReferenceFilesHelper* ReferenceFiles; //Descriptor /* struct descriptor { stream_t StreamKind; int32u ChildSID; descriptor() { StreamKind=Stream_Max; ChildSID=(int32u)-1; } }; typedef std::map descriptors; //Key is Directory_Pos of Descriptor descriptors Descriptors; */ //Locator /* struct locator { Ztring EssenceLocator; }; typedef std::map locators; //Key is Directory_Pos of the locator locators Locators; */ }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_DvDif_Analysis.cpp0000664000000000000000000022623512652076434023253 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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; } Ztring Errors_Stats_Line; if (Speed_FrameCount) //We must have at least one complete frame { bool Errors_AreDetected=false; bool Infos_AreDetected=false; bool Arb_AreDetected=false; #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) 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=(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; Pos2) { 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_Possize() && Speed_FrameCount-1>=Mpeg4_stts->at(Mpeg4_stts_Pos).Pos_Begin && Speed_FrameCount-1at(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(this, (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; Pos2) 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 MediaInfoLib/Source/MediaInfo/Multiple/File_DashMpd.cpp0000664000000000000000000007010412652076434021724 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ // Period // AdaptationSet --> One per stream // SegmentTemplate (optional) // SegmentTimeline // S --> duration per segment, count of segments // Representation --> file name from SegmentTemplate or BaseURL // SegmentBase // SegmentList // Representation --> file name from BaseURL //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DASHMPD_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_DashMpd.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "ZenLib/FileName.h" #include "ZenLib/File.h" #include "tinyxml2.h" using namespace ZenLib; using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- void DashMpd_Transform (Ztring &Value, std::map &Attributes) { size_t Pos1=0; for (;;) { Pos1=Value.find(__T('$'), Pos1); if (Pos1==string::npos) break; size_t Pos2=Value.find(__T('$'), Pos1+1); if (Pos2==string::npos) break; Ztring Name=Value.substr(Pos1+1, Pos2-Pos1-1); if (Name.empty()) Value.erase(Pos1, 1); else { if (Name==__T("RepresentationID")) Name=__T("id"); if (Name==__T("Bandwidth")) Name=__T("bandwidth"); std::map::iterator Attribute_It=Attributes.find(Name); if (Attribute_It!=Attributes.end()) { Value.erase(Pos1, Pos2-Pos1+1); Value.insert(Pos1, Attribute_It->second); } else Pos1+=2+Name.size(); } } } //--------------------------------------------------------------------------- stream_t DashMpd_mimeType_StreamKind (const char* mimeType) { Ztring StreamKind; StreamKind.From_UTF8(mimeType); if (StreamKind.find(__T("video"))==0) return Stream_Video; else if (StreamKind.find(__T("audio"))==0) return Stream_Audio; else if (StreamKind.find(__T("application/ttml+xml"))==0) return Stream_Text; else return Stream_Other; } //--------------------------------------------------------------------------- Ztring DashMpd_codecid_CodecID (const char* codecid) { Ztring CodecID; Ztring Codecs; Codecs.From_UTF8(codecid); size_t DotPos=Codecs.find(__T('.')); if (DotPos==4 && Codecs.substr(0, DotPos).find(__T("mp4"))==0) DotPos=Codecs.find(__T('.'), 5); if (DotPos==string::npos) { CodecID=Codecs; } else { CodecID=Codecs.substr(0, DotPos); //TODO per format, rfc 6381 //Sequence->Infos["Format_Profile"]=; } CodecID.FindAndReplace(__T("0x"), Ztring(), 0, Ztring_Recursive); return CodecID; } //--------------------------------------------------------------------------- struct template_generic { sequence* Sequence; Ztring SourceDir; Ztring BaseURL; Ztring initialization; Ztring media; int64u duration; int64u startNumber; int64u duration_Max; int64u startNumber_Max; struct segmenttimeline { int64u t; //start time int64u d; //duration per segment int64u r; //repeat count segmenttimeline() { t=1; d=1; r=0; } }; std::vector SegmentTimeLines; std::map Attributes_ForMedia; template_generic(const Ztring &BaseURL=Ztring(), const Ztring &SourceDir=Ztring()) { Sequence=new sequence; template_generic::BaseURL=BaseURL; template_generic::SourceDir=SourceDir; duration=1; startNumber=1; duration_Max=0; startNumber_Max=0; } template_generic(const template_generic &ToCopy) { Sequence=new sequence; *Sequence=*ToCopy.Sequence; template_generic::BaseURL=ToCopy.BaseURL; template_generic::SourceDir=ToCopy.SourceDir; initialization=ToCopy.initialization; media=ToCopy.media; duration=ToCopy.duration; startNumber=ToCopy.duration; duration_Max=ToCopy.duration_Max; startNumber_Max=ToCopy.startNumber_Max; } void AdaptationSet_Attributes_Parse (XMLElement* Item); void SegmentTemplate_Attributes_Parse (XMLElement* Item); void SegmentTimeline_Attributes_Parse (XMLElement* Item); void Representation_Attributes_Parse (XMLElement* Item); void Decode (); }; void template_generic::AdaptationSet_Attributes_Parse (XMLElement* Item) { const char* Attribute; //Attributes - mineType Attribute=Item->Attribute("mimeType"); if (Attribute) Sequence->StreamKind=DashMpd_mimeType_StreamKind(Attribute); //Attributes - codecs Attribute=Item->Attribute("codecs"); if (Attribute) Sequence->Infos["CodecID"]=DashMpd_codecid_CodecID(Attribute); //Attributes - lang Attribute=Item->Attribute("lang"); if (Attribute) Sequence->Infos["Language"].From_UTF8(Attribute); } void template_generic::SegmentTemplate_Attributes_Parse (XMLElement* Item) { const char* Attribute; //Attributes - initialization Attribute=Item->Attribute("initialization"); if (Attribute) { initialization.From_UTF8(Attribute); } //Attributes - media Attribute=Item->Attribute("media"); if (Attribute) { media.From_UTF8(Attribute); } //Attributes - duration Attribute=Item->Attribute("duration"); if (Attribute) { duration=Ztring().From_UTF8(Attribute).To_int64u(); } //Attributes - startNumber Attribute=Item->Attribute("startNumber"); if (Attribute) { startNumber=Ztring().From_UTF8(Attribute).To_int64u(); } } void template_generic::SegmentTimeline_Attributes_Parse (XMLElement* Item) { const char* Attribute; segmenttimeline SegmentTimeLine; //Attributes - t (start time) Attribute=Item->Attribute("t"); if (Attribute) { SegmentTimeLine.t=Ztring().From_UTF8(Attribute).To_int64u(); } else SegmentTimeLine.t=startNumber; //Attributes - d (duration per segment) Attribute=Item->Attribute("d"); if (Attribute) { SegmentTimeLine.d=Ztring().From_UTF8(Attribute).To_int64u(); } else SegmentTimeLine.d=duration; //Attributes - r (repeat count) Attribute=Item->Attribute("r"); if (Attribute) { SegmentTimeLine.r=Ztring().From_UTF8(Attribute).To_int64u(); } SegmentTimeLines.push_back(SegmentTimeLine); duration_Max+=SegmentTimeLine.d*(SegmentTimeLine.r+1); startNumber_Max+=SegmentTimeLine.r+1; } void template_generic::Representation_Attributes_Parse (XMLElement* Item) { const char* Attribute; //Attributes - id Attribute=Item->Attribute("id"); if (Attribute) { Sequence->StreamID=Ztring().From_UTF8(Attribute).To_int64u(16); } //Attributes - bandwidth Attribute=Item->Attribute("bandwidth"); if (Attribute) { Sequence->Infos["BitRate"].From_UTF8(Attribute); } //Attributes - frame size Attribute=Item->Attribute("width"); if (Attribute) { Sequence->Infos["Width"].From_UTF8(Attribute); } Attribute=Item->Attribute("height"); if (Attribute) { Sequence->Infos["Height"].From_UTF8(Attribute); } //Attributes - mineType Attribute=Item->Attribute("mimeType"); if (Attribute) Sequence->StreamKind=DashMpd_mimeType_StreamKind(Attribute); //Attributes - codecs Attribute=Item->Attribute("codecs"); if (Attribute) Sequence->Infos["CodecID"]=DashMpd_codecid_CodecID(Attribute); //Attributes - lang Attribute=Item->Attribute("lang"); if (Attribute) Sequence->Infos["Language"].From_UTF8(Attribute); //Attributes - Saving all attributes for (const XMLAttribute* Attribute_Item=Item->FirstAttribute(); Attribute_Item; Attribute_Item=Attribute_Item->Next()) { Ztring Name; Name.From_UTF8(Attribute_Item->Name()); Ztring Value; Value.From_UTF8(Attribute_Item->Value()); Attributes_ForMedia[Name]=Value; } } //--------------------------------------------------------------------------- void template_generic::Decode() { //initialization - URL decoding, template adaptation and add it if (!initialization.empty()) { DashMpd_Transform(initialization, Attributes_ForMedia); Sequence->AddFileName(BaseURL+initialization); } //media - URL decoding, template adaptation and add it if (!media.empty()) { DashMpd_Transform(media, Attributes_ForMedia); size_t Index_Pos=media.find(__T("$Index")); size_t Index_StringSize=5; if (Index_Pos==string::npos) { Index_Pos=media.find(__T("$Number")); Index_StringSize++; } int8u Index_Size=1; if (Index_Pos!=string::npos) { size_t Index_Pos_End=media.find(__T('$'), Index_Pos+1+Index_StringSize); if (Index_Pos_End!=string::npos && Index_Pos+1+Index_StringSize+2Index_Pos) Time_Pos-=1+Index_StringSize+1; } if (Time_Pos!=string::npos) { Media_Name.erase(Time_Pos, 6); if (Index_Pos!=string::npos && Index_Pos>Time_Pos) Index_Pos-=6; } if (SegmentTimeLines.empty()) { int64u Index_Pos_Temp=startNumber; for (;;) { Ztring Media_Name_Temp(Media_Name); Ztring Index; Index.From_Number(Index_Pos_Temp); if (Index.size()AddFileName(File_Name); Index_Pos_Temp++; } } else { int64u SegmentTimeLines_duration=0; int64u SegmentTimeLines_startNumber=startNumber; for (size_t SegmentTimeLines_Pos=0; SegmentTimeLines_PosIndex_Pos) Time_Pos_Temp+=Index.size(); } if (Time_Pos_Temp!=string::npos) { Ztring Time; Time.From_Number(SegmentTimeLines_duration); Media_Name_Temp.insert(Time_Pos_Temp, Time); } Sequence->AddFileName(BaseURL+Media_Name_Temp); SegmentTimeLines_duration+=SegmentTimeLines[SegmentTimeLines_Pos].d; SegmentTimeLines_startNumber++; } } } } else Sequence->AddFileName(BaseURL+media); } } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_DashMpd::File_DashMpd() :File__Analyze() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_DashMpd; StreamIDs_Width[0]=16; #endif //MEDIAINFO_EVENTS //Temp ReferenceFiles=NULL; } //--------------------------------------------------------------------------- File_DashMpd::~File_DashMpd() { delete ReferenceFiles; //ReferenceFiles=NULL; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_DashMpd::Streams_Finish() { if (ReferenceFiles==NULL) return; ReferenceFiles->ParseReferences(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_DashMpd::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { if (ReferenceFiles==NULL) return 0; return ReferenceFiles->Seek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_DashMpd::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; { XMLElement* Root=document.FirstChildElement("MPD"); if (Root) { const char* Attribute=Root->Attribute("xmlns"); if (Attribute==NULL || (Ztring().From_UTF8(Attribute)!=__T("urn:mpeg:DASH:schema:MPD:2011") && Ztring().From_UTF8(Attribute)!=__T("urn:mpeg:dash:schema:mpd:2011") //Some muxers use lower case version && Ztring().From_UTF8(Attribute)!=__T("urn:3GPP:ns:PSS:AdaptiveHTTPStreamingMPD:2009"))) { Reject("DashMpd"); return false; } Accept("DashMpd"); Fill(Stream_General, 0, General_Format, "DASH MPD"); Config->File_ID_OnlyRoot_Set(false); ReferenceFiles=new File__ReferenceFilesHelper(this, Config); //Parsing main elements Ztring BaseURL; for (XMLElement* Root_Item=Root->FirstChildElement(); Root_Item; Root_Item=Root_Item->NextSiblingElement()) { //Common information if (string(Root_Item->Value())=="BaseURL") { if (BaseURL.empty()) //Using the first one BaseURL=Root_Item->GetText(); } //Period if (string(Root_Item->Value())=="Period") { for (XMLElement* Period_Item=Root_Item->FirstChildElement(); Period_Item; Period_Item=Period_Item->NextSiblingElement()) { //AdaptationSet (=a stream) if (string(Period_Item->Value())=="AdaptationSet") { template_generic Template_Generic(BaseURL, FileName(File_Name).Path_Get()); Template_Generic.AdaptationSet_Attributes_Parse(Period_Item); //Sub for (XMLElement* AdaptationSet_Item=Period_Item->FirstChildElement(); AdaptationSet_Item; AdaptationSet_Item=AdaptationSet_Item->NextSiblingElement()) { //SegmentTemplate if (string(AdaptationSet_Item->Value())=="SegmentTemplate") { Template_Generic.SegmentTemplate_Attributes_Parse(AdaptationSet_Item); //Sub for (XMLElement* SegmentTemplate_Item=AdaptationSet_Item->FirstChildElement(); SegmentTemplate_Item; SegmentTemplate_Item=SegmentTemplate_Item->NextSiblingElement()) { //SegmentTimeline if (string(SegmentTemplate_Item->Value())=="SegmentTimeline") { //Sub for (XMLElement* SegmentTimeline_Item=SegmentTemplate_Item->FirstChildElement(); SegmentTimeline_Item; SegmentTimeline_Item=SegmentTimeline_Item->NextSiblingElement()) { //SegmentTimeline if (string(SegmentTimeline_Item->Value())=="S") { Template_Generic.SegmentTimeline_Attributes_Parse(SegmentTimeline_Item); } } } } } //Representation if (string(AdaptationSet_Item->Value())=="Representation") { template_generic Template_Generic_PerRepresentation(Template_Generic); Template_Generic_PerRepresentation.Representation_Attributes_Parse(AdaptationSet_Item); //Sub for (XMLElement* Representation_Item=AdaptationSet_Item->FirstChildElement(); Representation_Item; Representation_Item=Representation_Item->NextSiblingElement()) { //BaseURL if (string(Representation_Item->Value())=="BaseURL") { Template_Generic_PerRepresentation.Sequence->AddFileName(BaseURL+Ztring().From_UTF8(Representation_Item->GetText())); } //SegmentTemplate if (string(Representation_Item->Value())=="SegmentTemplate") { Template_Generic_PerRepresentation.SegmentTemplate_Attributes_Parse(Representation_Item); } //SegmentBase if (string(Representation_Item->Value())=="SegmentBase") { //Sub for (XMLElement* SegmentBase_Item=Representation_Item->FirstChildElement(); SegmentBase_Item; SegmentBase_Item=SegmentBase_Item->NextSiblingElement()) { //Initialization if (string(SegmentBase_Item->Value())=="Initialization") { Attribute=SegmentBase_Item->Attribute("sourceURL"); if (Attribute) Template_Generic_PerRepresentation.Sequence->AddFileName(BaseURL+Ztring().From_UTF8(Attribute), 0); } } } //SegmentList if (string(Representation_Item->Value())=="SegmentList") { //Sub for (XMLElement* SegmentBase_Item=Representation_Item->FirstChildElement(); SegmentBase_Item; SegmentBase_Item=SegmentBase_Item->NextSiblingElement()) { //Initialization if (string(SegmentBase_Item->Value())=="SegmentURL") { bool IsSupported=true; Attribute=SegmentBase_Item->Attribute("mediaRange"); if (Attribute) { size_t Length=strlen(Attribute); if (Length<2 || Attribute[0]!='0' || Attribute[1]!='-') IsSupported=false; //Currently, we do not support ranges } Attribute=SegmentBase_Item->Attribute("media"); if (Attribute && IsSupported) Template_Generic_PerRepresentation.Sequence->AddFileName(BaseURL+Ztring().From_UTF8(Attribute)); } } } } Template_Generic_PerRepresentation.Decode(); ReferenceFiles->AddSequence(Template_Generic_PerRepresentation.Sequence); } } } //Representation (=a stream) if (string(Period_Item->Value())=="Representation") { sequence* Sequence=new sequence; int64u duration=1; //Attributes - mineType Attribute=Period_Item->Attribute("mimeType"); if (Attribute) Sequence->StreamKind=DashMpd_mimeType_StreamKind(Attribute); //Attributes - codecs Attribute=Period_Item->Attribute("codecs"); if (Attribute) Sequence->Infos["CodecID"]=DashMpd_codecid_CodecID(Attribute); //Attributes - lang Attribute=Period_Item->Attribute("lang"); if (Attribute) Sequence->Infos["Language"].From_UTF8(Attribute); //Sub for (XMLElement* AdaptationSet_Item=Period_Item->FirstChildElement(); AdaptationSet_Item; AdaptationSet_Item=AdaptationSet_Item->NextSiblingElement()) { //SegmentInfo if (string(AdaptationSet_Item->Value())=="SegmentInfo") { //Attributes - duration Attribute=AdaptationSet_Item->Attribute("duration"); if (Attribute) { duration=Ztring().From_UTF8(Attribute).To_int64u(); } //Sub for (XMLElement* SegmentInfo_Item=AdaptationSet_Item->FirstChildElement(); SegmentInfo_Item; SegmentInfo_Item=SegmentInfo_Item->NextSiblingElement()) { //InitialisationSegmentURL if (string(SegmentInfo_Item->Value())=="InitialisationSegmentURL") { Attribute=SegmentInfo_Item->Attribute("sourceURL"); if (Attribute) Sequence->AddFileName(BaseURL+Ztring().From_UTF8(Attribute), 0); } //Url if (string(SegmentInfo_Item->Value())=="Url") { Attribute=SegmentInfo_Item->Attribute("sourceURL"); if (Attribute) Sequence->AddFileName(BaseURL+Ztring().From_UTF8(Attribute)); } } ReferenceFiles->AddSequence(Sequence); } } } } } } } else { Reject("DashMpd"); return false; } } Element_Offset=File_Size; //All should be OK... return true; } } //NameSpace #endif //MEDIAINFO_DASHMPD_YES MediaInfoLib/Source/MediaInfo/Multiple/File__ReferenceFilesHelper_Sequence_Common.h0000664000000000000000000000567012652076434027377 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef File__ReferenceFilesHelper_Sequence_CommonH #define File__ReferenceFilesHelper_Sequence_CommonH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Const.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { class rfh_common; //*************************************************************************** // Class resource //*************************************************************************** class rfhs_common { public: rfhs_common(stream_t* StreamKind_p, size_t* StreamPos_p, int64u* StreamID_p, int64u* DTS_p, bool* Enabled_p, bool* IsMain_p): Package(NULL), FileSize((int64u)-1), Edits((int64u)-1), DemuxRate(0), HasMultipleResources(false), StreamKind(StreamKind_p), StreamPos(StreamPos_p), StreamID(StreamID_p), DTS(DTS_p), Enabled(Enabled_p), IsMain(IsMain_p) { } //Data rfh_common* Package; int64u FileSize; int64u Edits; float64 DemuxRate; bool HasMultipleResources; const stream_t StreamKind_Get() {return *StreamKind;} void StreamKind_Set(stream_t StreamKind_n) {*StreamKind=StreamKind_n;} const size_t StreamPos_Get() {return *StreamPos;} void StreamPos_Set(size_t StreamPos_n) {*StreamPos=StreamPos_n;} const int64u StreamID_Get() {return *StreamID;} void StreamID_Set(int64u StreamID_n) {*StreamID=StreamID_n;} const int64u DTS_Get() {return *DTS;} void DTS_Set(int64u DTS_n) {*DTS=DTS_n;} const bool Enabled_Get() {return *Enabled;} const bool IsMain_Get() {return *IsMain;} private: stream_t* StreamKind; size_t* StreamPos; int64u* StreamID; int64u* DTS; bool* Enabled; bool* IsMain; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg4_TimeCode.h0000664000000000000000000000237212652076434022600 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #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 int8u NumberOfFrames; bool DropFrame; bool NegativeTimes; //Out int64s Pos; //Constructor/Destructor File_Mpeg4_TimeCode(); protected : //Streams management void Streams_Fill(); //Buffer - Global void Read_Buffer_Continue(); }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Mxf.cpp0000664000000000000000000305032212652076434021141 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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_SMPTEST0337_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_SMPTEST0331_YES) #include "MediaInfo/Audio/File_SmpteSt0331.h" #endif #if defined(MEDIAINFO_SMPTEST0337_YES) #include "MediaInfo/Audio/File_SmpteSt0337.h" #endif #if defined(MEDIAINFO_JPEG_YES) #include "MediaInfo/Image/File_Jpeg.h" #endif #if defined(MEDIAINFO_TTML_YES) #include "MediaInfo/Text/File_Ttml.h" #endif #include "MediaInfo/TimeCode.h" #include "MediaInfo/File_Unknown.h" #include "ZenLib/File.h" #include "ZenLib/FileName.h" #include "ZenLib/Dir.h" #include "MediaInfo/MediaInfo_Internal.h" #if defined(MEDIAINFO_REFERENCES_YES) #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" #endif //defined(MEDIAINFO_REFERENCES_YES) #include "ZenLib/Format/Http/Http_Utils.h" #include #include #if MEDIAINFO_SEEK #include #endif //MEDIAINFO_SEEK using namespace std; //--------------------------------------------------------------------------- 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(PART1, PART2, PART3, PART4, LOCAL, NORM, NAME, DESCRIPTION) \ 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 { // 01 - Identification and location // 01 - Globally Unique Identifiers // 15 - Object Identifiers UUID(060E2B34, 0101010C, 01011512, 00000000, 0000, "SMPTE ST 429-5", ResourceID, "Resource ID") // 02 - Globally Unique Locators // 01 - Uniform Resource Locators UUID(060E2B34, 0101010C, 01020105, 01000000, 0000, "SMPTE ST 429-5", NamespaceURI, "Namespace URI") // 03 - Locally Unique Identifiers // 04 - ? UUID(060E2B34, 0101010E, 0103040A, 00000000, 0000, "SMPTE ST 377-4", MCAChannelID, "MCA Channel ID") // 07 - ? // 01 - ? UUID(060E2B34, 0101010E, 01030701, 01000000, 0000, "SMPTE ST 377-4", MCALabelDictionaryID, "MCA Label Dictionary ID") UUID(060E2B34, 0101010E, 01030701, 02000000, 0000, "SMPTE ST 377-4", MCATagSymbol, "MCA Tag Symbol") UUID(060E2B34, 0101010E, 01030701, 03000000, 0000, "SMPTE ST 377-4", MCATagName, "MCA Tag Name") UUID(060E2B34, 0101010E, 01030701, 04000000, 0000, "SMPTE ST 377-4", GroupOfSoundfieldGroupsLinkID, "Group Of Soundfield Groups Link ID") UUID(060E2B34, 0101010E, 01030701, 05000000, 0000, "SMPTE ST 377-4", MCALinkID, "MCA Link ID") UUID(060E2B34, 0101010E, 01030701, 06000000, 0000, "SMPTE ST 377-4", SoundfieldGroupLinkID, "Soundfield Group Link ID") // 04 - Locally Unique Locators // 01 - ? // 01 - ? UUID(060E2B34, 0101010E, 01040105, 00000000, 0000, "SMPTE ST 377-4", MCAPartitionKind, "MCA Partition Kind") UUID(060E2B34, 0101010E, 01040106, 00000000, 0000, "SMPTE ST 377-4", MCAPartitionNumber, "MCA Partition Number") // 05 - Titles UUID(060E2B34, 0101010E, 01051000, 00000000, 0000, "SMPTE ST 377-4", MCATitle, "MCA Title") UUID(060E2B34, 0101010E, 01051100, 00000000, 0000, "SMPTE ST 377-4", MCATitleVersion, "MCA Title Version") UUID(060E2B34, 0101010E, 01051200, 00000000, 0000, "SMPTE ST 377-4", MCATitleSubVersion, "MCA Title Sub-version") UUID(060E2B34, 0101010E, 01051300, 00000000, 0000, "SMPTE ST 377-4", MCAEpisode, "MCA Episode") // 02 - Administrative // 03 - Interpretive // 01 - Fundamental // 01 - Countries and Languages // 01 - Country and Region Codes // 02 - Spoken Language Codes UUID(060E2B34, 01010107, 03010102, 03010000, 0000, "", PrimarySpokenLanguage, "") UUID(060E2B34, 01010107, 03010102, 03020000, 0000, "", SecondarySpokenLanguage, "") UUID(060E2B34, 01010107, 03010102, 03030000, 0000, "", OriginalSpokenLanguage, "") UUID(060E2B34, 01010107, 03010102, 03040000, 0000, "", SecondaryOriginalSpokenLanguage, "") UUID(060E2B34, 01010107, 03010102, 03110000, 0000, "SMPTE ST 380", PrimaryExtendedSpokenLanguage, "Primary Extended Spoken Language") UUID(060E2B34, 01010107, 03010102, 03120000, 0000, "SMPTE ST 380", SecondaryExtendedSpokenLanguage, "Secondary Extended Spoken Language") UUID(060E2B34, 01010107, 03010102, 03130000, 0000, "SMPTE ST 380", OriginalExtendedSpokenLanguage, "Original Extended Spoken Language") UUID(060E2B34, 01010107, 03010102, 03140000, 0000, "SMPTE ST 380", SecondaryOriginalExtendedSpokenLanguage, "Secondary Original Extended Spoken Language") UUID(060E2B34, 0101010D, 03010102, 03150000, 0000, "SMPTE ST 377-4", RFC5646AudioLanguageCode, "RFC 5646 Spoken Language") // 02 - Data Interpretations and Definitions // 0A - Name-Value Construct Interpretations UUID(060E2B34, 01010105, 0301020A, 01000000, 0000, "", Ansi_01, "") UUID(060E2B34, 01010105, 0301020A, 01010000, 0000, "", UTF16_01, "") UUID(060E2B34, 01010105, 0301020A, 02000000, 0000, "", Ansi_02, "") UUID(060E2B34, 01010105, 0301020A, 02010000, 0000, "", UTF16_02, "") // 10 - KLV Interpretations UUID(060E2B34, 01010101, 03010210, 01000000, 0000, "", Filler01, "") UUID(060E2B34, 01010102, 03010210, 01000000, 0000, "", Filler02, "") UUID(060E2B34, 01010102, 03010210, 05000000, 0000, "", TerminatingFiller, "") // 10 - XML Constructs and Interpretations UUID(060E2B34, 01010105, 03010220, 01000000, 0000, "", XmlDocumentText, "") // 02 - Human Assigned Descriptors // 01 - Categorization // 01 - Content Classification // 02 - Cataloging and Indexing UUID(060E2B34, 0101010E, 03020102, 20000000, 0000, "", MCAAudioContentKind, "") UUID(060E2B34, 0101010E, 03020102, 21000000, 0000, "", MCAAudioElementKind, "") // 04 - Parametric // 01 - Video and Image Essence Characteristics // 06 - Digital Video and Image Compression Parameters // 02 - MPEG Coding Parameters // 01 - MPEG-2 Coding Parameters UUID(060E2B34, 01010105, 04010602, 01020000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_SingleSequence, "") UUID(060E2B34, 01010105, 04010602, 01030000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_ConstantBFrames, "") UUID(060E2B34, 01010105, 04010602, 01040000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_CodedContentType, "") UUID(060E2B34, 01010105, 04010602, 01050000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_LowDelay, "") UUID(060E2B34, 01010105, 04010602, 01060000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_ClosedGOP, "") UUID(060E2B34, 01010105, 04010602, 01070000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_IdenticalGOP, "") UUID(060E2B34, 01010105, 04010602, 01080000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_MaxGOP, "") UUID(060E2B34, 01010105, 04010602, 01090000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_BPictureCount, "") UUID(060E2B34, 01010105, 04010602, 010A0000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_ProfileAndLevel, "") UUID(060E2B34, 01010105, 04010602, 010B0000, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor_BitRate, "") // 02 - MPEG-4 Visual Coding Parameters UUID(060E2B34, 01010105, 04010602, 02020000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_SingleSequence, "") UUID(060E2B34, 01010105, 04010602, 02030000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_ConstantBFrames, "") UUID(060E2B34, 01010105, 04010602, 02040000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_CodedContentType, "") UUID(060E2B34, 01010105, 04010602, 02050000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_LowDelay, "") UUID(060E2B34, 01010105, 04010602, 02060000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_ClosedGOP, "") UUID(060E2B34, 01010105, 04010602, 02070000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_IdenticalGOP, "") UUID(060E2B34, 01010105, 04010602, 02080000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_MaxGOP, "") UUID(060E2B34, 01010105, 04010602, 02090000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_BPictureCount, "") UUID(060E2B34, 01010105, 04010602, 020A0000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_ProfileAndLevel, "") UUID(060E2B34, 01010105, 04010602, 020B0000, 0000, "SMPTE ST 381-2", Mpeg4VisualDescriptor_BitRate, "") // 02 - JPEG 2000 Coding Parameters UUID(060E2B34, 0101010A, 04010603, 01000000, 0000, "", JPEG2000PictureSubDescriptor_Rsiz, "") UUID(060E2B34, 0101010A, 04010603, 02000000, 0000, "", JPEG2000PictureSubDescriptor_Xsiz, "") UUID(060E2B34, 0101010A, 04010603, 03000000, 0000, "", JPEG2000PictureSubDescriptor_Ysiz, "") UUID(060E2B34, 0101010A, 04010603, 04000000, 0000, "", JPEG2000PictureSubDescriptor_XOsiz, "") UUID(060E2B34, 0101010A, 04010603, 05000000, 0000, "", JPEG2000PictureSubDescriptor_YOsiz, "") UUID(060E2B34, 0101010A, 04010603, 06000000, 0000, "", JPEG2000PictureSubDescriptor_XTsiz, "") UUID(060E2B34, 0101010A, 04010603, 07000000, 0000, "", JPEG2000PictureSubDescriptor_YTsiz, "") UUID(060E2B34, 0101010A, 04010603, 08000000, 0000, "", JPEG2000PictureSubDescriptor_XTOsiz, "") UUID(060E2B34, 0101010A, 04010603, 09000000, 0000, "", JPEG2000PictureSubDescriptor_YTOsiz, "") UUID(060E2B34, 0101010A, 04010603, 0A000000, 0000, "", JPEG2000PictureSubDescriptor_Csiz, "") UUID(060E2B34, 0101010A, 04010603, 0B000000, 0000, "", JPEG2000PictureSubDescriptor_PictureComponentSizing, "") UUID(060E2B34, 0101010A, 04010603, 0C000000, 0000, "", JPEG2000PictureSubDescriptor_CodingStyleDefault, "") UUID(060E2B34, 0101010A, 04010603, 0D000000, 0000, "", JPEG2000PictureSubDescriptor_QuantizationDefault, "") // 02 - Audio Essence Characteristics // 04 - Audio Compression Parameters // 03 - MPEG Coding Parameters // 01 - MPEG-2 Coding Parameters UUID(060E2B34, 01010105, 04020403, 01020000, 0000, "SMPTE ST 381-2", MpegAudioDescriptor_BitRate, "") // 09 - Format Characteristics UUID(060E2B34, 0101010C, 04090500, 00000000, 0000, "SMPTE ST 429-5", UCSEncoding, "UCS Encoding") // 05 - Process // 06 - Relational // 01 - Essence and Metadata Relationships // 04 - Essence to Essence Relationships UUID(060E2B34, 01010109, 06010104, 06100000, 0000, "", SubDescriptors, "") // 07 - Spatio-temporal // 0C - Compound // 02 - Metadata sets created at point of creation or capture // 01 - Metadata sets associated with a video camera // 01 - Frame-based metadata set UUID(060E2B34, 02530101, 0C020101, 01010000, 0000, "SMPTE RDD 18", LensUnitMetadata, "") UUID(060E2B34, 02530101, 0C020101, 02010000, 0000, "SMPTE RDD 18", CameraUnitMetadata, "") UUID(060E2B34, 02530101, 0C020101, 7F010000, 0000, "SMPTE RDD 18", UserDefinedAcquisitionMetadata, "") // 0D - Organizationally registered for public use // 01 - AAF Association // 01 - MXF Structural Metadata Sets // 01 - Version 1 // 01 - MXF compatible sets and packs UUID(060E2B34, 02530101, 0D010101, 01010100, 0000, "SMPTE ST 377-1", InterchangeObject, "Interchange Object") UUID(060E2B34, 02530101, 0D010101, 01010200, 0000, "SMPTE ST 377-1", StructuralComponent, "Structural Component") UUID(060E2B34, 02530101, 0D010101, 01010300, 0000, "SMPTE ST 377-1", Segment, "Segment") UUID(060E2B34, 02530101, 0D010101, 01010600, 0000, "SMPTE ST 377-1", Event, "Event") UUID(060E2B34, 02530101, 0D010101, 01010800, 0000, "SMPTE ST 377-1", CommentMarker, "Comment Marker") UUID(060E2B34, 02530101, 0D010101, 01010900, 0000, "SMPTE ST 377-1", DMFiller, "") UUID(060E2B34, 02530101, 0D010101, 01010F00, 0000, "SMPTE ST 377-1", Sequence, "") UUID(060E2B34, 02530101, 0D010101, 01011100, 0000, "SMPTE ST 377-1", SourceClip, "") UUID(060E2B34, 02530101, 0D010101, 01011400, 0000, "SMPTE ST 377-1", TimecodeComponent, "") UUID(060E2B34, 02530101, 0D010101, 01011800, 0000, "SMPTE ST 377-1", ContentStorage, "") UUID(060E2B34, 02530101, 0D010101, 01012300, 0000, "SMPTE ST 377-1", EssenceContainerData, "") UUID(060E2B34, 02530101, 0D010101, 01012400, 0000, "SMPTE ST 377-1", GenericDescriptor, "Generic Descriptor") UUID(060E2B34, 02530101, 0D010101, 01012500, 0000, "SMPTE ST 377-1", FileDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01012700, 0000, "SMPTE ST 377-1", GenericPictureEssenceDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01012800, 0000, "SMPTE ST 377-1", CDCIEssenceDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01012900, 0000, "SMPTE ST 377-1", RGBAEssenceDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01012F00, 0000, "SMPTE ST 377-1", Preface, "") UUID(060E2B34, 02530101, 0D010101, 01013000, 0000, "SMPTE ST 377-1", Identification, "") UUID(060E2B34, 02530101, 0D010101, 01013200, 0000, "SMPTE ST 377-1", NetworkLocator, "") UUID(060E2B34, 02530101, 0D010101, 01013300, 0000, "SMPTE ST 377-1", TextLocator, "") UUID(060E2B34, 02530101, 0D010101, 01013400, 0000, "SMPTE ST 377-1", GenericPackage, "Generic Package") UUID(060E2B34, 02530101, 0D010101, 01013600, 0000, "SMPTE ST 377-1", MaterialPackage, "") UUID(060E2B34, 02530101, 0D010101, 01013700, 0000, "SMPTE ST 377-1", SourcePackage, "") UUID(060E2B34, 02530101, 0D010101, 01013800, 0000, "SMPTE ST 377-1", GenericTrack , "Generic Track") UUID(060E2B34, 02530101, 0D010101, 01013900, 0000, "SMPTE ST 377-1", EventTrack, "") UUID(060E2B34, 02530101, 0D010101, 01013A00, 0000, "SMPTE ST 377-1", StaticTrack, "") UUID(060E2B34, 02530101, 0D010101, 01013B00, 0000, "SMPTE ST 377-1", TimelineTrack, "") UUID(060E2B34, 02530101, 0D010101, 01014100, 0000, "SMPTE ST 377-1", DMSegment, "") UUID(060E2B34, 02530101, 0D010101, 01014200, 0000, "SMPTE ST 377-1", GenericSoundEssenceDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01014300, 0000, "SMPTE ST 377-1", GenericDataEssenceDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01014400, 0000, "SMPTE ST 377-1", MultipleDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01014500, 0000, "SMPTE ST 377-1", DMSourceClip, "") UUID(060E2B34, 02530101, 0D010101, 01014700, 0000, "", AES3PCMDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01014800, 0000, "", WaveAudioDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01015100, 0000, "SMPTE ST 381-1", MPEG2VideoDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01015900, 0000, "SMPTE ST 377-1", SubDescriptor, "Sub Descriptor") UUID(060E2B34, 02530101, 0D010101, 01015A00, 0000, "", JPEG2000PictureSubDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01015B00, 0000, "", VbiPacketsDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01015C00, 0000, "", AncPacketsDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01015E00, 0000, "SMPTE ST 381-2", MpegAudioDescriptor, "MPEG Audio Descriptor") UUID(060E2B34, 02530101, 0D010101, 01016000, 0000, "SMPTE ST 377-1", PackageMarkerObject, "") UUID(060E2B34, 02530101, 0D010101, 01016100, 0000, "SMPTE ST 377-1", ApplicationPlugInObject, "") UUID(060E2B34, 02530101, 0D010101, 01016200, 0000, "SMPTE ST 377-1", ApplicationReferencedObject, "") UUID(060E2B34, 0253010C, 0D010101, 01016300, 0000, "SMPTE ST 429-10", StereoscopicPictureSubDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01016400, 0000, "SMPTE ST 429-5", TimedTextDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01016500, 0000, "SMPTE ST 429-5", TimedTextResourceSubDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01016600, 0000, "SMPTE ST 377-1", ApplicationObject, "Application Object") UUID(060E2B34, 02530101, 0D010101, 01016700, 0000, "SMPTE ST ?", Unknown67SubDescriptor, "Unknown 0x67 Sub-Descriptor") UUID(060E2B34, 02530101, 0D010101, 01016800, 0000, "SMPTE ST 381-2", Mpeg4VisualSubDescriptor, "MPEG-4 Visual Sub-Descriptor") UUID(060E2B34, 02530101, 0D010101, 01016A00, 0000, "SMPTE ST 377-4", MCALabelSubDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01016B00, 0000, "SMPTE ST 377-4", AudioChannelLabelSubDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01016C00, 0000, "SMPTE ST 377-4", SoundfieldGroupLabelSubDescriptor, "") UUID(060E2B34, 02530101, 0D010101, 01016D00, 0000, "SMPTE ST 377-4", GroupOfSoundfieldGroupsLabelSubDescriptor, "") // 02 - MXF File Structure // 01 - Version 1 // 01 - MXF File Structure sets & packs UUID(060E2B34, 02050101, 0D010201, 01020100, 0000, "SMPTE ST 377-1", OpenIncompleteHeaderPartition, "") UUID(060E2B34, 02050101, 0D010201, 01020200, 0000, "SMPTE ST 377-1", ClosedIncompleteHeaderPartition, "") UUID(060E2B34, 02050101, 0D010201, 01020300, 0000, "SMPTE ST 377-1", OpenCompleteHeaderPartition, "") UUID(060E2B34, 02050101, 0D010201, 01020400, 0000, "SMPTE ST 377-1", ClosedCompleteHeaderPartition, "") UUID(060E2B34, 02050101, 0D010201, 01030100, 0000, "SMPTE ST 377-1", OpenIncompleteBodyPartition, "") UUID(060E2B34, 02050101, 0D010201, 01030200, 0000, "SMPTE ST 377-1", ClosedIncompleteBodyPartition, "") UUID(060E2B34, 02050101, 0D010201, 01030300, 0000, "SMPTE ST 377-1", OpenCompleteBodyPartition, "") UUID(060E2B34, 02050101, 0D010201, 01030400, 0000, "SMPTE ST 377-1", ClosedCompleteBodyPartition, "") UUID(060E2B34, 02050101, 0D010201, 01040100, 0000, "SMPTE ST 377-1", OpenIncompleteFooterPartition, "") UUID(060E2B34, 02050101, 0D010201, 01040200, 0000, "SMPTE ST 377-1", ClosedIncompleteFooterPartition, "") UUID(060E2B34, 02050101, 0D010201, 01040300, 0000, "SMPTE ST 377-1", OpenCompleteFooterPartition, "") UUID(060E2B34, 02050101, 0D010201, 01040400, 0000, "SMPTE ST 377-1", ClosedCompleteFooterPartition, "") UUID(060E2B34, 02050101, 0D010201, 01050100, 0000, "SMPTE ST 377-1", Primer, "") UUID(060E2B34, 02530101, 0D010201, 01100100, 0000, "SMPTE ST 377-1", IndexTableSegment, "") UUID(060E2B34, 02050101, 0D010201, 01110100, 0000, "SMPTE ST 377-1", RandomIndexMetadata, "") // 03 - ? // 01 - ? // 00 - Generic UUID(060E2B34, 01020101, 0D010301, 00000000, 0000, "", GenericContainer_Aaf, "") // 04 - SDTI UUID(060E2B34, 02050101, 0D010301, 04010100, 0000, "", SDTI_SystemMetadataPack, "") UUID(060E2B34, 02430101, 0D010301, 04010200, 0000, "", SDTI_PackageMetadataSet, "") UUID(060E2B34, 02430101, 0D010301, 04010300, 0000, "", SDTI_PictureMetadataSet, "") UUID(060E2B34, 02430101, 0D010301, 04010400, 0000, "", SDTI_SoundMetadataSet, "") UUID(060E2B34, 02430101, 0D010301, 04010500, 0000, "", SDTI_DataMetadataSet, "") UUID(060E2B34, 02630101, 0D010301, 04010600, 0000, "", SDTI_ControlMetadataSet, "") // 14 - System Scheme 1 UUID(060E2B34, 02530101, 0D010301, 14020000, 0000, "", SystemScheme1, "") // 04 - ? // 01 - ? UUID(060E2B34, 02530101, 0D010401, 01010100, 0000, "", DMScheme1, "") // 07 - AMWA AS-11 // 01 - ? // 0B - ? // 01 - AS-11 core metadata framework UUID(060E2B34, 02530101, 0D010701, 0B010100, 0000, "AMWA AS-11", AS11_AAF_Core, "") UUID(060E2B34, 01010101, 0D010701, 0B010101, 0000, "AMWA AS-11", AS11_Core_SeriesTitle, "") UUID(060E2B34, 01010101, 0D010701, 0B010102, 0000, "AMWA AS-11", AS11_Core_ProgrammeTitle, "") UUID(060E2B34, 01010101, 0D010701, 0B010103, 0000, "AMWA AS-11", AS11_Core_EpisodeTitleNumber, "") UUID(060E2B34, 01010101, 0D010701, 0B010104, 0000, "AMWA AS-11", AS11_Core_ShimName, "") UUID(060E2B34, 01010101, 0D010701, 0B010105, 0000, "AMWA AS-11", AS11_Core_AudioTrackLayout, "") UUID(060E2B34, 01010101, 0D010701, 0B010106, 0000, "AMWA AS-11", AS11_Core_PrimaryAudioLanguage, "") UUID(060E2B34, 01010101, 0D010701, 0B010107, 0000, "AMWA AS-11", AS11_Core_ClosedCaptionsPresent, "") UUID(060E2B34, 01010101, 0D010701, 0B010108, 0000, "AMWA AS-11", AS11_Core_ClosedCaptionsType, "") UUID(060E2B34, 01010101, 0D010701, 0B010109, 0000, "AMWA AS-11", AS11_Core_ClosedCaptionsLanguage, "") UUID(060E2B34, 01010101, 0D010701, 0B01010A, 0000, "AMWA AS-11", AS11_Core_ShimVersion, "") // 02 - AS-11 segmentation metadata framework UUID(060E2B34, 02530101, 0D010701, 0B020100, 0000, "AMWA AS-11", AS11_AAF_Segmentation, "") UUID(060E2B34, 01010101, 0D010701, 0B020101, 0000, "AMWA AS-11", AS11_Segment_PartNumber, "") UUID(060E2B34, 01010101, 0D010701, 0B020102, 0000, "AMWA AS-11", AS11_Segment_PartTotal, "") // 0C - BBC // 01 - ? // 01 - ? // 01 - ? // 01 - AS-11 UK DPP metadata framework UUID(060E2B34, 02530101, 0D0C0101, 01010000, 0000, "AMWA AS-11", AS11_AAF_UKDPP, "") UUID(060E2B34, 01010101, 0D0C0101, 01010100, 0000, "AMWA AS-11", AS11_UKDPP_ProductionNumber, "") UUID(060E2B34, 01010101, 0D0C0101, 01010200, 0000, "AMWA AS-11", AS11_UKDPP_Synopsis, "") UUID(060E2B34, 01010101, 0D0C0101, 01010300, 0000, "AMWA AS-11", AS11_UKDPP_Originator, "") UUID(060E2B34, 01010101, 0D0C0101, 01010400, 0000, "AMWA AS-11", AS11_UKDPP_CopyrightYear, "") UUID(060E2B34, 01010101, 0D0C0101, 01010500, 0000, "AMWA AS-11", AS11_UKDPP_OtherIdentifier, "") UUID(060E2B34, 01010101, 0D0C0101, 01010600, 0000, "AMWA AS-11", AS11_UKDPP_OtherIdentifierType, "") UUID(060E2B34, 01010101, 0D0C0101, 01010700, 0000, "AMWA AS-11", AS11_UKDPP_Genre, "") UUID(060E2B34, 01010101, 0D0C0101, 01010800, 0000, "AMWA AS-11", AS11_UKDPP_Distributor, "") UUID(060E2B34, 01010101, 0D0C0101, 01010900, 0000, "AMWA AS-11", AS11_UKDPP_PictureRatio, "") UUID(060E2B34, 01010101, 0D0C0101, 01010A00, 0000, "AMWA AS-11", AS11_UKDPP_3D, "") UUID(060E2B34, 01010101, 0D0C0101, 01010B00, 0000, "AMWA AS-11", AS11_UKDPP_3DType, "") UUID(060E2B34, 01010101, 0D0C0101, 01010C00, 0000, "AMWA AS-11", AS11_UKDPP_ProductPlacement, "") UUID(060E2B34, 01010101, 0D0C0101, 01010D00, 0000, "AMWA AS-11", AS11_UKDPP_FpaPass, "") UUID(060E2B34, 01010101, 0D0C0101, 01010E00, 0000, "AMWA AS-11", AS11_UKDPP_FpaManufacturer, "") UUID(060E2B34, 01010101, 0D0C0101, 01010F00, 0000, "AMWA AS-11", AS11_UKDPP_FpaVersion, "") UUID(060E2B34, 01010101, 0D0C0101, 01011000, 0000, "AMWA AS-11", AS11_UKDPP_VideoComments, "") UUID(060E2B34, 01010101, 0D0C0101, 01011100, 0000, "AMWA AS-11", AS11_UKDPP_SecondaryAudioLanguage, "") UUID(060E2B34, 01010101, 0D0C0101, 01011200, 0000, "AMWA AS-11", AS11_UKDPP_TertiaryAudioLanguage, "") UUID(060E2B34, 01010101, 0D0C0101, 01011300, 0000, "AMWA AS-11", AS11_UKDPP_AudioLoudnessStandard, "") UUID(060E2B34, 01010101, 0D0C0101, 01011400, 0000, "AMWA AS-11", AS11_UKDPP_AudioComments, "") UUID(060E2B34, 01010101, 0D0C0101, 01011500, 0000, "AMWA AS-11", AS11_UKDPP_LineUpStart, "") UUID(060E2B34, 01010101, 0D0C0101, 01011600, 0000, "AMWA AS-11", AS11_UKDPP_IdentClockStart, "") UUID(060E2B34, 01010101, 0D0C0101, 01011700, 0000, "AMWA AS-11", AS11_UKDPP_TotalNumberOfParts, "") UUID(060E2B34, 01010101, 0D0C0101, 01011800, 0000, "AMWA AS-11", AS11_UKDPP_TotalProgrammeDuration, "") UUID(060E2B34, 01010101, 0D0C0101, 01011900, 0000, "AMWA AS-11", AS11_UKDPP_AudioDescriptionPresent, "") UUID(060E2B34, 01010101, 0D0C0101, 01011A00, 0000, "AMWA AS-11", AS11_UKDPP_AudioDescriptionType, "") UUID(060E2B34, 01010101, 0D0C0101, 01011B00, 0000, "AMWA AS-11", AS11_UKDPP_OpenCaptionsPresent, "") UUID(060E2B34, 01010101, 0D0C0101, 01011C00, 0000, "AMWA AS-11", AS11_UKDPP_OpenCaptionsType, "") UUID(060E2B34, 01010101, 0D0C0101, 01011D00, 0000, "AMWA AS-11", AS11_UKDPP_OpenCaptionsLanguage, "") UUID(060E2B34, 01010101, 0D0C0101, 01011E00, 0000, "AMWA AS-11", AS11_UKDPP_SigningPresent, "") UUID(060E2B34, 01010101, 0D0C0101, 01011F00, 0000, "AMWA AS-11", AS11_UKDPP_SignLanguage, "") UUID(060E2B34, 01010101, 0D0C0101, 01012000, 0000, "AMWA AS-11", AS11_UKDPP_CompletionDate, "") UUID(060E2B34, 01010101, 0D0C0101, 01012100, 0000, "AMWA AS-11", AS11_UKDPP_TextlessElementsExist, "") UUID(060E2B34, 01010101, 0D0C0101, 01012200, 0000, "AMWA AS-11", AS11_UKDPP_ProgrammeHasText, "") UUID(060E2B34, 01010101, 0D0C0101, 01012300, 0000, "AMWA AS-11", AS11_UKDPP_ProgrammeTextLanguage, "") UUID(060E2B34, 01010101, 0D0C0101, 01012400, 0000, "AMWA AS-11", AS11_UKDPP_ContactEmail, "") UUID(060E2B34, 01010101, 0D0C0101, 01012500, 0000, "AMWA AS-11", AS11_UKDPP_ContactTelephoneNumber, "") // 0E - Organizationally registered for private use // 04 - Avid UUID(060E2B34, 01020101, 0E040301, 00000000, 0000, "", GenericContainer_Avid, "") // 06 - Sony UUID(060E2B34, 01020101, 0E067F03, 00000000, 0000, "", GenericContainer_Sony, "") // 0B - Omneon Video Networks UUID(060E2B34, 02530105, 0E0B0102, 01010100, 0000, "", Omneon_010201010100, "") UUID(060E2B34, 02530105, 0E0B0102, 01020100, 0000, "", Omneon_010201020100, "") } //--------------------------------------------------------------------------- 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(const 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(const int128u EssenceElement) { if ((EssenceElement.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3401020100LL) return ""; int8u Code1=(int8u)((EssenceElement.lo&0xFF00000000000000LL)>>56); int8u Code2=(int8u)((EssenceElement.lo&0x00FF000000000000LL)>>48); int8u Code5=(int8u)((EssenceElement.lo&0x00000000FF000000LL)>>24); int8u Code7=(int8u)((EssenceElement.lo&0x000000000000FF00LL)>> 8); switch (Code1) { case 0x0E : //Private switch (Code2) { case 0x06 : //Sony case 0x15 : //GC Picture switch (Code5) { case 0x15 : return "Sony private picture stream"; default : return "Sony private stream"; } default : return "Unknown private stream"; } default : ; } switch (Code5) { case 0x05 : //CP Picture (SMPTE 386M) switch (Code7) { case 0x01 : return "D-10 Video"; default : return "Unknown stream"; } case 0x06 : //CP Sound (SMPTE 386M) switch (Code7) { case 0x10 : return "D-10 Audio"; default : return "Unknown stream"; } case 0x07 : //CP Data (SMPTE 386M) 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 0x01 : return "VBI"; //Frame-Wrapped VBI Data Element case 0x02 : return "ANC"; //Frame-Wrapped ANC Data Element case 0x0B : return "Timed Text"; //Clip-Wrapped Timed Text Data Element, SMPTE ST 429-5 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(const 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"; // Video and 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 0x10 : return "AVC"; case 0x11 : return "VC-3"; case 0x13 : return "Timed Text"; 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 ""; } case 0x06 : //Sony switch (Code3) { case 0x0D : switch (Code4) { case 0x03 : switch (Code5) { case 0x02 : switch (Code6) { case 0x01 : switch (Code7) { case 0x01 : return "Sony RAW?"; default : return ""; } 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 ""; } case 0x13 : //Timed Text return "Clip"; default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_EssenceCompression(const 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 0x00 : return "MPEG Video"; 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 0x30 : case 0x31 : case 0x32 : case 0x33 : case 0x34 : case 0x35 : case 0x36 : case 0x37 : case 0x38 : case 0x39 : case 0x3A : case 0x3B : case 0x3C : case 0x3D : case 0x3E : case 0x3F : 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"; // TODO: Undefined 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 ""; } case 0x06 : //Sony switch (Code3) { case 0x04 : switch (Code4) { case 0x01 : switch (Code5) { case 0x02 : switch (Code6) { case 0x04 : switch (Code7) { case 0x02 : return "Sony RAW SQ"; default : return ""; } default : return ""; } default : return ""; } default : return ""; } default : return ""; } default : return ""; } default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_EssenceCompression_Version(const 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(const int128u DataDefinition) { int8u Code4=(int8u)((DataDefinition.lo&0x000000FF00000000LL)>>32); int8u Code5=(int8u)((DataDefinition.lo&0x00000000FF000000LL)>>24); switch (Code4) { case 0x01 : switch (Code5) { case 0x01 : case 0x02 : case 0x03 : return "Time"; case 0x10 : return "Descriptive Metadata"; default : return ""; } 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; } } //--------------------------------------------------------------------------- const char* Mxf_ColorPrimaries(const int128u ColorPrimaries) { int32u Code_Compare4=(int32u)ColorPrimaries.lo; switch ((int8u)(Code_Compare4>>16)) { case 0x01 : return "BT.601 NTSC"; case 0x02 : return "BT.470 System B"; case 0x03 : return "BT.709"; default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_TransferCharacteristic(const int128u TransferCharacteristic) { int32u Code_Compare4=(int32u)TransferCharacteristic.lo; switch ((int8u)(Code_Compare4>>16)) { case 0x01 : return "BT.470"; case 0x02 : return "BT.709"; case 0x03 : return "SMPTE 240M"; case 0x04 : return "SMPTE 274M"; case 0x05 : return "BT.1361 extended colour gamut system"; case 0x06 : return "Linear"; case 0x07 : return "SMPTE 428M"; default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_CodingEquations(const int128u CodingEquations) { int32u Code_Compare4=(int32u)CodingEquations.lo; switch ((int8u)(Code_Compare4>>16)) { case 0x01 : return "BT.601"; case 0x02 : return "BT.709"; case 0x03 : return "SMPTE 240M"; default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_ChannelAssignment_ChannelPositions(const int128u ChannelLayout, int32u ChannelsCount) { //Sound Channel Labeling if ((ChannelLayout.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3404010100LL && (ChannelLayout.lo&0xFFFFFFFF00000000LL)!=0x0402021000000000LL) return ""; int8u Code5=(int8u)((ChannelLayout.lo&0x00000000FF000000LL)>>24); int8u Code6=(int8u)((ChannelLayout.lo&0x0000000000FF0000LL)>>16); int8u Code7=(int8u)((ChannelLayout.lo&0x000000000000FF00LL)>> 8); switch (Code5) { case 0x03 : //SMPTE 429-2 switch (Code6) { case 0x01 : //Sets switch (Code7) { case 0x01 : //Config 1 switch (ChannelsCount) { case 6 : return "Front: L C R, Side: L R, LFE"; default : return "Front: L C R, Side: L R, LFE, HI, VI-N"; } case 0x02 : //Config 2 switch (ChannelsCount) { case 6 : return "Front: L C R, Side: L R, LFE"; case 8 : return "Front: L C R, Side: L R, Back: C, LFE"; default : return "Front: L C R, Side: L R, Back: C, LFE, HI, VI-N"; } case 0x03 : //Config 3 switch (ChannelsCount) { case 6 : return "Front: L C R, Side: L R, LFE"; case 8 : return "Front: L C R, Side: L R, Back: L R, LFE"; default : return "Front: L C R, Side: L R, Back: L R, LFE, HI, VI-N"; } default : return ""; } default : return ""; } default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_ChannelAssignment_ChannelPositions2(const int128u ChannelLayout, int32u ChannelsCount=(int32u)-1) { //Sound Channel Labeling if ((ChannelLayout.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3404010100LL && (ChannelLayout.lo&0xFFFFFFFF00000000LL)!=0x0402021000000000LL) return ""; int8u Code5=(int8u)((ChannelLayout.lo&0x00000000FF000000LL)>>24); int8u Code6=(int8u)((ChannelLayout.lo&0x0000000000FF0000LL)>>16); int8u Code7=(int8u)((ChannelLayout.lo&0x000000000000FF00LL)>> 8); switch (Code5) { case 0x03 : //SMPTE 429-2 switch (Code6) { case 0x01 : //Sets switch (Code7) { case 0x01 : //Config 1 switch (ChannelsCount) { case 6 : return "3/2/0.1"; default : return "3/2/0.1+2"; } case 0x02 : //Config 2 switch (ChannelsCount) { case 6 : return "3/2/0.1"; case 8 : return "3/2/1.1"; default : return "3/2/1.1+2"; } case 0x03 : //Config 3 switch (ChannelsCount) { case 6 : return "3/2/0.1"; case 8 : return "3/2/2.1"; default : return "3/2/2.1+2"; } default : return ""; } default : return ""; } default : return ""; } } //--------------------------------------------------------------------------- const char* Mxf_ChannelAssignment_ChannelLayout(const int128u ChannelLayout, int32u ChannelsCount=(int32u)-1) { //Sound Channel Labeling if ((ChannelLayout.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3404010100LL && (ChannelLayout.lo&0xFFFFFFFF00000000LL)!=0x0402021000000000LL) return ""; int8u Code5=(int8u)((ChannelLayout.lo&0x00000000FF000000LL)>>24); int8u Code6=(int8u)((ChannelLayout.lo&0x0000000000FF0000LL)>>16); int8u Code7=(int8u)((ChannelLayout.lo&0x000000000000FF00LL)>> 8); switch (Code5) { case 0x03 : //SMPTE 429-2 switch (Code6) { case 0x01 : //Sets switch (Code7) { case 0x01 : //Config 1 switch (ChannelsCount) { case 6 : return "L R C LFE Ls Rs"; default : return "L R C LFE Ls Rs HI VI-N"; } case 0x02 : //Config 2 switch (ChannelsCount) { case 6 : return "L R C LFE Ls Rs"; case 8 : return "L R C LFE Ls Rs Cs X"; default : return "L R C LFE Ls Rs Cs X HI VI-N"; } case 0x03 : //Config 3 switch (ChannelsCount) { case 6 : return "L R C LFE Ls Rs"; case 8 : return "L R C LFE Ls Rs Rls Rrs"; default : return "L R C LFE Ls Rs Rls Rrs HI VI-N"; } default : return ""; } default : return ""; } default : return ""; } } const char* Mxf_ChannelAssignment_ChannelLayout(const int128u ChannelLayout) { return Mxf_ChannelAssignment_ChannelLayout(ChannelLayout, (int32u)-1); } string MXF_MCALabelDictionaryID_ChannelPositions(const std::vector &MCALabelDictionaryIDs) { string ToReturn; bitset<8> Front, Side, Back, Lfe; bool IsOk=true; for (size_t Pos=0; Pos>48)&0xFF) { case 0x01 : switch ((MCALabelDictionaryIDs[Pos].lo>>40)&0xFF) { case 0x01 : switch ((MCALabelDictionaryIDs[Pos].lo>>32)&0xFF) { case 0x01 : Front[0]=true; break; //L case 0x02 : Front[1]=true; break; //R case 0x03 : Front[2]=true; break; //C case 0x04 : Lfe[0]=true; break; //LFE case 0x05 : Side[0]=true; break; //Ls case 0x06 : Side[1]=true; break; //Rs case 0x20 : Front[6]=true; break; //M1 //TODO: split M1 and M2 in 2 services case 0x21 : Front[7]=true; break; //M2 //TODO: split M1 and M2 in 2 services case 0x22 : Front[4]=true; break; //Lt case 0x23 : Front[5]=true; break; //Rt default : IsOk=false; } break; default : IsOk=false; } break; case 0x02 : switch ((MCALabelDictionaryIDs[Pos].lo>>40)&0xFF) { case 0x01 : switch ((MCALabelDictionaryIDs[Pos].lo>>32)&0xFF) { case 0x01 : Front[0]=true; break; //L case 0x02 : Front[1]=true; break; //R case 0x03 : Front[2]=true; break; //C case 0x04 : Lfe[0]=true; break; //LFE case 0x05 : Side[0]=true; break; //Ls case 0x06 : Side[1]=true; break; //Rs case 0x20 : switch ((MCALabelDictionaryIDs[Pos].lo>>24)&0xFF) { case 0x03 : Front[4]=true; break; //Lt case 0x04 : Front[5]=true; break; //Rt default : IsOk=false; } break; default : IsOk=false; } break; default : IsOk=false; } break; default : IsOk=false; } } else IsOk=false; } if (IsOk) { string FrontS, SideS, BackS, LfeS; if (Front.any()) { FrontS+="Front: "; if (Front[0]) FrontS+="L "; if (Front[2]) FrontS+="C "; if (Front[1]) FrontS+="R "; if (Front[4]) FrontS+="Lt "; if (Front[5]) FrontS+="Rt "; if (Front[6]) FrontS+="M1 "; if (Front[7]) FrontS+="M2 "; FrontS.resize(FrontS.size()-1); } if (Side.any()) { SideS+="Side: "; if (Side[0]) SideS+="L "; if (Side[1]) SideS+="R "; SideS.resize(SideS.size()-1); } if (Back.any()) { BackS+="Back: "; if (Back[0]) BackS+="L "; if (Back[2]) BackS+="C "; if (Back[1]) BackS+="R "; BackS.resize(BackS.size()-1); } if (Lfe.any()) { if (Lfe[0]) LfeS+="LFE"; } if (!FrontS.empty()) ToReturn+=FrontS.c_str(); if (!SideS.empty()) { if (!ToReturn.empty()) ToReturn+=", "; ToReturn+=SideS.c_str(); } if (!BackS.empty()) { if (!ToReturn.empty()) ToReturn+=", "; ToReturn+=BackS.c_str(); } if (!LfeS.empty()) { if (!ToReturn.empty()) ToReturn+=", "; ToReturn+=LfeS.c_str(); } } return ToReturn; } string MXF_MCALabelDictionaryID_ChannelLayout(const std::vector &MCALabelDictionaryIDs) { string ToReturn; for (size_t Pos=0; Pos>48)&0xFF) { case 0x01 : switch ((MCALabelDictionaryIDs[Pos].lo>>40)&0xFF) { case 0x01 : switch ((MCALabelDictionaryIDs[Pos].lo>>32)&0xFF) { case 0x01 : Value="L"; break; case 0x02 : Value="R"; break; case 0x03 : Value="C"; break; case 0x04 : Value="LFE"; break; case 0x05 : Value="Ls"; break; case 0x06 : Value="Rs"; break; case 0x20 : Value="M1"; break; case 0x21 : Value="M2"; break; case 0x22 : Value="Lt"; break; case 0x23 : Value="Rt"; break; default : Value=""; } break; default : Value=""; } break; case 0x02 : switch ((MCALabelDictionaryIDs[Pos].lo>>40)&0xFF) { case 0x01 : switch ((MCALabelDictionaryIDs[Pos].lo>>32)&0xFF) { case 0x01 : Value="L"; break; case 0x02 : Value="R"; break; case 0x03 : Value="C"; break; case 0x04 : Value="LFE"; break; case 0x05 : Value="Ls"; break; case 0x06 : Value="Rs"; break; case 0x20 : switch ((MCALabelDictionaryIDs[Pos].lo>>24)&0xFF) { case 0x03 : Value="Lt"; break; case 0x04 : Value="Rt"; break; default : Value=""; } break; case 0x22 : Value="Lt"; break; case 0x23 : Value="Rt"; break; default : Value=""; } break; default : Value=""; } break; default : Value=""; } } if (!ToReturn.empty()) ToReturn+=' '; if (strlen(Value)) ToReturn+=Value; else { Ztring Value; Value.From_Number(MCALabelDictionaryIDs[Pos].lo>>32, 16); if (Value.size()<8) Value.insert(0, 8-Value.size(), __T('0')); ToReturn+=Value.To_UTF8(); } } return ToReturn; } //--------------------------------------------------------------------------- const size_t Mxf_AS11_ClosedCaptionType_Count=2; const char* Mxf_AS11_ClosedCaptionType[Mxf_AS11_ClosedCaptionType_Count]= { "Hard of Hearing", "Translation", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_AudioTrackLayout_Count=0x35; const char* Mxf_AS11_AudioTrackLayout[Mxf_AS11_AudioTrackLayout_Count]= { "EBU R 48: 1a", "EBU R 48: 1b", "EBU R 48: 1c", "EBU R 48: 2a", "EBU R 48: 2b", "EBU R 48: 2c", "EBU R 48: 3a", "EBU R 48: 3b", "EBU R 48: 4a", "EBU R 48: 4b", "EBU R 48: 4c", "EBU R 48: 5a", "EBU R 48: 5b", "EBU R 48: 6a", "EBU R 48: 6b", "EBU R 48: 7a", "EBU R 48: 7b", "EBU R 48: 8a", "EBU R 48: 8b", "EBU R 48: 8c", "EBU R 48: 9a", "EBU R 48: 9b", "EBU R 48: 10a", "EBU R 48: 11a", "EBU R 48: 11b", "EBU R 48: 11c", "EBU R 123: 2a", "EBU R 123: 4a", "EBU R 123: 4b", "EBU R 123: 4c", "EBU R 123: 8a", "EBU R 123: 8b", "EBU R 123: 8c", "EBU R 123: 8d", "EBU R 123: 8e", "EBU R 123: 8f", "EBU R 123: 8g", "EBU R 123: 8h", "EBU R 123: 8i", "EBU R 123: 12a", "EBU R 123: 12b", "EBU R 123: 12c", "EBU R 123: 12d", "EBU R 123: 12e", "EBU R 123: 12f", "EBU R 123: 12g", "EBU R 123: 12h", "EBU R 123: 16a", "EBU R 123: 16b", "EBU R 123: 16c", "EBU R 123: 16d", "EBU R 123: 16e", "EBU R 123: 16f", }; struct mxf_as11_audiotracklayout_assignment { size_t Count; const char* Assign[16]; }; const mxf_as11_audiotracklayout_assignment Mxf_AS11_AudioTrackLayout_ChannelPositions[Mxf_AS11_AudioTrackLayout_Count]= { { 2, "Front: C", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 1a { 4, "Front: C", NULL, "Front: C", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 1b { 8, "Front: C", NULL, "Front: C", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 1c { 2, "Front: L", "Front: R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 2a { 4, "Front: L", "Front: R", "Front: L", "Front: R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 2b { 8, "Front: L", "Front: R", "Front: L", "Front: R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 2c { 4, "Front: L", "Front: R", "Front: L", "Front: R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 3a { 8, "Front: L", "Front: R", "Front: L", "Front: R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 3b { 2, "EBU R 48: 4a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 4b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 4c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 5a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 5b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 6a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 6b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 7a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 7b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 2, "EBU R 48: 8a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 8b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 8c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 9a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 9b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 2, "EBU R 48: 10a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 11a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 11b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 11c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 2, "EBU R 123: 2a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 123: 4a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 123: 4b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 123: 4c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8d", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8e", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8f", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8g", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8h", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8i", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12d", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12e", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12f", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12g", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12h", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 16, "Front: L", "Front: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Front: L", "Front: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", }, //123 16a { 16, "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", }, //123 16b { 16, "Front: L", "Front: R", "Front: L", "Front: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", }, //123 16c { 16, "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Front: L", "Front: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Front: L", "Front: R", }, //123 16d { 16, "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Front: L", "Front: R", "Front: C", "LFE", "Side: L", "Side: R", "Side: L", "Side: R", "Side: L", "Side: R", }, //123 16e { 16, "Front: L", "Front: R", NULL, NULL, "Front: L", "Front: R", NULL, NULL, "Front: L", "Front: R", NULL, NULL, "Front: L", "Front: R", "Front: L", "Front: R", }, //123 16f }; const mxf_as11_audiotracklayout_assignment Mxf_AS11_AudioTrackLayout_ChannelLayout[Mxf_AS11_AudioTrackLayout_Count]= { { 2, "C", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 1a { 4, "C", NULL, "C", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 1b { 8, "C", NULL, "C", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 1c { 2, "L", "R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 2a { 4, "L", "R", "L", "R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 2b { 8, "L", "R", "L", "R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 2c { 4, "L", "R", "L", "R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 3a { 8, "L", "R", "L", "R", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, //48 3b { 2, "EBU R 48: 4a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 4b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 4c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 5a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 5b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 6a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 6b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 7a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 7b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 2, "EBU R 48: 8a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 8b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 8c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 9a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 9b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 2, "EBU R 48: 10a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 48: 11a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 11b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 48: 11c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 2, "EBU R 123: 2a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 123: 4a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 123: 4b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 4, "EBU R 123: 4c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8d", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8e", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8f", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8g", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8h", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 8, "EBU R 123: 8i", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12a", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12b", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12c", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12d", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12e", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12f", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12g", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 12, "EBU R 123: 12h", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, { 16, "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", }, //123 16a { 16, "L", "R", "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", "L", "R", "C", "LFE", "Ls", "Rs", }, //123 16b { 16, "L", "R", "L", "R", "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", "C", "LFE", "Ls", "Rs", }, //123 16c { 16, "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", }, //123 16d { 16, "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", "C", "LFE", "Ls", "Rs", "L", "R", "L", "R", }, //123 16e { 16, "L", "R", NULL, NULL, "L", "R", NULL, NULL, "L", "R", NULL, NULL, "L", "R", "L", "R", }, //123 16f }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_FpaPass_Count=3; const char* Mxf_AS11_FpaPass[Mxf_AS11_FpaPass_Count]= { "Yes", "No", "Not tested", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_SigningPresent_Count=3; const char* Mxf_AS11_SigningPresent[Mxf_AS11_SigningPresent_Count]= { "Yes", "No", "Signer only", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_3D_Type_Count=4; const char* Mxf_AS11_3D_Type[Mxf_AS11_3D_Type_Count]= { "Side by side", "Dual", "Left eye only", "Right eye only", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_AudioLoudnessStandard_Count=2; const char* Mxf_AS11_AudioLoudnessStandard[Mxf_AS11_AudioLoudnessStandard_Count]= { "", "EBU R 128", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_AudioDescriptionType_Count=2; const char* Mxf_AS11_AudioDescriptionType[Mxf_AS11_AudioDescriptionType_Count]= { "Control data / Narration", "AD Mix", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_OpenCaptionsType_Count=2; const char* Mxf_AS11_OpenCaptionsType[Mxf_AS11_OpenCaptionsType_Count]= { "Hard of Hearing", "Translation", }; //--------------------------------------------------------------------------- const size_t Mxf_AS11_SignLanguage_Count=2; const char* Mxf_AS11_SignLanguage[Mxf_AS11_SignLanguage_Count]= { "BSL (British Sign Language)", "BSL (Makaton)", }; //--------------------------------------------------------------------------- // EBU Tech 3349 string Mxf_CameraUnitMetadata_GammaforCDL(int8u Value) { switch(Value) { case 0x00 : return "Same as Capture Gamma"; case 0x01 : return "Scene Linear"; case 0x02 : return "S-Log"; case 0x03 : return "Cine-Log"; case 0xFF : return "Undefined"; default : return Ztring::ToZtring(Value).To_UTF8(); } }; //--------------------------------------------------------------------------- // EBU Tech 3349 string Mxf_CameraUnitMetadata_NeutralDensityFilterWheelSetting(int16u Value) { switch(Value) { case 0x01 : return "Clear"; default : return Ztring::ToZtring(Value).To_UTF8(); } }; //--------------------------------------------------------------------------- // EBU Tech 3349 string Mxf_CameraUnitMetadata_ImageSensorReadoutMode(int8u Value) { switch(Value) { case 0x00 : return "Interlaced field"; case 0x01 : return "Interlaced frame"; case 0x02 : return "Progressive frame"; case 0xFF : return "Undefined"; default : return Ztring::ToZtring(Value).To_UTF8(); } }; //--------------------------------------------------------------------------- // EBU Tech 3349 string Mxf_CameraUnitMetadata_CaptureGammaEquation(int128u Value) { switch(Value.lo) { case 0x0401010101010000LL : return "BT.470"; // Directly from SMPTE registry case 0x0401010101020000LL : return "BT.709"; case 0x0401010101030000LL : return "SMPTE ST 240"; case 0x0401010101040000LL : return "SMPTE ST 274"; // Directly from SMPTE registry case 0x0401010101050000LL : return "BT.1361"; // Directly from SMPTE registry case 0x0401010101060000LL : return "SceneLinear"; // Directly from SMPTE registry case 0x0E06040101010101LL : return "DVW-709 Like"; // 0x0E06x values are read from SR Viewer program case 0x0E06040101010102LL : return "E10/E30STD for J EK"; case 0x0E06040101010103LL : return "E10/E30STD for UC"; case 0x0E06040101010106LL : return "BBC Initial50"; case 0x0E06040101010107LL : return "SD CamCorder STD"; case 0x0E06040101010108LL : return "BVW-400 Like"; case 0x0E06040101010109LL : return "Ikegami"; case 0x0E0604010101017FLL : return "reproduced unknown label"; case 0x0E06040101010201LL : return "HG3250G36"; case 0x0E06040101010202LL : return "HG4600G30"; case 0x0E06040101010203LL : return "HG3259G40"; case 0x0E06040101010204LL : return "HG4609G33"; case 0x0E06040101010205LL : return "HG8000G36"; case 0x0E06040101010206LL : return "HG8000G30"; case 0x0E06040101010207LL : return "HG8009G40"; case 0x0E06040101010208LL : return "HG8009G33"; case 0x0E06040101010301LL : return "CINE1 of EX1/EX3"; case 0x0E06040101010302LL : return "CINE2 of EX1/EX3"; case 0x0E06040101010303LL : return "CINE3 of EX1/EX3"; case 0x0E06040101010304LL : return "CINE4 of EX1/EX3"; case 0x0E06040101010305LL : return "Kodak 5248 film like"; case 0x0E06040101010306LL : return "Kodak 5245 film like"; case 0x0E06040101010307LL : return "Kodak 5293 film like"; case 0x0E06040101010308LL : return "Kodak 5296 film like"; case 0x0E06040101010309LL : return "Average of Film of MSW-900"; case 0x0E06040101010401LL : return "User defined curve1"; case 0x0E06040101010402LL : return "User defined curve2"; case 0x0E06040101010403LL : return "User defined curve3"; case 0x0E06040101010404LL : return "User defined curve4"; case 0x0E06040101010405LL : return "User defined curve5"; case 0x0E06040101010406LL : return "User defined curve6"; case 0x0E06040101010407LL : return "User defined curve7"; case 0x0E06040101010408LL : return "User defined curve8"; case 0x0E06040101010501LL : return "S-Log"; case 0x0E06040101010502LL : return "FS-Log"; case 0x0E06040101010503LL : return "R709 180%"; case 0x0E06040101010504LL : return "R709 800%"; case 0x0E06040101010506LL : return "Cine-Log"; case 0x0E06040101010507LL : return "ASC-CDL"; default : { Ztring ValueS; ValueS.From_Number(Value.lo, 16); if (ValueS.size()<16) ValueS.insert(0, 16-ValueS.size(), __T('0')); return ValueS.To_UTF8(); } } }; //--------------------------------------------------------------------------- // RDD 18 string Mxf_CameraUnitMetadata_AutoExposureMode(int128u Value) { switch(Value.lo) { case 0x0510010101010000LL : return "Manual"; case 0x0510010101020000LL : return "Full Auto"; case 0x0510010101030000LL : return "Gain Priority Auto"; case 0x0510010101040000LL : return "Iris Priority Auto"; case 0x0510010101050000LL : return "Shutter Priority Auto"; default : { Ztring ValueS; ValueS.From_Number(Value.lo, 16); if (ValueS.size()<16) ValueS.insert(0, 16-ValueS.size(), __T('0')); return ValueS.To_UTF8(); } } } //--------------------------------------------------------------------------- // RDD 18 string Mxf_CameraUnitMetadata_AutoFocusSensingAreaSetting(int8u Value) { switch(Value) { case 0x00 : return "Manual"; case 0x01 : return "Center Sensitive Auto"; case 0x02 : return "Full Screen Sensing Auto"; case 0x03 : return "Multi Spot Sensing Auto"; case 0x04 : return "Single Spot Sensing Auto"; default : return Ztring::ToZtring(Value).To_UTF8(); } } //--------------------------------------------------------------------------- // RDD 18 string Mxf_CameraUnitMetadata_ColorCorrectionFilterWheelSetting(int8u Value) { switch(Value) { case 0x00 : return "Cross effect"; case 0x01 : return "Color Compensation 3200 K"; case 0x02 : return "Color Compensation 4300 K"; case 0x03 : return "Color Compensation 6300 K"; case 0x04 : return "Color Compensation 5600 K"; default : return Ztring::ToZtring(Value).To_UTF8(); } } //--------------------------------------------------------------------------- // RDD 18 string Mxf_CameraUnitMetadata_AutoWhiteBalanceMode(int8u Value) { switch(Value) { case 0x00 : return "Preset"; case 0x01 : return "Automatic"; case 0x02 : return "Hold"; case 0x03 : return "One Push"; default : return Ztring::ToZtring(Value).To_UTF8(); } } //--------------------------------------------------------------------------- // CameraUnitMetadata string Mxf_AcquisitionMetadata_ElementName(int16u Value, bool IsSony=false) { if (IsSony) switch (Value) { case 0xE101: return "EffectiveMarkerCoverage"; case 0xE102: return "EffectiveMarkerAspectRatio"; case 0xE103: return "CameraProcessDiscriminationCode"; case 0xE104: return "RotaryShutterMode"; case 0xE105: return "RawBlackCodeValue"; case 0xE106: return "RawGrayCodeValue"; case 0xE107: return "RawWhiteCodeValue"; case 0xE109: return "MonitoringDescriptions"; case 0xE10B: return "MonitoringBaseCurve"; //case 0xE201: return "CookeProtocol_BinaryMetadata"; //Not used case 0xE202: return "CookeProtocol_UserMetadata"; case 0xE203: return "CookeProtocol_CalibrationType"; default: ; } switch (Value) // From EBU Tech 3349 { case 0x3210: return "CaptureGammaEquation"; case 0x8000: return "IrisFNumber"; case 0x8001: return "FocusPositionFromImagePlane"; case 0x8002: return "FocusPositionFromFrontLensVertex"; case 0x8003: return "MacroSetting"; case 0x8004: return "LensZoom35mmStillCameraEquivalent"; case 0x8005: return "LensZoomActualFocalLength"; case 0x8006: return "OpticalExtenderMagnification"; case 0x8007: return "LensAttributes"; case 0x8100: return "AutoExposureMode"; case 0x8101: return "AutoFocusSensingAreaSetting"; case 0x8102: return "ColorCorrectionFilterWheelSetting"; case 0x8103: return "NeutralDensityFilterWheelSetting"; case 0x8104: return "ImageSensorDimensionEffectiveWidth"; case 0x8105: return "ImageSensorDimensionEffectiveHeight"; case 0x8106: return "CaptureFrameRate"; case 0x8107: return "ImageSensorReadoutMode"; case 0x8108: return "ShutterSpeed_Angle"; case 0x8109: return "ShutterSpeed_Time"; case 0x810A: return "CameraMasterGainAdjustment"; case 0x810B: return "ISOSensitivity"; case 0x810C: return "ElectricalExtenderMagnification"; case 0x810D: return "AutoWhiteBalanceMode"; case 0x810E: return "WhiteBalance"; case 0x810F: return "CameraMasterBlackLevel"; case 0x8110: return "CameraKneePoint"; case 0x8111: return "CameraKneeSlope"; case 0x8112: return "CameraLuminanceDynamicRange"; case 0x8113: return "CameraSettingFileURI"; case 0x8114: return "CameraAttributes"; case 0x8115: return "ExposureIndexofPhotoMeter"; case 0x8116: return "GammaForCDL"; case 0x8117: return "ASC_CDL_V12"; default: return Ztring(Ztring::ToZtring(Value, 16)).To_UTF8(); } } //--------------------------------------------------------------------------- // CameraUnitMetadata - Sony E201 (Values are internal MI) const size_t Mxf_AcquisitionMetadata_Sony_E201_ElementCount = 11; const char* Mxf_AcquisitionMetadata_Sony_E201_ElementName[Mxf_AcquisitionMetadata_Sony_E201_ElementCount] = { "FocusDistance", "ApertureValue", "ApertureScale", "EffectiveFocaleLength", "HyperfocalDistance", "NearFocusDistance", "FarFocusDistance", "HorizontalFieldOfView", "EntrancePupilPosition", "NormalizedZoomValue", "LensSerialNumber", }; //--------------------------------------------------------------------------- // Read from SR Viewer program string Mxf_AcquisitionMetadata_Sony_CameraProcessDiscriminationCode(int16u Value) { switch (Value) { case 0x0101: return "F65 RAW Mode released in December 2011"; case 0x0102: return "F65 HD Mode released in April 2012"; case 0x0103: return "F65 RAW High Frame Rate Mode released in July 2012"; default: return Ztring(Ztring::ToZtring(Value, 16)).To_UTF8(); } }; //--------------------------------------------------------------------------- // Read from SR Viewer program string Mxf_AcquisitionMetadata_Sony_MonitoringBaseCurve(int128u Value) { switch(Value.lo) { case 0x0E06040101010508LL : return "S-Log2"; default : { Ztring ValueS; ValueS.From_Number(Value.lo, 16); if (ValueS.size()<16) ValueS.insert(0, 16-ValueS.size(), __T('0')); return ValueS.To_UTF8(); } } } //--------------------------------------------------------------------------- extern const char* Mpegv_profile_and_level_indication_profile[]; extern const char* Mpegv_profile_and_level_indication_level[]; extern const char* Mpeg4v_Profile_Level(int32u Profile_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_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_End_Unlimited=false; 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; IsSearchingFooterPartitionAddress=false; FooterPartitionAddress_Jumped=false; PartitionPack_Parsed=false; IdIsAlwaysSame_Offset=0; PartitionMetadata_PreviousPartition=(int64u)-1; PartitionMetadata_FooterPartition=(int64u)-1; RandomIndexMetadatas_MaxOffset=(int64u)-1; DTS_Delay=0; SDTI_TimeCode_RepetitionCount=0; SDTI_SizePerFrame=0; SDTI_IsPresent=false; SDTI_IsInIndexStreamOffset=true; SystemScheme1_TimeCodeArray_StartTimecode_ms=(int64u)-1; SystemScheme1_FrameRateFromDescriptor=0; Essences_FirstEssence_Parsed=false; MayHaveCaptionsInStream=false; StereoscopicPictureSubDescriptor_IsPresent=false; UserDefinedAcquisitionMetadata_UdamSetIdentifier_IsSony=false; Essences_UsedForFrameCount=(int32u)-1; #if MEDIAINFO_ADVANCED Footer_Position=(int64u)-1; #endif //MEDIAINFO_ADVANCED 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 #if MEDIAINFO_DEMUX DemuxedSampleCount_Total=(int64u)-1; DemuxedSampleCount_Current=(int64u)-1; DemuxedSampleCount_AddedToFirstFrame=0; DemuxedElementSize_AddedToFirstFrame=0; #endif //MEDIAINFO_DEMUX } //--------------------------------------------------------------------------- File_Mxf::~File_Mxf() { #if defined(MEDIAINFO_REFERENCES_YES) delete ReferenceFiles; #endif //defined(MEDIAINFO_REFERENCES_YES) #if defined(MEDIAINFO_ANCILLARY_YES) if (!Ancillary_IsBinded) delete Ancillary; #endif //defined(MEDIAINFO_ANCILLARY_YES) } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Mxf::Streams_Accept() { //Configuration Buffer_MaximumSize=64*1024*1024; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p, 4K) } //--------------------------------------------------------------------------- void File_Mxf::Streams_Fill() { for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); ++Essence) for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) Fill(*Parser); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish() { #if MEDIAINFO_NEXTPACKET && defined(MEDIAINFO_REFERENCES_YES) //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 && defined(MEDIAINFO_REFERENCES_YES) //Per stream for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); ++Essence) { if (Essence->second.Parsers.size()>1 && Essence->second.StreamKind==Stream_Audio) // Last parser is PCM, impossible to detect with another method if there is only one block { for (size_t Pos=0; Possecond.Parsers.size()-1; Pos++) delete Essence->second.Parsers[Pos]; Essence->second.Parsers.erase(Essence->second.Parsers.begin(), Essence->second.Parsers.begin()+Essence->second.Parsers.size()-1); Essence->second.Parsers[0]->Accept(); Essence->second.Parsers[0]->Fill(); } for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) { if (!(*Parser)->Status[IsFinished]) { if (Config->ParseSpeed>=1) { int64u File_Size_Temp=File_Size; File_Size=File_Offset+Buffer_Offset+Element_Offset; Open_Buffer_Continue(*Parser, Buffer, 0); File_Size=File_Size_Temp; } Finish(*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) for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) { Merge(*(*Parser)); Ztring LawRating=(*Parser)->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=(*Parser)->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); if (IsSub && StreamKind_Last!=Stream_Max && Retrieve(StreamKind_Last, StreamPos_Last, "MuxingMode").empty()) Fill(StreamKind_Last, StreamPos_Last, "MuxingMode", "MXF"); } } 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)); //Time codes if (SDTI_TimeCode_StartTimecode.IsValid()) { bool IsDuplicate=false; for (size_t Pos2=0; Pos2NextPacket_Get() && ReferenceFiles) { ReferenceFiles_IsParsing=true; return; } #endif //MEDIAINFO_NEXTPACKET //Sizes #if MEDIAINFO_ADVANCED if (Footer_Position!=(int64u)-1) Fill(Stream_General, 0, General_FooterSize, File_Size-Footer_Position); else Fill(Stream_General, 0, "IsTruncated", "Yes", Unlimited, true, true); #endif //MEDIAINFO_ADVANCED //Commercial names Streams_Finish_CommercialNames(); //Handling separate streams for (size_t StreamKind=Stream_General+1; StreamKindFile_IgnoreEditsBefore || Config->File_IgnoreEditsAfter!=(int64u)-1) { int64u FrameCount_FromComponent=(int64u)-1; for (components::iterator Component=Components.begin(); Component!=Components.end(); ++Component) if (FrameCount_FromComponent>Component->second.Duration) FrameCount_FromComponent=Component->second.Duration; float64 EditRate_FromTrack=DBL_MAX; for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (EditRate_FromTrack>Track->second.EditRate) EditRate_FromTrack=Track->second.EditRate; if (FrameCount_FromComponent!=(int64u)-1 && FrameCount_FromComponent && EditRate_FromTrack!=DBL_MAX && EditRate_FromTrack) { int64u FrameCount=FrameCount_FromComponent; int64u File_IgnoreEditsBefore=Config->File_IgnoreEditsBefore; if (File_IgnoreEditsBefore && Config->File_EditRate && (EditRate_FromTrackFile_EditRate*0.9 || EditRate_FromTrack>Config->File_EditRate*1.1)) //In case of problem or EditRate being sampling rate File_IgnoreEditsBefore=float64_int64s(((float64)File_IgnoreEditsBefore)/Config->File_EditRate*EditRate_FromTrack); int64u File_IgnoreEditsAfter=Config->File_IgnoreEditsAfter; if (File_IgnoreEditsAfter!=(int64u)-1 && Config->File_EditRate && (EditRate_FromTrackFile_EditRate*0.9 || EditRate_FromTrack>Config->File_EditRate*1.1)) //In case of problem or EditRate being sampling rate File_IgnoreEditsAfter=float64_int64s(((float64)File_IgnoreEditsAfter)/Config->File_EditRate*EditRate_FromTrack); if (File_IgnoreEditsAftersecond.IsTimeCode) //Already done somewhere else { Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, "ID", __T("System scheme 1-")+Ztring().From_Number((int8u)(SystemScheme->first>8))+__T('-')+Ztring().From_Number((int8u)(SystemScheme->first&0xFF))); Fill(Stream_Other, StreamPos_Last, "MuxingMode", "System scheme 1"); } } //Primary package info bool PrimaryPackageIsSourcePackage=false; bool PrimaryPackageIsMaterialPackage=false; for (prefaces::iterator Preface=Prefaces.begin(); Preface!=Prefaces.end(); ++Preface) { for (packages::iterator Package=Packages.begin(); Package!=Packages.end(); ++Package) if (Package->first==Preface->second.PrimaryPackage) { if (Package->second.IsSourcePackage) PrimaryPackageIsSourcePackage=true; else PrimaryPackageIsMaterialPackage=true; } } if (PrimaryPackageIsSourcePackage && !PrimaryPackageIsMaterialPackage) { Fill(Stream_General, 0, "PrimaryPackage", "Source Package"); (*Stream_More)[Stream_General][0](Ztring().From_Local("PrimaryPackage"), Info_Options)=__T("N NT"); } if (!PrimaryPackageIsSourcePackage && PrimaryPackageIsMaterialPackage) { Fill(Stream_General, 0, "PrimaryPackage", "Material Package"); (*Stream_More)[Stream_General][0](Ztring().From_Local("PrimaryPackage"), Info_Options)=__T("N NT"); } //CameraUnitMetadata if (!AcquisitionMetadataLists.empty()) for (size_t Pos = 0; Pos < AcquisitionMetadataLists.size(); Pos++) { if (UserDefinedAcquisitionMetadata_UdamSetIdentifier_IsSony && Pos==0xE201 && !AcquisitionMetadata_Sony_E201_Lists.empty()) { for (size_t i=0; iempty()) { string ElementName(Mxf_AcquisitionMetadata_Sony_E201_ElementName[i]); string ElementName_FirstFrame(ElementName+"_FirstFrame"); string ElementName_Values(ElementName+"_Values"); string ElementName_FrameCounts(ElementName+"_FrameCounts"); Fill(Stream_Other, 0, ElementName_FirstFrame.c_str(), (*AcquisitionMetadata_Sony_E201_Lists[i])[0].Value); switch (i) { case 0 : //FocusDistance case 4 : //HyperfocalDistance case 5 : //NearFocusDistance case 6 : //FarFocusDistance case 8 : //EntrancePupilPosition (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); if (AcquisitionMetadataLists[0xE203] && !AcquisitionMetadataLists[0xE203]->empty()) //Calibration Type Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadata_Sony_E201_Lists[i])[0].Value+' '+(*AcquisitionMetadataLists[0xE203])[0].Value); break; case 3 : //EffectiveFocaleLength (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadata_Sony_E201_Lists[i])[0].Value+" mm"); break; case 7 : //HorizontalFieldOfView (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadata_Sony_E201_Lists[i])[0].Value+"\xc2\xB0"); break; default : ; } for (size_t List_Pos=0; List_Possize(); List_Pos++) { Fill(Stream_Other, 0, ElementName_Values.c_str(), (*AcquisitionMetadata_Sony_E201_Lists[i])[List_Pos].Value); Fill(Stream_Other, 0, ElementName_FrameCounts.c_str(), (*AcquisitionMetadata_Sony_E201_Lists[i])[List_Pos].FrameCount); } (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_Values.c_str()), Info_Options)=__T("N NT"); (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FrameCounts.c_str()), Info_Options)=__T("N NT"); } } else if (AcquisitionMetadataLists[Pos] && !AcquisitionMetadataLists[Pos]->empty()) { string ElementName(Mxf_AcquisitionMetadata_ElementName((int16u)Pos, UserDefinedAcquisitionMetadata_UdamSetIdentifier_IsSony)); string ElementName_FirstFrame(ElementName+"_FirstFrame"); string ElementName_Values(ElementName+"_Values"); string ElementName_FrameCounts(ElementName+"_FrameCounts"); Fill(Stream_Other, 0, ElementName_FirstFrame.c_str(), (*AcquisitionMetadataLists[Pos])[0].Value); switch (Pos) { case 0x8001 : //FocusPosition_ImagePlane case 0x8002 : //FocusPosition_FrontLensVertex case 0x8004 : //LensZoom_35mmStillCameraEquivalent case 0x8005 : //LensZoom_ActualFocalLength (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+" m"); break; case 0x8006 : //OpticalExtenderMagnification case 0x810C : //ElectricalExtenderMagnification case 0x810F : //CameraMasterBlackLevel case 0x8110 : //CameraKneePoint case 0x8112 : //CameraLuminanceDynamicRange (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+"%"); break; case 0x8104 : //ImagerDimension_EffectiveWidth case 0x8105 : //ImagerDimension_EffectiveHeight (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+" mm"); break; case 0x8106 : //CaptureFrameRate (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+" fps"); break; case 0x8108 : //ShutterSpeed_Angle (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+"\xc2\xB0"); break; case 0x8109 : //ShutterSpeed_Time (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+" s"); break; case 0x810A : //CameraMasterGainAdjustment (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+" dB"); break; case 0x810E : //WhiteBalance (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); Fill(Stream_Other, 0, (ElementName_FirstFrame+"/String").c_str(), (*AcquisitionMetadataLists[Pos])[0].Value+" K"); break; default : ; } if (UserDefinedAcquisitionMetadata_UdamSetIdentifier_IsSony && Pos==0xE203) // Calibration Type, not for display (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FirstFrame.c_str()), Info_Options)=__T("N NT"); for (size_t List_Pos=0; List_Possize(); List_Pos++) { Fill(Stream_Other, 0, ElementName_Values.c_str(), (*AcquisitionMetadataLists[Pos])[List_Pos].Value); Fill(Stream_Other, 0, ElementName_FrameCounts.c_str(), (*AcquisitionMetadataLists[Pos])[List_Pos].FrameCount); } (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_Values.c_str()), Info_Options)=__T("N NT"); (*Stream_More)[Stream_Other][0](Ztring().From_UTF8(ElementName_FrameCounts.c_str()), Info_Options)=__T("N NT"); } } } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Preface (const int128u PrefaceUID) { prefaces::iterator Preface=Prefaces.find(PrefaceUID); if (Preface==Prefaces.end()) return; //ContentStorage Streams_Finish_ContentStorage(Preface->second.ContentStorage); //ContenStorage, for AS11 Streams_Finish_ContentStorage_ForAS11(Preface->second.ContentStorage); //Identifications for (size_t Pos=0; Possecond.Identifications.size(); Pos++) Streams_Finish_Identification(Preface->second.Identifications[Pos]); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Preface_ForTimeCode (const int128u PrefaceUID) { prefaces::iterator Preface=Prefaces.find(PrefaceUID); if (Preface==Prefaces.end()) return; //ContentStorage Streams_Finish_ContentStorage_ForTimeCode(Preface->second.ContentStorage); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_ContentStorage (const int128u ContentStorageUID) { contentstorages::iterator ContentStorage=ContentStorages.find(ContentStorageUID); if (ContentStorage==ContentStorages.end()) return; for (size_t Pos=0; Possecond.Packages.size(); Pos++) Streams_Finish_Package(ContentStorage->second.Packages[Pos]); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_ContentStorage_ForTimeCode (const int128u ContentStorageUID) { contentstorages::iterator ContentStorage=ContentStorages.find(ContentStorageUID); if (ContentStorage==ContentStorages.end()) return; //Searching the right Time code track first TODO: this is an hack in order to get material or source time code, we need to have something more conform in the future // Material Package then Source Package for (size_t Pos=0; Possecond.Packages.size(); Pos++) { packages::iterator Package=Packages.find(ContentStorage->second.Packages[Pos]); if (Package!=Packages.end() && !Package->second.IsSourcePackage) Streams_Finish_Package_ForTimeCode(ContentStorage->second.Packages[Pos]); } for (size_t Pos=0; Possecond.Packages.size(); Pos++) { packages::iterator Package=Packages.find(ContentStorage->second.Packages[Pos]); if (Package!=Packages.end() && Package->second.IsSourcePackage) Streams_Finish_Package_ForTimeCode(ContentStorage->second.Packages[Pos]); } } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_ContentStorage_ForAS11 (const int128u ContentStorageUID) { contentstorages::iterator ContentStorage=ContentStorages.find(ContentStorageUID); if (ContentStorage==ContentStorages.end()) return; for (size_t Pos=0; Possecond.Packages.size(); Pos++) Streams_Finish_Package_ForAS11(ContentStorage->second.Packages[Pos]); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Package (const int128u PackageUID) { packages::iterator Package=Packages.find(PackageUID); if (Package==Packages.end() || !Package->second.IsSourcePackage) return; for (size_t Pos=0; Possecond.Tracks.size(); Pos++) Streams_Finish_Track(Package->second.Tracks[Pos]); Streams_Finish_Descriptor(Package->second.Descriptor, PackageUID); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Package_ForTimeCode (const int128u PackageUID) { packages::iterator Package=Packages.find(PackageUID); if (Package==Packages.end()) return; for (size_t Pos=0; Possecond.Tracks.size(); Pos++) Streams_Finish_Track_ForTimeCode(Package->second.Tracks[Pos], Package->second.IsSourcePackage); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Package_ForAS11 (const int128u PackageUID) { packages::iterator Package=Packages.find(PackageUID); if (Package==Packages.end() || Package->second.IsSourcePackage) return; for (size_t Pos=0; Possecond.Tracks.size(); Pos++) Streams_Finish_Track_ForAS11(Package->second.Tracks[Pos]); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Track(const 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 Streams_Finish_Component(Track->second.Sequence, Track->second.EditRate_Real?Track->second.EditRate_Real:Track->second.EditRate, Track->second.TrackID, Track->second.Origin); //Done Track->second.Stream_Finish_Done=true; } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Track_ForTimeCode(const int128u TrackUID, bool IsSourcePackage) { 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; //Sequence Streams_Finish_Component_ForTimeCode(Track->second.Sequence, Track->second.EditRate_Real?Track->second.EditRate_Real:Track->second.EditRate, Track->second.TrackID, Track->second.Origin, IsSourcePackage); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Track_ForAS11(const 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; //Sequence Streams_Finish_Component_ForAS11(Track->second.Sequence, Track->second.EditRate_Real?Track->second.EditRate_Real:Track->second.EditRate, Track->second.TrackID, Track->second.Origin); //TrackName if (StreamKind_Last!=Stream_Max && !Track->second.TrackName.empty()) Fill(StreamKind_Last, StreamPos_Last, "Title", Track->second.TrackName); //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.Parsers.size()!=1) return; parsers::iterator Parser=Essence->second.Parsers.begin(); //Descriptive Metadata std::vector DMScheme1s_List; int32u TrackID=(int32u)-1; tracks::iterator Track=Tracks.find(TrackUID); if (Track!=Tracks.end()) TrackID=Track->second.TrackID; for (dmsegments::iterator DMSegment=DMSegments.begin(); DMSegment!=DMSegments.end(); ++DMSegment) for (size_t Pos=0; Possecond.TrackIDs.size(); Pos++) if (DMSegment->second.TrackIDs[Pos]==TrackID) DMScheme1s_List.push_back(DMSegment->second.Framework); if (Config->ParseSpeed<1.0 && !(*Parser)->Status[IsFinished]) { Fill(*Parser); (*Parser)->Open_Buffer_Unsynch(); } Finish(*Parser); StreamKind_Last=Stream_Max; if ((*Parser)->Count_Get(Stream_Video)) { Stream_Prepare(Stream_Video); if (IsSub) Fill(Stream_Video, StreamPos_Last, Video_MuxingMode, "MXF"); } else if ((*Parser)->Count_Get(Stream_Audio)) Stream_Prepare(Stream_Audio); else if ((*Parser)->Count_Get(Stream_Text)) Stream_Prepare(Stream_Text); else if ((*Parser)->Count_Get(Stream_Other)) Stream_Prepare(Stream_Other); 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 } if (IsSub) Fill(StreamKind_Last, StreamPos_Last, "MuxingMode", "MXF"); 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::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 (MxfTimeCodeForDelay.RoundedTimecodeBase && MxfTimeCodeForDelay.StartTimecode!=(int64u)-1) { float64 TimeCode_StartTimecode_Temp=((float64)(MxfTimeCodeForDelay.StartTimecode+Config->File_IgnoreEditsBefore))/MxfTimeCodeForDelay.RoundedTimecodeBase; if (MxfTimeCodeForDelay.DropFrame) { TimeCode_StartTimecode_Temp*=1001; TimeCode_StartTimecode_Temp/=1000; } Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), TimeCode_StartTimecode_Temp*1000, 0, true); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container"); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_DropFrame), MxfTimeCodeForDelay.DropFrame?"Yes":"No"); //TimeCode TC(MxfTimeCodeForDelay.StartTimecode, MxfTimeCodeForDelay.RoundedTimecodeBase, MxfTimeCodeForDelay.DropFrame); //Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_TimeCode_FirstFrame), TC.ToString().c_str()); //Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_TimeCode_Source), "Time code track (stripped)"); } if (SDTI_TimeCode_StartTimecode.IsValid()) { Fill(StreamKind_Last, StreamPos_Last, "Delay_SDTI", SDTI_TimeCode_StartTimecode.ToMilliseconds()); if (StreamKind_Last!=Stream_Max) (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("Delay_SDTI"), Info_Options)=__T("N NT"); //Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_TimeCode_FirstFrame), SDTI_TimeCode_StartTimecode.c_str()); //Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_TimeCode_Source), "SDTI"); } if (SystemScheme1_TimeCodeArray_StartTimecode_ms!=(int64u)-1) { Fill(StreamKind_Last, StreamPos_Last, "Delay_SystemScheme1", SystemScheme1_TimeCodeArray_StartTimecode_ms); if (StreamKind_Last!=Stream_Max) (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("Delay_SystemScheme1"), Info_Options)=__T("N NT"); //Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_TimeCode_FirstFrame), SystemScheme1_TimeCodeArray_StartTimecode.c_str()); //Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_TimeCode_Source), "System scheme 1"); } //Special case - Multiple sub-streams in a stream if (((*Parser)->Retrieve(Stream_General, 0, General_Format)==__T("ChannelGrouping") || (*Parser)->Count_Get(StreamKind_Last)>1) && (*Parser)->Count_Get(Stream_Audio)) { //Before 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 ((*Parser)->Retrieve(Stream_General, 0, General_Format)==__T("ChannelGrouping")) { //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); } else { NewPos1=StreamPos_Last; ID=Ztring::ToZtring(Essence->second.TrackID); Stream_Erase(NewKind, NewPos1); } //After for (size_t StreamPos=0; StreamPos<(*Parser)->Count_Get(NewKind); StreamPos++) { Stream_Prepare(NewKind, NewPos1+StreamPos); Merge(*(*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; PosCount_Get(NewKind)>1 && (!StreamSave[Pos].empty() || StreamPos)) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Encoded), StreamPos?0:(StreamSave[Pos].To_int64u()*2)); else if (Pos==Fill_Parameter(StreamKind_Last, Generic_StreamSize) && (*Parser)->Count_Get(NewKind)>1 && (!StreamSave[Pos].empty() || StreamPos)) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize_Encoded), StreamPos?0:(StreamSave[Pos].To_int64u()*2)); else if (Retrieve(StreamKind_Last, StreamPos_Last, Pos).empty()) Fill(StreamKind_Last, StreamPos_Last, Pos, StreamSave[Pos]); } for (size_t Pos=0; Possecond.PrimaryExtendedSpokenLanguage, true); } } } //Positioning other streams for (essences::iterator Essence_Temp=Essence; Essence_Temp!=Essences.end(); ++Essence_Temp) if (*(Essence_Temp->second.Parsers.begin()) && (*(Essence_Temp->second.Parsers.begin()))->Count_Get(Stream_Audio)) { Essence_Temp->second.StreamPos-=2; //ChannelGrouping Essence_Temp->second.StreamPos+=(*(Essence_Temp->second.Parsers.begin()))->Count_Get(Stream_Audio); } } else //Normal { //From descriptor if ((*Parser)->Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==__T("PCM")) // MXF handles channel count only with PCM, not with compressed data for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); ++Descriptor) if (Descriptor->second.LinkedTrackID==Essence->second.TrackID && Descriptor->second.StreamKind==Stream_Audio && StreamKind_Last==Stream_Audio && Descriptor->second.ChannelCount!=(int32u)-1) { Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Descriptor->second.ChannelCount); break; } MergedStreams_Last.clear(); //TODO: better way to do this Merge(*(*Parser), StreamKind_Last, 0, StreamPos_Last); MergedStreams_Last.push_back(streamidentity(StreamKind_Last, StreamPos_Last)); Ztring LawRating=(*Parser)->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=(*Parser)->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); for (size_t Pos=0; Possecond.PrimaryExtendedSpokenLanguage, true); } } for (size_t StreamPos=1; StreamPos<(*Parser)->Count_Get(StreamKind_Last); StreamPos++) //If more than 1 stream, TODO: better way to do this { Stream_Prepare(StreamKind_Last); Merge(*(*Parser), StreamKind_Last, StreamPos, StreamPos_Last); MergedStreams_Last.push_back(streamidentity(StreamKind_Last, StreamPos_Last)); } if (StreamKind_Last!=Stream_Other && (*Parser)->Count_Get(Stream_Other)) { stream_t StreamKind_Last_Main=StreamKind_Last; size_t StreamPos_Last_Main=StreamPos_Last; for (size_t StreamPos=0; StreamPos<(*Parser)->Count_Get(Stream_Other); StreamPos++) { Stream_Prepare(Stream_Other); Merge(*(*Parser), Stream_Other, StreamPos, StreamPos_Last); } Streams_Finish_Essence_FillID(EssenceUID, TrackUID); StreamKind_Last=StreamKind_Last_Main; StreamPos_Last=StreamPos_Last_Main; } } Streams_Finish_Essence_FillID(EssenceUID, TrackUID); //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, (*Parser)->Retrieve(Stream_General, 0, General_Recorded_Date)); //Video and Audio are together size_t Audio_Count=(*Parser)->Count_Get(Stream_Audio); for (size_t Audio_Pos=0; Audio_PosFinish(); if (MxfTimeCodeForDelay.RoundedTimecodeBase && MxfTimeCodeForDelay.StartTimecode!=(int64u)-1) { float64 TimeCode_StartTimecode_Temp=((float64)(MxfTimeCodeForDelay.StartTimecode+Config->File_IgnoreEditsBefore))/MxfTimeCodeForDelay.RoundedTimecodeBase; if (MxfTimeCodeForDelay.DropFrame) { TimeCode_StartTimecode_Temp*=1001; TimeCode_StartTimecode_Temp/=1000; } Fill(Stream_Audio, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), TimeCode_StartTimecode_Temp*1000, 0, true); Fill(Stream_Audio, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container"); } Merge(*(*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_StartAtZero[Essence->second.StreamKind]?0:1), Video_Format), true); else Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1), Video_Format)+__T(" / ")+Retrieve(Stream_Audio, Pos, Audio_MuxingMode), true); Fill(Stream_Audio, Pos, Audio_Duration, Retrieve(Stream_Video, Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1), 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_StartAtZero[Essence->second.StreamKind]?0:1); } #endif //Special case - MPEG Video + Captions if (StreamKind_Last==Stream_Video && (*Parser)->Count_Get(Stream_Text)) { //Video and Text are together size_t Parser_Text_Count=(*Parser)->Count_Get(Stream_Text); for (size_t Parser_Text_Pos=0; Parser_Text_PosFinish(); if (MxfTimeCodeForDelay.RoundedTimecodeBase && MxfTimeCodeForDelay.StartTimecode!=(int64u)-1) { float64 TimeCode_StartTimecode_Temp=((float64)(MxfTimeCodeForDelay.StartTimecode+Config->File_IgnoreEditsBefore))/MxfTimeCodeForDelay.RoundedTimecodeBase; if (MxfTimeCodeForDelay.DropFrame) { TimeCode_StartTimecode_Temp*=1001; TimeCode_StartTimecode_Temp/=1000; } Fill(Stream_Text, Parser_Text_Pos, Fill_Parameter(StreamKind_Last, Generic_Delay), TimeCode_StartTimecode_Temp*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); } for (size_t Pos=0; Possecond.PrimaryExtendedSpokenLanguage, true); } } } Ztring LawRating=(*Parser)->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=(*Parser)->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); StreamKind_Last=Stream_Video; StreamPos_Last=Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1); } //Stream size if (StreamKind_Last!=Stream_Max && Count_Get(Stream_Video)+Count_Get(Stream_Audio)==1 && Essence->second.Stream_Size!=(int64u)-1) { //TODO: Stream_Size is present only if there is one stream, so it works in most cases. We should find a better way. int64u Stream_Size=Essence->second.Stream_Size; if (Config->File_IgnoreEditsBefore || Config->File_IgnoreEditsAfter!=(int64u)-1) { int64u FrameCount_FromComponent=(int64u)-1; for (components::iterator Component=Components.begin(); Component!=Components.end(); ++Component) if (FrameCount_FromComponent>Component->second.Duration) FrameCount_FromComponent=Component->second.Duration; float64 EditRate_FromTrack=DBL_MAX; for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (EditRate_FromTrack>Track->second.EditRate) EditRate_FromTrack=Track->second.EditRate; if (FrameCount_FromComponent!=(int64u)-1 && FrameCount_FromComponent && EditRate_FromTrack!=DBL_MAX && EditRate_FromTrack) { int64u FrameCount=FrameCount_FromComponent; int64u File_IgnoreEditsBefore=Config->File_IgnoreEditsBefore; if (File_IgnoreEditsBefore && Config->File_EditRate && (EditRate_FromTrackFile_EditRate*0.9 || EditRate_FromTrack>Config->File_EditRate*1.1)) //In case of problem or EditRate being sampling rate File_IgnoreEditsBefore=float64_int64s(((float64)File_IgnoreEditsBefore)/Config->File_EditRate*EditRate_FromTrack); int64u File_IgnoreEditsAfter=Config->File_IgnoreEditsAfter; if (File_IgnoreEditsAfter!=(int64u)-1 && Config->File_EditRate && (EditRate_FromTrackFile_EditRate*0.9 || EditRate_FromTrack>Config->File_EditRate*1.1)) //In case of problem or EditRate being sampling rate File_IgnoreEditsAfter=float64_int64s(((float64)File_IgnoreEditsAfter)/Config->File_EditRate*EditRate_FromTrack); if (File_IgnoreEditsAftersecond.Stream_Finish_Done=true; } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Essence_FillID(int32u EssenceUID, int128u TrackUID) { essences::iterator Essence=Essences.find(EssenceUID); if (Essence==Essences.end() || Essence->second.Stream_Finish_Done) return; parsers::iterator Parser=Essence->second.Parsers.begin(); if (Retrieve(StreamKind_Last, StreamPos_Last, General_ID).empty() || StreamKind_Last==Stream_Text || StreamKind_Last==Stream_Other) //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_Possecond.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-((*Parser)->Count_Get(StreamKind_Last)?((*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-((*Parser)->Count_Get(StreamKind_Last)?((*Parser)->Count_Get(StreamKind_Last)-1):0); StreamPos<=StreamPos_Last; StreamPos++) //If more than 1 stream Fill(StreamKind_Last, StreamPos, "Title", Tracks[TrackUID].TrackName); } } } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Descriptor(const int128u DescriptorUID, const int128u PackageUID) { descriptors::iterator Descriptor=Descriptors.find(DescriptorUID); if (Descriptor==Descriptors.end()) return; //Subs if (Descriptor->second.Type==descriptor::type_Mutiple) { for (size_t Pos=0; Possecond.SubDescriptors.size(); Pos++) Streams_Finish_Descriptor(Descriptor->second.SubDescriptors[Pos], PackageUID); return; //Is not a real descriptor } StreamKind_Last=Descriptor->second.StreamKind; StreamPos_Last=Descriptor->second.StreamPos; if (StreamPos_Last==(size_t)-1) { for (size_t Pos=0; Possecond.LinkedTrackID)==ID) { StreamPos_Last=Pos; break; } } } if (StreamPos_Last==(size_t)-1) { if (Descriptors.size()==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_Possecond.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; StreamKindsecond.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? { if (Descriptor->second.StreamKind!=Stream_Max) Stream_Prepare(Descriptor->second.StreamKind); if (Track->second.TrackID!=(int32u)-1) { if (Descriptor->second.LinkedTrackID==(int32u)-1) Descriptor->second.LinkedTrackID=Track->second.TrackID; if (Descriptor->second.StreamKind!=Stream_Max) { 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; Possecond.Locators.size(); Locator_Pos++) { //Locator Streams_Finish_Locator(DescriptorUID, 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 if (Descriptor->second.ScanType==__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; StreamKindFile_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() && !(Retrieve(Stream_Video, StreamPos_Last, Video_Format) == __T("DV") && Descriptor->second.Width_Display == 1920 && (Retrieve(Stream_Video, StreamPos_Last, Video_Width) == __T("1280") || Retrieve(Stream_Video, StreamPos_Last, Video_Width) == __T("1440")))) // Exception: DVCPRO HD is really 1440 but lot of containers fill the width value with the marketing width 1920, we ignore it { 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); } //Info const Ztring &ID=Retrieve(StreamKind_Last, StreamPos_Last, General_ID); size_t ID_Dash_Pos=ID.find(__T('-')); size_t StreamWithSameID=1; if (ID_Dash_Pos!=(size_t)-1) { Ztring RealID=ID.substr(0, ID_Dash_Pos+1); while (StreamPos_Last+StreamWithSameIDsecond.SampleRate && StreamKind_Last==Stream_Video) { float64 SampleRate=Descriptor->second.SampleRate; if (StereoscopicPictureSubDescriptor_IsPresent) { SampleRate/=2; Fill(Stream_Video, StreamPos_Last, Video_MultiView_Count, 2, 10, true); } for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); ++Essence) if (Essence->second.StreamKind==Stream_Video && Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1)==StreamPos_Last) { if (Essence->second.Field_Count_InThisBlock_1 && !Essence->second.Field_Count_InThisBlock_2) SampleRate/=2; break; } Ztring SampleRate_Container; SampleRate_Container.From_Number(SampleRate); //TODO: fill frame rate before the merge with raw stream information const Ztring &SampleRate_RawStream=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate); if (!SampleRate_RawStream.empty() && SampleRate_Container!=SampleRate_RawStream) Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Original, SampleRate_RawStream); Fill(Stream_Video, StreamPos_Last, Video_FrameRate, SampleRate, 3, true); } for (std::map::iterator Info=Descriptor->second.Infos.begin(); Info!=Descriptor->second.Infos.end(); ++Info) if (Retrieve(StreamKind_Last, StreamPos_Last, Info->first.c_str()).empty()) { //Special case if (Info->first=="BitRate" && Retrieve(StreamKind_Last, StreamPos_Last, General_ID).find(__T(" / "))!=string::npos) { if (Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate)).empty() || Retrieve(StreamKind_Last, StreamPos_Last, General_ID).find(__T("-"))!=string::npos) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Encoded), Info->second.To_int64u()*2, 10, true); else Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate), Info->second.To_int64u()*2, 10, true); } else { for (size_t Pos=0; Posfirst.c_str(), Info->second, true); } } Ztring Format, CodecID; if (Descriptor->second.EssenceContainer.hi!=(int64u)-1) { CodecID.From_Number(Descriptor->second.EssenceContainer.lo, 16); if (CodecID.size()<16) CodecID.insert(0, 16-CodecID.size(), __T('0')); Format.From_Local(Mxf_EssenceContainer(Descriptor->second.EssenceContainer)); } if (Descriptor->second.EssenceCompression.hi!=(int64u)-1) { if (!CodecID.empty()) CodecID+=__T('-'); Ztring EssenceCompression; EssenceCompression.From_Number(Descriptor->second.EssenceCompression.lo, 16); if (EssenceCompression.size()<16) EssenceCompression.insert(0, 16-EssenceCompression.size(), __T('0')); CodecID+=EssenceCompression; Ztring Format_FromCompression; Format_FromCompression.From_Local(Mxf_EssenceCompression(Descriptor->second.EssenceCompression)); if (!Format_FromCompression.empty()) Format=Format_FromCompression; //EssenceCompression has priority } if (!CodecID.empty()) for (size_t Pos=0; Possecond.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); } //ScanType / ScanOrder if (StreamKind_Last==Stream_Video && Retrieve(Stream_Video, StreamPos_Last, Video_ScanType_Original).empty()) { //ScanType if (!Descriptor->second.ScanType.empty() && (Descriptor->second.ScanType!=Retrieve(Stream_Video, StreamPos_Last, Video_ScanType) && !(Descriptor->second.ScanType==__T("Interlaced") && Retrieve(Stream_Video, StreamPos_Last, Video_ScanType)==__T("MBAFF")))) { Fill(Stream_Video, StreamPos_Last, Video_ScanType_Original, Retrieve(Stream_Video, StreamPos_Last, Video_ScanType)); Fill(Stream_Video, StreamPos_Last, Video_ScanType, Descriptor->second.ScanType, true); } //ScanOrder Ztring ScanOrder_Temp; if ((Descriptor->second.FieldDominance==1 && Descriptor->second.FieldTopness==1) || (Descriptor->second.FieldDominance!=1 && Descriptor->second.FieldTopness==2)) ScanOrder_Temp.From_UTF8("TFF"); if ((Descriptor->second.FieldDominance==1 && Descriptor->second.FieldTopness==2) || (Descriptor->second.FieldDominance!=1 && Descriptor->second.FieldTopness==1)) ScanOrder_Temp.From_UTF8("BFF"); if ((!ScanOrder_Temp.empty() && ScanOrder_Temp!=Retrieve(Stream_Video, StreamPos_Last, Video_ScanOrder)) || !Retrieve(Stream_Video, StreamPos_Last, Video_ScanType_Original).empty()) { Fill(Stream_Video, StreamPos_Last, Video_ScanOrder_Original, Retrieve(Stream_Video, StreamPos_Last, Video_ScanOrder), true); if (ScanOrder_Temp.empty()) { Clear(Stream_Video, StreamPos_Last, Video_ScanOrder); Clear(Stream_Video, StreamPos_Last, Video_ScanOrder_String); } else Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, ScanOrder_Temp, true); } } //BlockAlignment if (StreamKind_Last==Stream_Audio && Descriptor->second.BlockAlign!=(int16u)-1) { if (Retrieve(Stream_Audio, StreamPos_Last, "BlockAlignment").empty()) //TODO: check the reason it is sometimes call several times. Fill(Stream_Audio, StreamPos_Last, "BlockAlignment", Descriptor->second.BlockAlign); if (StreamPos_Lastsecond.ChannelAssignment.lo!=(int64u)-1) { ChannelAssignment.From_Number(Descriptor->second.ChannelAssignment.lo, 16); if (ChannelAssignment.size()<16) ChannelAssignment.insert(0, 16-ChannelAssignment.size(), __T('0')); } if (!Descriptor->second.SubDescriptors.empty()) { std::vector AudioChannelLabels_MCALabelDictionaryID; for (size_t Pos=0; Possecond.SubDescriptors.size(); Pos++) { descriptors::iterator SubDescriptor=Descriptors.find(Descriptor->second.SubDescriptors[Pos]); if (SubDescriptor!=Descriptors.end()) { switch (SubDescriptor->second.Type) { case descriptor::Type_AudioChannelLabelSubDescriptor: AudioChannelLabels_MCALabelDictionaryID.push_back(SubDescriptor->second.MCALabelDictionaryID); break; case descriptor::Type_SoundfieldGroupLabelSubDescriptor: Fill(Stream_Audio, StreamPos_Last, "MCA Partition kind", SubDescriptor->second.MCAPartitionKind); Fill(Stream_Audio, StreamPos_Last, "MCA Partition Number", SubDescriptor->second.MCAPartitionNumber); Fill(Stream_Audio, StreamPos_Last, "MCA Title", SubDescriptor->second.MCATitle); Fill(Stream_Audio, StreamPos_Last, "MCA Title Version", SubDescriptor->second.MCATitleVersion); Fill(Stream_Audio, StreamPos_Last, "MCA Title Sub-Version", SubDescriptor->second.MCATitleSubVersion); Fill(Stream_Audio, StreamPos_Last, "MCA Episode", SubDescriptor->second.MCAEpisode); Fill(Stream_Audio, StreamPos_Last, "MCA Audio Content Kind", SubDescriptor->second.MCAAudioContentKind); Fill(Stream_Audio, StreamPos_Last, "MCA Audio Element Kind", SubDescriptor->second.MCAAudioElementKind); //if (SubDescriptor->second.MCALabelDictionaryID.lo!=(int64u)-1) //{ // Ztring ChannelAssignment2; // ChannelAssignment2.From_Number(SubDescriptor->second.MCALabelDictionaryID.lo, 16); // if (ChannelAssignment2.size()<16) // ChannelAssignment2.insert(0, 16-ChannelAssignment2.size(), __T('0')); // if (!ChannelAssignment.empty()) // ChannelAssignment+=__T('-'); // ChannelAssignment+=ChannelAssignment2; //} for (std::map::iterator Info=SubDescriptor->second.Infos.begin(); Info!=SubDescriptor->second.Infos.end(); ++Info) Fill(Stream_Audio, StreamPos_Last, Info->first.c_str(), Info->second, true); break; default: ; } } } if (!AudioChannelLabels_MCALabelDictionaryID.empty()) { Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, MXF_MCALabelDictionaryID_ChannelPositions(AudioChannelLabels_MCALabelDictionaryID)); Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, MXF_MCALabelDictionaryID_ChannelLayout(AudioChannelLabels_MCALabelDictionaryID)); } } if (!ChannelAssignment.empty()) Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayoutID, ChannelAssignment); } //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(const int128u DescriptorUID, const int128u LocatorUID) { descriptors::iterator Descriptor=Descriptors.find(DescriptorUID); if (Descriptor==Descriptors.end()) return; 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; Locator->second.LinkedTrackID=Descriptor->second.LinkedTrackID; } } //--------------------------------------------------------------------------- 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).empty() && 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 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).empty() && 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).empty() && 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).empty() && 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(const int128u ComponentUID, float64 EditRate, int32u TrackID, int64u Origin) { components::iterator Component=Components.find(ComponentUID); if (Component==Components.end()) return; //Duration if (EditRate && StreamKind_Last!=Stream_Max && Component->second.Duration!=(int64u)-1) { int64u FrameCount=Component->second.Duration; if (StreamKind_Last==Stream_Video || Config->File_EditRate) { int64u File_IgnoreEditsBefore=Config->File_IgnoreEditsBefore; if (File_IgnoreEditsBefore && Config->File_EditRate && (EditRateFile_EditRate*0.9 || EditRate>Config->File_EditRate*1.1)) //In case of problem or EditRate being sampling rate File_IgnoreEditsBefore=float64_int64s(((float64)File_IgnoreEditsBefore)/Config->File_EditRate*EditRate); int64u File_IgnoreEditsAfter=Config->File_IgnoreEditsAfter; if (File_IgnoreEditsAfter!=(int64u)-1 && Config->File_EditRate && (EditRateFile_EditRate*0.9 || EditRate>Config->File_EditRate*1.1)) //In case of problem or EditRate being sampling rate File_IgnoreEditsAfter=float64_int64s(((float64)File_IgnoreEditsAfter)/Config->File_EditRate*EditRate); if (File_IgnoreEditsAftersecond.StreamKind==Stream_Video && Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1)==StreamPos_Last) { if (Essence->second.Field_Count_InThisBlock_1 && !Essence->second.Field_Count_InThisBlock_2) FrameCount/=2; break; } FillAllMergedStreams=true; if (Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameCount)).empty()) Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameCount), FrameCount); if (Retrieve(StreamKind_Last, StreamPos_Last, "FrameRate").empty()) Fill(StreamKind_Last, StreamPos_Last, "FrameRate", EditRate); FillAllMergedStreams=false; } } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Component_ForTimeCode(const int128u ComponentUID, float64 EditRate, int32u TrackID, int64u Origin, bool IsSourcePackage) { components::iterator Component=Components.find(ComponentUID); if (Component==Components.end()) return; //For the sequence, searching Structural componenents for (size_t Pos=0; Possecond.StructuralComponents.size(); Pos++) { components::iterator Component2=Components.find(Component->second.StructuralComponents[Pos]); if (Component2!=Components.end() && Component2->second.MxfTimeCode.StartTimecode!=(int64u)-1 && !Config->File_IsReferenced_Get()) { //Note: Origin is not part of the StartTimecode for the first frame in the source package. From specs: "For a Timecode Track with a single Timecode Component and with origin N, where N greater than 0, the timecode value at the Zero Point of the Track equals the start timecode of the Timecode Component incremented by N units." TimeCode TC(Component2->second.MxfTimeCode.StartTimecode+Config->File_IgnoreEditsBefore, (int8u)Component2->second.MxfTimeCode.RoundedTimecodeBase, Component2->second.MxfTimeCode.DropFrame); bool IsHybridTimeCode=false; if (Component->second.StructuralComponents.size()==2 && !Pos) { components::iterator Component_TC2=Components.find(Component->second.StructuralComponents[1]); if (Component_TC2!=Components.end() && Component_TC2->second.MxfTimeCode.StartTimecode!=(int64u)-1) { TimeCode TC2(Component_TC2->second.MxfTimeCode.StartTimecode+Config->File_IgnoreEditsBefore, (int8u)Component_TC2->second.MxfTimeCode.RoundedTimecodeBase, Component2->second.MxfTimeCode.DropFrame); if (TC2.ToFrames()-TC.ToFrames()==2) { TC++; IsHybridTimeCode=true; } } } Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_ID, Ztring::ToZtring(TrackID)+(IsSourcePackage?__T("-Source"):__T("-Material"))); Fill(Stream_Other, StreamPos_Last, Other_Type, "Time code"); Fill(Stream_Other, StreamPos_Last, Other_Format, "MXF TC"); Fill(Stream_Other, StreamPos_Last, Other_TimeCode_FirstFrame, TC.ToString().c_str()); Fill(Stream_Other, StreamPos_Last, Other_TimeCode_Settings, IsSourcePackage?__T("Source Package"):__T("Material Package")); Fill(Stream_Other, StreamPos_Last, Other_TimeCode_Striped, "Yes"); if ((!TimeCodeFromMaterialPackage && IsSourcePackage) || (TimeCodeFromMaterialPackage && !IsSourcePackage)) { MxfTimeCodeForDelay=Component2->second.MxfTimeCode; DTS_Delay=((float64)MxfTimeCodeForDelay.StartTimecode)/MxfTimeCodeForDelay.RoundedTimecodeBase; if (MxfTimeCodeForDelay.DropFrame) { DTS_Delay*=1001; DTS_Delay/=1000; } FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000); #if MEDIAINFO_DEMUX Config->Demux_Offset_DTS_FromStream=FrameInfo.DTS; #endif //MEDIAINFO_DEMUX } if (!IsSourcePackage) { MxfTimeCodeMaterial=Component2->second.MxfTimeCode; } if (IsHybridTimeCode) break; } } } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Component_ForAS11(const int128u ComponentUID, float64 EditRate, int32u TrackID, int64u Origin) { components::iterator Component=Components.find(ComponentUID); if (Component==Components.end()) return; //Computing frame rate int64u TC_Temp=0; int8u FrameRate_TempI; bool DropFrame_Temp; if (MxfTimeCodeMaterial.RoundedTimecodeBase && MxfTimeCodeMaterial.StartTimecode!=(int64u)-1) { TC_Temp=MxfTimeCodeMaterial.StartTimecode; FrameRate_TempI=(int8u)MxfTimeCodeMaterial.RoundedTimecodeBase; DropFrame_Temp=MxfTimeCodeMaterial.DropFrame; } else { TC_Temp=0; Ztring FrameRateS=Retrieve(Stream_Video, 0, Video_FrameRate); int32u FrameRate_TempI32=float32_int32s(FrameRateS.To_float32()); if (FrameRate_TempI32 && FrameRate_TempI32<256) { FrameRate_TempI=(int8u)FrameRate_TempI32; float32 FrameRateF=FrameRateS.To_float32(); float FrameRateF_Min=((float32)FrameRate_TempI)/((float32)1.002); float FrameRateF_Max=(float32)FrameRate_TempI; if (FrameRateF>=FrameRateF_Min && FrameRateFsecond.StructuralComponents.size(); Pos++) { // AS-11 dmsegments::iterator DMSegment=DMSegments.find(Component->second.StructuralComponents[Pos]); if (DMSegment!=DMSegments.end()) { as11s::iterator AS11=AS11s.find(DMSegment->second.Framework); if (AS11!=AS11s.end()) { if (StreamKind_Last==Stream_Max) { Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_ID, TrackID); Fill(Stream_Other, StreamPos_Last, Other_Type, "Metadata"); if (AS11->second.Type==as11::Type_Segmentation) { if (AS11->second.PartTotal!=(int16u)-1) Fill(Stream_Other, StreamPos_Last, "PartTotal", AS11->second.PartTotal); } } switch (AS11->second.Type) { case as11::Type_Core: Fill(Stream_Other, StreamPos_Last, "Format", "AS-11 Core"); Fill(Stream_Other, StreamPos_Last, "SeriesTitle", AS11->second.SeriesTitle); Fill(Stream_Other, StreamPos_Last, "ProgrammeTitle", AS11->second.ProgrammeTitle); Fill(Stream_Other, StreamPos_Last, "EpisodeTitleNumber", AS11->second.EpisodeTitleNumber); Fill(Stream_Other, StreamPos_Last, "ShimName", AS11->second.ShimName); if (AS11->second.ShimVersion_Major!=(int8u)-1) { Ztring Version=Ztring::ToZtring(AS11->second.ShimVersion_Major); if (AS11->second.ShimVersion_Minor!=(int8u)-1) { Version+=__T('.'); Version+=Ztring::ToZtring(AS11->second.ShimVersion_Minor); } Fill(Stream_Other, StreamPos_Last, "ShimVersion", Version); } if (AS11->second.AudioTrackLayoutsecond.AudioTrackLayout]); //Per track const mxf_as11_audiotracklayout_assignment &ChP=Mxf_AS11_AudioTrackLayout_ChannelPositions[AS11->second.AudioTrackLayout]; const mxf_as11_audiotracklayout_assignment &ChL=Mxf_AS11_AudioTrackLayout_ChannelLayout[AS11->second.AudioTrackLayout]; if (Count_Get(Stream_Audio)>=ChP.Count) for (size_t Pos=0; Possecond.AudioTrackLayout]); } } Fill(Stream_Other, StreamPos_Last, "PrimaryAudioLanguage", AS11->second.PrimaryAudioLanguage); //(*Stream_More)[Stream_Other][StreamPos_Last](Ztring().From_Local("PrimaryAudioLanguage"), Info_Options)=__T("N NT"); //if (MediaInfoLib::Config.Iso639_Find(AS11->second.PrimaryAudioLanguage).empty()) // Fill(Stream_Other, StreamPos_Last, "PrimaryAudioLanguage/String", MediaInfoLib::Config.Iso639_Translate(AS11->second.PrimaryAudioLanguage)); if (AS11->second.ClosedCaptionsPresent<2) Fill(Stream_Other, StreamPos_Last, "ClosedCaptionsPresent", AS11->second.ClosedCaptionsPresent?"Yes":"No"); if (AS11->second.ClosedCaptionsTypesecond.ClosedCaptionsType]); Fill(Stream_Other, StreamPos_Last, "ClosedCaptionsLanguage", AS11->second.ClosedCaptionsLanguage); break; case as11::Type_Segmentation: Fill(Stream_Other, StreamPos_Last, "Format", "AS-11 Segmentation", Unlimited, true, true); if (AS11->second.PartNumber!=(int16u)-1 && AS11->second.PartTotal!=(int16u)-1) { string S; S+=TimeCode(TC_Temp+Duration_CurrentPos, FrameRate_TempI, DropFrame_Temp).ToString(); if (DMSegment->second.Duration!=(int64u)-1) { S+=" + "; S+=TimeCode(DMSegment->second.Duration, FrameRate_TempI, DropFrame_Temp).ToString(); S+=" = "; Duration_CurrentPos+=DMSegment->second.Duration; S+=TimeCode(TC_Temp+Duration_CurrentPos, FrameRate_TempI, DropFrame_Temp).ToString(); Duration_Programme+=DMSegment->second.Duration; } Fill(Stream_Other, StreamPos_Last, Ztring::ToZtring(AS11->second.PartNumber).To_UTF8().c_str(), S); } break; case as11::Type_UKDPP: Fill(Stream_Other, StreamPos_Last, "Format", "AS-11 UKDPP"); Fill(Stream_Other, StreamPos_Last, "ProductionNumber", AS11->second.ProductionNumber); Fill(Stream_Other, StreamPos_Last, "Synopsis", AS11->second.Synopsis); Fill(Stream_Other, StreamPos_Last, "Originator", AS11->second.Originator); if (AS11->second.CopyrightYear!=(int16u)-1) Fill(Stream_Other, StreamPos_Last, "CopyrightYear", AS11->second.CopyrightYear); Fill(Stream_Other, StreamPos_Last, "OtherIdentifier", AS11->second.OtherIdentifier); Fill(Stream_Other, StreamPos_Last, "OtherIdentifierType", AS11->second.OtherIdentifierType); Fill(Stream_Other, StreamPos_Last, "Genre", AS11->second.Genre); Fill(Stream_Other, StreamPos_Last, "Distributor", AS11->second.Distributor); Fill(Stream_Other, StreamPos_Last, "PictureRatio", Ztring::ToZtring(AS11->second.PictureRatio_N)+__T(':')+Ztring::ToZtring(AS11->second.PictureRatio_D)); if (AS11->second.ThreeD!=(int8u)-1) Fill(Stream_Other, StreamPos_Last, "3D", AS11->second.ThreeD?__T("Yes"):__T("No")); if (AS11->second.ThreeDTypesecond.ThreeDType]); if (AS11->second.ProductPlacement!=(int8u)-1) Fill(Stream_Other, StreamPos_Last, "ProductPlacement", AS11->second.ProductPlacement?__T("Yes"):__T("No")); if (AS11->second.ThreeDTypesecond.FpaPass]); Fill(Stream_Other, StreamPos_Last, "FpaManufacturer", AS11->second.FpaManufacturer); Fill(Stream_Other, StreamPos_Last, "FpaVersion", AS11->second.FpaVersion); Fill(Stream_Other, StreamPos_Last, "VideoComments", AS11->second.VideoComments); if (AS11->second.SecondaryAudioLanguage!=__T("zxx")) Fill(Stream_Other, StreamPos_Last, "SecondaryAudioLanguage", AS11->second.SecondaryAudioLanguage); if (AS11->second.TertiaryAudioLanguage!=__T("zxx")) Fill(Stream_Other, StreamPos_Last, "TertiaryAudioLanguage", AS11->second.TertiaryAudioLanguage); if (AS11->second.AudioLoudnessStandardsecond.AudioLoudnessStandard]); Fill(Stream_Other, StreamPos_Last, "AudioComments", AS11->second.AudioComments); if (AS11->second.LineUpStart!=(int64u)-1) Fill(Stream_Other, StreamPos_Last, "LineUpStart", Ztring().From_UTF8(TimeCode(TC_Temp+AS11->second.LineUpStart, FrameRate_TempI, DropFrame_Temp).ToString())); if (AS11->second.IdentClockStart!=(int64u)-1) Fill(Stream_Other, StreamPos_Last, "IdentClockStart", Ztring().From_UTF8(TimeCode(TC_Temp+AS11->second.IdentClockStart, FrameRate_TempI, DropFrame_Temp).ToString())); if (AS11->second.TotalNumberOfParts!=(int16u)-1) Fill(Stream_Other, StreamPos_Last, "TotalNumberOfParts", AS11->second.TotalNumberOfParts); if (AS11->second.TotalProgrammeDuration!=(int64u)-1) Fill(Stream_Other, StreamPos_Last, "TotalProgrammeDuration", Ztring().From_UTF8(TimeCode(AS11->second.TotalProgrammeDuration, FrameRate_TempI, DropFrame_Temp).ToString())); if (AS11->second.AudioDescriptionPresent!=(int8u)-1) Fill(Stream_Other, StreamPos_Last, "AudioDescriptionPresent", AS11->second.AudioDescriptionPresent?__T("Yes"):__T("No")); if (AS11->second.AudioDescriptionTypesecond.AudioDescriptionType]); if (AS11->second.OpenCaptionsPresent!=(int8u)-1) Fill(Stream_Other, StreamPos_Last, "OpenCaptionsPresent", AS11->second.OpenCaptionsPresent?__T("Yes"):__T("No")); if (AS11->second.OpenCaptionsTypesecond.OpenCaptionsType]); Fill(Stream_Other, StreamPos_Last, "OpenCaptionsLanguage", AS11->second.OpenCaptionsLanguage); if (AS11->second.SigningPresentsecond.SigningPresent]); if (AS11->second.SignLanguagesecond.SignLanguage]); //if (AS11->second.CompletionDate!=(int64u)-1) // Fill(Stream_Other, StreamPos_Last, "CompletionDate", Ztring::ToZtring(AS11->second.CompletionDate)+__T(" (TODO: Timestamp translation)")); //TODO: Timestamp if (AS11->second.TextlessElementsExist!=(int8u)-1) Fill(Stream_Other, StreamPos_Last, "TextlessElementsExist", AS11->second.TextlessElementsExist?__T("Yes"):__T("No")); if (AS11->second.ProgrammeHasText!=(int8u)-1) Fill(Stream_Other, StreamPos_Last, "ProgrammeHasText", AS11->second.ProgrammeHasText?__T("Yes"):__T("No")); Fill(Stream_Other, StreamPos_Last, "ProgrammeTextLanguage", AS11->second.ProgrammeTextLanguage); Fill(Stream_Other, StreamPos_Last, "ContactEmail", AS11->second.ContactEmail); Fill(Stream_Other, StreamPos_Last, "ContactTelephoneNumber", AS11->second.ContactTelephoneNumber); break; default: ; } } else if (DMSegment->second.IsAs11SegmentFiller && DMSegment->second.Duration!=(int64u)-1) Duration_CurrentPos+=DMSegment->second.Duration; } } if (Duration_Programme) Fill(Stream_Other, StreamPos_Last, "TotalProgrammeDuration", TimeCode(Duration_Programme, FrameRate_TempI, DropFrame_Temp).ToString()); } //--------------------------------------------------------------------------- void File_Mxf::Streams_Finish_Identification (const int128u IdentificationUID) { identifications::iterator Identification=Identifications.find(IdentificationUID); if (Identification==Identifications.end()) return; //Product part Ztring Encoded_Application_Version=Identification->second.ProductVersion.empty()?Identification->second.VersionString:Identification->second.ProductVersion; Ztring Encoded_Application_ProductName(Identification->second.ProductName); if (!Identification->second.CompanyName.empty() && Identification->second.CompanyName.size()second.CompanyName.size()); if (Identification->second.CompanyName.Compare(ProductName_Begin) && Encoded_Application_ProductName[Identification->second.CompanyName.size()]==__T(' ')) Encoded_Application_ProductName.erase(0, Identification->second.CompanyName.size()+1); } size_t Encoded_Application_ProductName_Pos = Encoded_Application_ProductName.find_last_of(__T(' ')); if (Encoded_Application_ProductName_Pos!=string::npos) { Ztring Encoded_Application_ProductName_End(Encoded_Application_ProductName.c_str()+Encoded_Application_ProductName_Pos+1); if (Encoded_Application_Version.find(Encoded_Application_ProductName_End)==0) Encoded_Application_ProductName.resize(Encoded_Application_ProductName_Pos); //Removing version number from the name (format not conform) } Fill(Stream_General, 0, General_Encoded_Application_CompanyName, Identification->second.CompanyName, true); Fill(Stream_General, 0, General_Encoded_Application_Name, Encoded_Application_ProductName, true); Fill(Stream_General, 0, General_Encoded_Application_Version, Encoded_Application_Version, true); //Platform part Ztring Library_Name(Identification->second.Platform); size_t Library_Name_Pos = Library_Name.find_last_of(__T(' ')); if (Library_Name_Pos!=string::npos) { Ztring Library_Name_End(Library_Name.c_str()+Library_Name_Pos+1); if (Identification->second.ToolkitVersion.find(Library_Name_End)==0) Library_Name.resize(Library_Name_Pos); //Removing version number from the name (format not conform) } Fill(Stream_General, 0, General_Encoded_Library_Name, Library_Name, true); Fill(Stream_General, 0, General_Encoded_Library_Version, Identification->second.ToolkitVersion, true); for (std::map::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 //Config TimeCodeFromMaterialPackage=Config->File_Mxf_TimeCodeFromMaterialPackage_Get(); } //--------------------------------------------------------------------------- void File_Mxf::Read_Buffer_Continue() { #if MEDIAINFO_DEMUX if (Demux_CurrentParser) { if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded--; Open_Buffer_Continue(Demux_CurrentParser, Buffer+Buffer_Offset, 0, false); if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; if (Config->Demux_EventWasSent) return; switch (Demux_CurrentParser->Field_Count_InThisBlock) { case 1 : Demux_CurrentEssence->second.Field_Count_InThisBlock_1++; break; case 2 : Demux_CurrentEssence->second.Field_Count_InThisBlock_2++; break; default: ; } if (Demux_CurrentParser->Buffer_Size) Demux_CurrentParser=NULL; //No more need of it } #endif //MEDIAINFO_DEMUX if (!IsSub) { if (Config->ParseSpeed>=1.0) { bool Buffer_End_IsUpdated=false; if (Config->File_IsGrowing && !Config->File_IsNotGrowingAnymore) { File F; F.Open(File_Name); std::vector SearchingPartitionPack(65536); size_t SearchingPartitionPack_Size=F.Read(&SearchingPartitionPack[0], SearchingPartitionPack.size()); for (size_t Pos=0; Pos+16File_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); Fill(Stream_General, 0, General_StreamSize, MI.Get(Stream_General, 0, General_StreamSize), true); if (Buffer_End_Unlimited) { Buffer_End=MI.Get(Stream_General, 0, General_FileSize).To_int64u()-MI.Get(Stream_General, 0, General_FooterSize).To_int64u(); Buffer_End_IsUpdated=true; } if (!Config->File_IsReferenced_Get() && ReferenceFiles && Retrieve(Stream_General, 0, General_StreamSize).To_int64u()) { //Playlist file size is not correctly modified Config->File_Size-=File_Size; File_Size=Retrieve(Stream_General, 0, General_StreamSize).To_int64u(); Config->File_Size+=File_Size; } } } break; default : ; } } if (Buffer_End && Buffer_End_Unlimited && !Buffer_End_IsUpdated) Buffer_End=Config->File_Size; //Updating Clip end in case the } Config->State_Set(((float)Buffer_TotalBytes)/Config->File_Size); } } if (IsSearchingFooterPartitionAddress) { if (File_Offset+Buffer_Size=Buffer) { while (B_Cur06>=Buffer) { if (*B_Cur06==0x06) break; B_Cur06--; } if (B_Cur06Buffer_Size) { Element_WaitForMoreData(); return; } IsCheckingFooterPartitionAddress=false; const int8u* B_Cur=Buffer+Buffer_Offset; if (*(B_Cur++)==0x06 && *(B_Cur++)==0x0E && *(B_Cur++)==0x2B && *(B_Cur++)==0x34 && *(B_Cur++)==0x02 && *(B_Cur++)==0x05 && *(B_Cur++)==0x01 && *(B_Cur++)==0x01 && *(B_Cur++)==0x0D && *(B_Cur++)==0x01 && *(B_Cur++)==0x02 && *(B_Cur++)==0x01 && *(B_Cur++)==0x01 && *(B_Cur++)==0x04) { int64u Size=*(B_Cur++); if (Size >= 0x80) { Size&=0x7F; if (17+Size>Buffer_Size) { if (File_Offset+17+SizeBuffer_Size) { Element_WaitForMoreData(); return; } IsCheckingRandomAccessTable=false; if (CC4(Buffer+Buffer_Offset)!=0x060E2B34 || CC3(Buffer+Buffer_Offset+4)!=0x020501 || CC3(Buffer+Buffer_Offset+8)!=0x0D0102 || CC1(Buffer+Buffer_Offset+12)!=0x01) // Checker if it is a Partition { if (File_Size>=64*1024) { IsSearchingFooterPartitionAddress=true; GoToFromEnd(64*1024); // Wrong offset, searching from end of file } else TryToFinish(); return; } } 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=64*1024) { IsSearchingFooterPartitionAddress=true; GoToFromEnd(64*1024); // Wrong offset, searching from end of file } else TryToFinish(); return; } } } //--------------------------------------------------------------------------- void File_Mxf::Read_Buffer_AfterParsing() { if (File_GoTo==(int64u)-1 && File_Offset+Buffer_Offset>=IsParsingMiddle_MaxOffset) { Fill(); Open_Buffer_Unsynch(); Finish(); return; } if (File_Offset+Buffer_Size>=File_Size) { if (Partitions_IsCalculatingHeaderByteCount) { Partitions_IsCalculatingHeaderByteCount=false; if (Partitions_Pos=Buffer_End //Too much late || File_GoTo<=Buffer_Begin) //Too much early { Buffer_Begin=(int64u)-1; Buffer_End=0; Buffer_End_Unlimited=false; Buffer_Header_Size=0; MustSynchronize=true; Synched=false; UnSynched_IsNotJunk=true; } else Synched=true; //Always in clip data } FrameInfo=frame_info(); FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000); Frame_Count_NotParsedIncluded=(int64u)-1; #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK if (!Tracks.empty() && Tracks.begin()->second.EditRate) //TODO: use the corresponding track instead of the first one FrameInfo.DUR=float64_int64s(1000000000/Tracks.begin()->second.EditRate); else if (!IndexTables.empty() && IndexTables[0].IndexEditRate) FrameInfo.DUR=float64_int64s(1000000000/IndexTables[0].IndexEditRate); //Calculating the byte count not included in seek information (partition, index...) int64u FutureFileOffset=File_GoTo==(int64u)-1?(File_Offset+Buffer_Offset):File_GoTo; int64u StreamOffset_Offset=0; Partitions_Pos=0; while (Partitions_Possecond.StreamKind==Stream_Text) Frame_Count_NotParsedIncluded=0; 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; if (FutureFileOffset>(StreamOffset_Offset+Buffer_Header_Size)) Frame_Count_NotParsedIncluded_Precise=(FutureFileOffset-(StreamOffset_Offset+Buffer_Header_Size))/BytePerFrame; //In case of audio at frame rate not an integer else Frame_Count_NotParsedIncluded_Precise=0; Frame_Count_NotParsedIncluded=float64_int64s(Frame_Count_NotParsedIncluded_Precise); FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Frame_Count_NotParsedIncluded_Precise)*1000000000/Descriptors.begin()->second.SampleRate); FrameInfo.PTS=FrameInfo.DTS; if (!Tracks.empty() && Tracks.begin()->second.EditRate) //TODO: use the corresponding track instead of the first one FrameInfo.DUR=float64_int64s(1000000000/Tracks.begin()->second.EditRate); else if (!IndexTables.empty() && IndexTables[0].IndexEditRate) FrameInfo.DUR=float64_int64s(1000000000/IndexTables[0].IndexEditRate); else FrameInfo.DUR=float64_int64s(1000000000/Descriptors.begin()->second.SampleRate); Demux_random_access=true; } else if (!IndexTables.empty() && IndexTables[0].EditUnitByteCount) { int64u Position=0; Frame_Count_NotParsedIncluded=0; for (size_t Pos=0; Pos=((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; Frame_Count_NotParsedIncluded+=IndexTables[Pos].IndexDuration; } else { int64u FramesToAdd; if (FutureFileOffset>((Buffer_End?Buffer_Begin:(StreamOffset_Offset+Buffer_Header_Size))+Position)) FramesToAdd=(FutureFileOffset-((Buffer_End?Buffer_Begin:(StreamOffset_Offset+Buffer_Header_Size))+Position))/IndexTables[Pos].EditUnitByteCount; else FramesToAdd=0; 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; Frame_Count_NotParsedIncluded+=float64_int64s(((float64)FramesToAdd)/IndexTables[Pos].IndexEditRate*Descriptors.begin()->second.SampleRate); FrameInfo.PTS=FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Frame_Count_NotParsedIncluded_Precise)*1000000000/Descriptors.begin()->second.SampleRate); } else { Frame_Count_NotParsedIncluded+=FramesToAdd; FrameInfo.PTS=FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Frame_Count_NotParsedIncluded)*1000000000/IndexTables[Pos].IndexEditRate); } } else FrameInfo.PTS=FrameInfo.DTS=(int64u)-1; Demux_random_access=true; break; } } } else if (!IndexTables.empty() && !IndexTables[0].Entries.empty()) { int64u StreamOffset; if (StreamOffset_Offset=IndexTables[Pos].Entries[0].StreamOffset+(IndexTables[Pos].IndexStartPosition)*SDTI_SizePerFrame && (Pos+1>=IndexTables.size() || IndexTables[Pos+1].Entries.empty() || StreamOffsetEntry_StreamOffset || Entry_StreamOffset>Entry1_StreamOffset) break; //Problem if (StreamOffset>=Entry_StreamOffset && StreamOffsetsecond.SampleRate) FrameInfo.PTS=FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Frame_Count_NotParsedIncluded)*1000000000/Descriptors.begin()->second.SampleRate); } else if (Frame_Count_NotParsedIncluded==0) { FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000); } #endif //if MEDIAINFO_DEMUX || MEDIAINFO_SEEK if (!Tracks.empty() && Tracks.begin()->second.EditRate) //TODO: use the corresponding track instead of the first one FrameInfo.DUR=float64_int64s(1000000000/Tracks.begin()->second.EditRate); #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK else if (!IndexTables.empty() && IndexTables[0].IndexEditRate) FrameInfo.DUR=float64_int64s(1000000000/IndexTables[0].IndexEditRate); #endif //if MEDIAINFO_DEMUX || MEDIAINFO_SEEK for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); ++Essence) for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) { (*Parser)->Open_Buffer_Unsynch(); Essence->second.FrameInfo=FrameInfo; Essence->second.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded; } Partitions_Pos=0; if (Partitions_IsCalculatingHeaderByteCount) { Partitions.erase(Partitions.end()-1); Partitions_IsCalculatingHeaderByteCount=false; } if (Partitions_IsCalculatingSdtiByteCount) Partitions_IsCalculatingSdtiByteCount=false; #if MEDIAINFO_SEEK IndexTables_Pos=0; #endif //MEDIAINFO_SEEK } //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK bool File_Mxf::DetectDuration () { if (Duration_Detected) return false; MediaInfo_Internal MI; MI.Option(__T("File_IsDetectingDuration"), __T("1")); 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()); MI.Option(__T("File_Mxf_ParseIndex"), __T("1")); 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 false; 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; Tracks=((File_Mxf*)MI.Info)->Tracks; //In one file (*-009.mxf), the TrackNumber is known only at the end of the file (Open and incomplete header/footer) for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) Track->second.Stream_Finish_Done=false; //Reseting the value, it is not done in this instance 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; return true; } #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK #if MEDIAINFO_SEEK size_t File_Mxf::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { #if defined(MEDIAINFO_REFERENCES_YES) if (ReferenceFiles) return ReferenceFiles->Seek(Method, Value, ID); #endif //defined(MEDIAINFO_REFERENCES_YES) //Init if (!Duration_Detected) { if (!DetectDuration()) return 0; } //Config - TODO: merge with the one in Data_Parse() if (!Essences_FirstEssence_Parsed) { //Searching single descriptor if it is the only valid descriptor descriptors::iterator SingleDescriptor=Descriptors.end(); for (descriptors::iterator SingleDescriptor_Temp=Descriptors.begin(); SingleDescriptor_Temp!=Descriptors.end(); ++SingleDescriptor_Temp) if (SingleDescriptor_Temp->second.StreamKind!=Stream_Max) { if (SingleDescriptor!=Descriptors.end()) { SingleDescriptor=Descriptors.end(); break; // 2 or more descriptors, can not be used } SingleDescriptor=SingleDescriptor_Temp; } if (SingleDescriptor!=Descriptors.end() && SingleDescriptor->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; } } for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); ++Descriptor) { //Configuring EditRate if needed (e.g. audio at 48000 Hz) if (Descriptor->second.SampleRate>1000) { float64 EditRate_FromTrack=DBL_MAX; for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (Track->second.EditRate && EditRate_FromTrack>Track->second.EditRate) EditRate_FromTrack=Track->second.EditRate; if (EditRate_FromTrack>1000) EditRate_FromTrack=Demux_Rate; //Default value; Descriptor->second.SampleRate=EditRate_FromTrack; for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (Track->second.EditRate>EditRate_FromTrack) { Track->second.EditRate_Real=Track->second.EditRate; Track->second.EditRate=EditRate_FromTrack; } } } Essences_FirstEssence_Parsed=true; } //Parsing switch (Method) { case 0 : { if (Config->File_IgnoreEditsBefore && Config->File_EditRate) { Read_Buffer_Seek(3, 0, (int64u)-1); if (File_GoTo!=(int64u)-1) Value+=File_GoTo; } //Calculating the byte count not included in seek information (partition, index...) Partitions_Pos=0; while (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 && Valuesecond.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; Possecond.SampleRate) break; if (Descriptor==Descriptors.end()) return (size_t)-1; //Not supported else if (MxfTimeCodeForDelay.StartTimecode!=(int64u)-1) { int64u Delay=float64_int64s(DTS_Delay*1000000000); if (Valuesecond.SampleRate); } //No break; case 3 : //FrameNumber Value+=Config->File_IgnoreEditsBefore; if (Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1 && Descriptors.begin()->second.BlockAlign && Descriptors.begin()->second.BlockAlign!=(int16u)-1 && Descriptors.begin()->second.SampleRate) { if (Descriptors.begin()->second.SampleRate!=Config->File_EditRate && Config->File_IgnoreEditsBefore) { //Edit rate and Demux rate are different, not well supported for the moment Value-=Config->File_IgnoreEditsBefore; Value+=float64_int64s(((float64)Config->File_IgnoreEditsBefore)/Config->File_EditRate*Descriptors.begin()->second.SampleRate); } 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_Possecond.Parsers.size()==1 && (*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer) { (*(Essences.begin()->second.Parsers.begin()))->Demux_Level=2; //Container (*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer=true; } #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; PosIndexTables[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_Possecond.Parsers.size()==1 && (*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer) { (*(Essences.begin()->second.Parsers.begin()))->Demux_Level=2; //Container (*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer=true; } #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[Pos].IndexStartPosition && Value=IndexTables[Pos].IndexStartPosition && IndexTables[Pos].Entries[(size_t)(Value-IndexTables[Pos].IndexStartPosition)].Type) { Value--; if (Valuesecond.Parsers.size()==1 && (*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer) { (*(Essences.begin()->second.Parsers.begin()))->Demux_Level=2; //Container (*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer=true; } #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() { //Element_Size if (Buffer_Size<0x18) return false; //Must wait for more data //AAF has some MXF start codes if (Buffer[ 0x0]==0xD0 && Buffer[ 0x1]==0xCF && Buffer[ 0x2]==0x11 && Buffer[ 0x3]==0xE0 && Buffer[ 0x4]==0xA1 && Buffer[ 0x5]==0xB1 && Buffer[ 0x6]==0x1A && Buffer[ 0x7]==0xE1 && Buffer[ 0x8]==0x41 && Buffer[ 0x9]==0x41 && Buffer[ 0xA]==0x46 && Buffer[ 0xB]==0x42 && Buffer[ 0xC]==0x0D && Buffer[ 0xD]==0x00 && Buffer[ 0xE]==0x4F && Buffer[ 0xF]==0x4D && Buffer[0x10]==0x06 && Buffer[0x11]==0x0E && Buffer[0x12]==0x2B && Buffer[0x13]==0x34 && Buffer[0x14]==0x01 && Buffer[0x15]==0x01 && Buffer[0x16]==0x01 && Buffer[0x17]==0xFF) { Reject("Mxf"); return false; } //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_OffsetBuffer_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(); } //Synched is OK return true; } //--------------------------------------------------------------------------- bool File_Mxf::Synched_Test() { //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 //Searching single descriptor if it is the only valid descriptor descriptors::iterator SingleDescriptor=Descriptors.end(); for (descriptors::iterator SingleDescriptor_Temp=Descriptors.begin(); SingleDescriptor_Temp!=Descriptors.end(); ++SingleDescriptor_Temp) if (SingleDescriptor_Temp->second.StreamKind!=Stream_Max) { if (SingleDescriptor!=Descriptors.end()) { SingleDescriptor=Descriptors.end(); break; // 2 or more descriptors, can not be used } SingleDescriptor=SingleDescriptor_Temp; } if (Demux_UnpacketizeContainer && SingleDescriptor!=Descriptors.end() && SingleDescriptor->second.ByteRate!=(int32u)-1 && SingleDescriptor->second.BlockAlign && SingleDescriptor->second.BlockAlign!=(int16u)-1 && SingleDescriptor->second.SampleRate) { float64 BytesPerFrame=((float64)SingleDescriptor->second.ByteRate)/SingleDescriptor->second.SampleRate; int64u FramesAlreadyParsed=float64_int64s(((float64)(File_Offset+Buffer_Offset-Buffer_Begin))/BytesPerFrame); Element_Size=float64_int64s(SingleDescriptor->second.ByteRate/SingleDescriptor->second.SampleRate*(FramesAlreadyParsed+1)); #if MEDIAINFO_DEMUX Element_Size+=DemuxedElementSize_AddedToFirstFrame; #endif //MEDIAINFO_DEMUX Element_Size/=SingleDescriptor->second.BlockAlign; Element_Size*=SingleDescriptor->second.BlockAlign; Element_Size-=File_Offset+Buffer_Offset-Buffer_Begin; if (Config->File_IsGrowing && Element_Size && File_Offset+Buffer_Offset+Element_Size>Buffer_End) return false; //Waiting for more data while (Element_Size && File_Offset+Buffer_Offset+Element_Size>Buffer_End) Element_Size-=SingleDescriptor->second.BlockAlign; if (Element_Size==0) Element_Size=Buffer_End-(File_Offset+Buffer_Offset); if (Buffer_Offset+Element_Size>Buffer_Size) return false; #if MEDIAINFO_DEMUX if (!DemuxedSampleCount_Total && Config->Demux_Offset_DTS!=(int64u)-1 && Config->File_EditRate) { //Need to sync to a rounded value compared to the whole stream (including previous files) float64 TimeStamp=((float64)Config->Demux_Offset_DTS)/1000000000; int64u FramesBeForeThisFileMinusOne=(int64u)(TimeStamp*SingleDescriptor->second.SampleRate); if ((((float64)FramesBeForeThisFileMinusOne)/SingleDescriptor->second.SampleRate)!=TimeStamp) { float64 Delta=(((float64)FramesBeForeThisFileMinusOne+1)/SingleDescriptor->second.SampleRate)-TimeStamp; DemuxedSampleCount_AddedToFirstFrame=float64_int64s(Delta*Config->File_EditRate); DemuxedElementSize_AddedToFirstFrame=DemuxedSampleCount_AddedToFirstFrame*SingleDescriptor->second.BlockAlign; Element_Size+=DemuxedElementSize_AddedToFirstFrame; } } if (DemuxedSampleCount_Total!=(int64u)-1 && Config->File_IgnoreEditsAfter!=(int64u)-1) { DemuxedSampleCount_Current=Element_Size/SingleDescriptor->second.BlockAlign; int64u RealSampleRate=SingleDescriptor->second.Infos["SamplingRate"].To_int64u(); int64u IgnoreSamplesAfter; if (RealSampleRate==Config->File_EditRate) IgnoreSamplesAfter=Config->File_IgnoreEditsAfter; else IgnoreSamplesAfter=float64_int64s(((float64)Config->File_IgnoreEditsAfter)/Config->File_EditRate*RealSampleRate); if (DemuxedSampleCount_Total+DemuxedSampleCount_Current>IgnoreSamplesAfter) { DemuxedSampleCount_Current=Config->File_IgnoreEditsAfter-DemuxedSampleCount_Total; Element_Size=DemuxedSampleCount_Current*SingleDescriptor->second.BlockAlign; } } #endif //MEDIAINFO_DEMUX } 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=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 (Buffer_Size_Target<128*1024) Buffer_Size_Target=128*1024; //if ((*File_Buffer_Size_Hint_Pointer)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=IndexTables[Pos].Entries[0].StreamOffset+(IndexTables[Pos].IndexStartPosition)*SDTI_SizePerFrame && (Pos+1>=IndexTables.size() || StreamOffsetEntry_StreamOffset || Entry_StreamOffset>Entry1_StreamOffset) break; //Problem if (StreamOffset>=Entry_StreamOffset && StreamOffsetBuffer_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 (Buffer_Size_Target<128*1024) Buffer_Size_Target=128*1024; //if ((*File_Buffer_Size_Hint_Pointer)=Buffer_End || File_GoTo!=(int64u)-1) ) { Buffer_Begin=(int64u)-1; Buffer_End=0; Buffer_End_Unlimited=false; Buffer_Header_Size=0; MustSynchronize=true; } 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"); if (Element_IsWaitingForMoreData()) return; if (Length==0 && ((int32u)Code.hi)==Elements::GenericContainer_Aaf2 && (((int32u)(Code.lo>>32))==Elements::GenericContainer_Aaf3 || ((int32u)(Code.lo>>32))==Elements::GenericContainer_Avid3) && Retrieve(Stream_General, 0, General_Format_Settings).find(__T(" / Incomplete"))!=string::npos ) { if (Buffer_Offset+Element_Offset+4>Buffer_Size) { Element_WaitForMoreData(); return; } if (BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset)!=0x060E2B34) { Buffer_End_Unlimited=true; Length=File_Size-(File_Offset+Buffer_Offset+Element_Offset); } } if (Config->File_IsGrowing && File_Offset+Buffer_Offset+Element_Offset+Length>File_Size) { Element_WaitForMoreData(); return; } if (Length==0 && Essences.empty() && Retrieve(Stream_General, 0, General_Format_Settings).find(__T(" / Incomplete"))!=string::npos) { if (Buffer_Offset+Element_Offset+4>Buffer_Size) { Element_WaitForMoreData(); return; } if (BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset)!=0x060E2B34) { Buffer_End_Unlimited=true; Length=File_Size-(File_Offset+Buffer_Offset+Element_Offset); } } if (Config->File_IsGrowing && File_Offset+Buffer_Offset+Element_Offset+Length>File_Size) { Element_WaitForMoreData(); return; } //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 (Code_Compare1==Elements::Filler011 && (Code_Compare2&0xFFFFFF00)==(Elements::Filler012&0xFFFFFF00) && Code_Compare3==Elements::Filler013) DataMustAlwaysBeComplete=false; if (Partitions_IsCalculatingHeaderByteCount) { if (!(Code_Compare1==Elements::Filler011 && (Code_Compare2&0xFFFFFF00)==(Elements::Filler012&0xFFFFFF00) && Code_Compare3==Elements::Filler013)) { Partitions_IsCalculatingHeaderByteCount=false; if (Partitions_PosFile_IgnoreEditsBefore && !Config->File_IsDetectingDuration_Get() && Config->Event_CallBackFunction_IsSet()) //Only if demux packet may be requested Open_Buffer_Seek(3, 0, (int64u)-1); //Forcing seek to Config->File_IgnoreEditsBefore 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 (Buffer_Offset+Element_Offset+Length>(size_t)-1 || Buffer_Offset+(size_t)(Element_Offset+Length)>Buffer_Size) //Not complete { 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>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_Offsetsecond.StreamKind!=Stream_Max) { if (SingleDescriptor!=Descriptors.end()) { SingleDescriptor=Descriptors.end(); break; // 2 or more descriptors, can not be used } SingleDescriptor=SingleDescriptor_Temp; } if (SingleDescriptor!=Descriptors.end() && SingleDescriptor->second.StreamKind==Stream_Audio) { //Configuring bitrate is not available in descriptor if (SingleDescriptor->second.ByteRate==(int32u)-1 && SingleDescriptor->second.Infos.find("SamplingRate")!=SingleDescriptor->second.Infos.end()) { int32u SamplingRate=SingleDescriptor->second.Infos["SamplingRate"].To_int32u(); if (SingleDescriptor->second.BlockAlign!=(int16u)-1) SingleDescriptor->second.ByteRate=SamplingRate*SingleDescriptor->second.BlockAlign; else if (SingleDescriptor->second.QuantizationBits!=(int8u)-1) SingleDescriptor->second.ByteRate=SamplingRate*SingleDescriptor->second.QuantizationBits/8; } } for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); ++Descriptor) { //Configuring EditRate if needed (e.g. audio at 48000 Hz) if (Descriptor->second.SampleRate>1000) { float64 EditRate_FromTrack=DBL_MAX; for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (Track->second.EditRate && EditRate_FromTrack>Track->second.EditRate) EditRate_FromTrack=Track->second.EditRate; if (EditRate_FromTrack>1000) EditRate_FromTrack=Demux_Rate; //Default value; Descriptor->second.SampleRate=EditRate_FromTrack; DemuxedSampleCount_Total=Config->File_IgnoreEditsBefore; for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (Track->second.EditRate>EditRate_FromTrack) { Track->second.EditRate_Real=Track->second.EditRate; Track->second.EditRate=EditRate_FromTrack; } } } #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK Essences_FirstEssence_Parsed=true; } if (IsParsingEnd) { NextRandomIndexMetadata(); return; } essences::iterator Essence=Essences.find(Code_Compare4); if (Essence==Essences.end()) Essence=Essences.insert(make_pair(Code_Compare4,essence())).first; if (Essence->second.Parsers.empty()) { //Searching single descriptor if it is the only valid descriptor descriptors::iterator SingleDescriptor=Descriptors.end(); for (descriptors::iterator SingleDescriptor_Temp=Descriptors.begin(); SingleDescriptor_Temp!=Descriptors.end(); ++SingleDescriptor_Temp) if (SingleDescriptor_Temp->second.StreamKind!=Stream_Max || SingleDescriptor_Temp->second.LinkedTrackID!=(int32u)-1) { if (SingleDescriptor!=Descriptors.end()) { SingleDescriptor=Descriptors.end(); break; // 2 or more descriptors, can not be used } SingleDescriptor=SingleDescriptor_Temp; } //Format_Settings_Wrapping if (SingleDescriptor!=Descriptors.end() && (SingleDescriptor->second.Infos.find("Format_Settings_Wrapping")==SingleDescriptor->second.Infos.end() || SingleDescriptor->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. SingleDescriptor->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; #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK if (Essence->second.TrackID==(int32u)-1 && !Duration_Detected && !Config->File_IsDetectingDuration_Get()) { DetectDuration(); //In one file (*-009.mxf), the TrackNumber is known only at the end of the file (Open and incomplete header/footer) for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); ++Track) if (Track->second.TrackNumber==Code_Compare4) Essence->second.TrackID=Track->second.TrackID; } #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK // Fallback in case TrackID is not detected, forcing TrackID and TrackNumber if (Essence->second.TrackID==(int32u)-1 && SingleDescriptor!=Descriptors.end()) { Essence->second.TrackID=SingleDescriptor->second.LinkedTrackID; prefaces::iterator Preface=Prefaces.find(Preface_Current); if (Preface!=Prefaces.end()) { contentstorages::iterator ContentStorage=ContentStorages.find(Preface->second.ContentStorage); if (ContentStorage!=ContentStorages.end()) { for (size_t Pos=0; Possecond.Packages.size(); Pos++) { packages::iterator Package=Packages.find(ContentStorage->second.Packages[Pos]); if (Package!=Packages.end() && Package->second.IsSourcePackage) { for (size_t Pos=0; Possecond.Tracks.size(); Pos++) { tracks::iterator Track=Tracks.find(Package->second.Tracks[Pos]); if (Track!=Tracks.end()) { if (Track->second.TrackNumber==0 && Track->second.TrackID==Essence->second.TrackID) { Track->second.TrackNumber=Essence->first; Essence->second.Track_Number_IsMappedToTrack=true; } } } } } } } } Essence->second.TrackID_WasLookedFor=true; } //Searching the corresponding Descriptor bool DescriptorFound=false; for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); ++Descriptor) if (Descriptor==SingleDescriptor || (Descriptor->second.LinkedTrackID==Essence->second.TrackID && Descriptor->second.LinkedTrackID!=(int32u)-1)) { DescriptorFound=true; Essence->second.StreamPos_Initial=Essence->second.StreamPos=Code_Compare4&0x000000FF; 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"); } ChooseParser(Essence, Descriptor); //Searching by the descriptor if (Essence->second.Parsers.empty()) 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.Parsers.begin())))->FrameRate=Descriptor->second.SampleRate; #endif //MEDIAINFO_VC3_YES break; } if (!DescriptorFound) Streams_Count++; //This stream was not yet counted //Searching by the track identifier if (Essence->second.Parsers.empty()) ChooseParser__FromEssence(Essence, Descriptors.end()); //Check of Essence used as a reference for frame count if (Essences_UsedForFrameCount==(int32u)-1) Essences_UsedForFrameCount=Essence->first; //Demux #if MEDIAINFO_DEMUX //Configuration if (!IsSub) //Updating for MXF only if MXF is not embedded in another container { Essence->second.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded; if (Essence->second.Frame_Count_NotParsedIncluded!=(int64u)-1 && Essence->second.Frame_Count_NotParsedIncluded && Essence->first!=Essences_UsedForFrameCount) Essence->second.Frame_Count_NotParsedIncluded--; //Info is from the first essence parsed, and 1 frame is already parsed Essence->second.FrameInfo.DTS=FrameInfo.DTS; if (Essence->second.FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1 && Frame_Count_NotParsedIncluded && Essence->first!=Essences_UsedForFrameCount) Essence->second.FrameInfo.DTS-=FrameInfo.DUR; //Info is from the first essence parsed, and 1 frame is already parsed 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); else if (!IndexTables.empty() && IndexTables[0].IndexEditRate) Essence->second.FrameInfo.DUR=float64_int64s(1000000000/IndexTables[0].IndexEditRate); #if MEDIAINFO_DEMUX if (Buffer_End && Demux_UnpacketizeContainer && Essences.size()==1 && !Essences.begin()->second.Parsers.empty() && !(*(Essences.begin()->second.Parsers.begin()))->Demux_UnpacketizeContainer) for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) { (*Parser)->Demux_Level=2; //Container (*Parser)->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX } if (Essence->second.TrackID!=(int32u)-1) Element_Code=Essence->second.TrackID; else Element_Code=Code.lo; #endif //MEDIAINFO_DEMUX if (Essence->second.Parsers.empty()) { if (Streams_Count>0) Streams_Count--; } else { Element_Code=Essence->second.TrackID; for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) { Open_Buffer_Init(*Parser); if ((*Parser)->Status[IsFinished]) if (Streams_Count>0) Streams_Count--; } } if ((Code_Compare4&0x000000FF)==0x00000000) StreamPos_StartAtZero.set(Essence->second.StreamKind); //Stream size is sometime easy to find if ((Buffer_End?(Buffer_End-Buffer_Begin):Element_TotalSize_Get())>=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_TotalSize_Get(); } //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) { //Searching single descriptor if it is the only valid descriptor descriptors::iterator SingleDescriptor=Descriptors.end(); for (descriptors::iterator SingleDescriptor_Temp=Descriptors.begin(); SingleDescriptor_Temp!=Descriptors.end(); ++SingleDescriptor_Temp) if (SingleDescriptor_Temp->second.StreamKind!=Stream_Max) { if (SingleDescriptor!=Descriptors.end()) { SingleDescriptor=Descriptors.end(); break; // 2 or more descriptors, can not be used } SingleDescriptor=SingleDescriptor_Temp; } if (SingleDescriptor!=Descriptors.end()) { if (SingleDescriptor->second.ByteRate!=(int32u)-1) for (parsers::iterator Parser=Essence->second.Parsers.begin(); Parser!=Essence->second.Parsers.end(); ++Parser) (*Parser)->Stream_BitRateFromContainer=SingleDescriptor->second.ByteRate*8; else if (SingleDescriptor->second.Infos["Duration"].To_float64()) for (parsers::iterator Parser=Essences.begin()->second.Parsers.begin(); Parser!=Essences.begin()->second.Parsers.end(); ++Parser) (*Parser)->Stream_BitRateFromContainer=((float64)Stream_Size)*8/(SingleDescriptor->second.Infos["Duration"].To_float64()/1000); } } } //Frame info is specific to the container, and it is not updated frame_info FrameInfo_Temp=FrameInfo; int64u Frame_Count_NotParsedIncluded_Temp=Frame_Count_NotParsedIncluded; if (!IsSub) //Updating for MXF only if MXF is not embedded in another container { FrameInfo=frame_info(); Frame_Count_NotParsedIncluded=(int64u)-1; } //Demux #if MEDIAINFO_DEMUX if (Essence->second.TrackID!=(int32u)-1) Element_Code=Essence->second.TrackID; else Element_Code=Code.lo; Demux_Level=(!Essence->second.Parsers.empty() && ((*(Essence->second.Parsers.begin()))->Demux_UnpacketizeContainer || (*(Essence->second.Parsers.begin()))->Demux_Level==2))?4:2; //Intermediate (D-10 Audio) / Container if (!IsSub) //Updating for MXF only if MXF is not embedded in another container { FrameInfo=Essence->second.FrameInfo; Frame_Count_NotParsedIncluded=Essence->second.Frame_Count_NotParsedIncluded; } Demux_random_access=true; Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream); #endif //MEDIAINFO_DEMUX if (!Essence->second.Parsers.empty() && !(*(Essence->second.Parsers.begin()))->Status[IsFinished]) { if ((Code_Compare4&0xFF00FF00)==0x17000100 || (Code_Compare4&0xFF00FF00)==0x17000200) { if (Element_Size) { parsers::iterator Parser=Essence->second.Parsers.begin(); //Ancillary, SMPTE ST 436 int16u Count; Get_B2 (Count, "Number of Lines"); if (Count*14>Element_Size) { (*Parser)->Finish(); Skip_XX(Element_Size-2, "Unknown"); Count=0; } for (int16u Pos=0; Possecond.Frame_Count_NotParsedIncluded!=(int64u)-1) (*Parser)->Frame_Count_NotParsedIncluded=Essence->second.Frame_Count_NotParsedIncluded; if (Essence->second.FrameInfo.DTS!=(int64u)-1) (*Parser)->FrameInfo.DTS=Essence->second.FrameInfo.DTS; if (Essence->second.FrameInfo.PTS!=(int64u)-1) (*Parser)->FrameInfo.PTS=Essence->second.FrameInfo.PTS; if (Essence->second.FrameInfo.DUR!=(int64u)-1) (*Parser)->FrameInfo.DUR=Essence->second.FrameInfo.DUR; #if defined(MEDIAINFO_ANCILLARY_YES) if ((*Parser)->ParserName==__T("Ancillary")) ((File_Ancillary*)(*Parser))->LineNumber=LineNumber; if ((*Parser)->ParserName==__T("Ancillary") && (((File_Ancillary*)(*Parser))->FrameRate==0 || ((File_Ancillary*)(*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*)(*Parser))->HasBFrames=Descriptor->second.HasBFrames; ((File_Ancillary*)(*Parser))->AspectRatio=Descriptor->second.DisplayAspectRatio; ((File_Ancillary*)(*Parser))->FrameRate=Descriptor->second.SampleRate; break; } } #endif //defined(MEDIAINFO_ANCILLARY_YES) int64u Parsing_Size=SampleCount; int64u Array_Size=ArrayCount*ArrayLength; if (Element_Offset+Parsing_Size>Element_Size) Parsing_Size=Element_Size-Element_Offset; // There is a problem if (Parsing_Size>Array_Size) Parsing_Size=Array_Size; // There is a problem (*Parser)->Frame_Count=Frame_Count; (*Parser)->Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded; Open_Buffer_Continue((*Parser), Buffer+Buffer_Offset+(size_t)(Element_Offset), Parsing_Size); if ((Code_Compare4&0xFF00FF00)==0x17000100 && LineNumber==21 && (*Parser)->Count_Get(Stream_Text)==0) { (*Parser)->Accept(); (*Parser)->Stream_Prepare(Stream_Text); (*Parser)->Fill(Stream_Text, StreamPos_Last, Text_Format, "EIA-608"); (*Parser)->Fill(Stream_Text, StreamPos_Last, Text_MuxingMode, "VBI / Line 21"); } Element_Offset+=Parsing_Size; if (Parsing_Sizesecond.Parsers.size(); Pos++) { //Parsing if (IsSub) { if (Frame_Count_NotParsedIncluded!=(int64u)-1) Essence->second.Parsers[Pos]->Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded; if (FrameInfo.DTS!=(int64u)-1) Essence->second.Parsers[Pos]->FrameInfo.DTS=FrameInfo.DTS; if (FrameInfo.PTS!=(int64u)-1) Essence->second.Parsers[Pos]->FrameInfo.PTS=FrameInfo.PTS; if (FrameInfo.DUR!=(int64u)-1) Essence->second.Parsers[Pos]->FrameInfo.DUR=FrameInfo.DUR; } else { if (Essence->second.Frame_Count_NotParsedIncluded!=(int64u)-1) Essence->second.Parsers[Pos]->Frame_Count_NotParsedIncluded=Essence->second.Frame_Count_NotParsedIncluded; if (Essence->second.FrameInfo.DTS!=(int64u)-1) Essence->second.Parsers[Pos]->FrameInfo.DTS=Essence->second.FrameInfo.DTS; if (Essence->second.FrameInfo.PTS!=(int64u)-1) Essence->second.Parsers[Pos]->FrameInfo.PTS=Essence->second.FrameInfo.PTS; if (Essence->second.FrameInfo.DUR!=(int64u)-1) Essence->second.Parsers[Pos]->FrameInfo.DUR=Essence->second.FrameInfo.DUR; } Open_Buffer_Continue(Essence->second.Parsers[Pos], Buffer+Buffer_Offset, (size_t)Element_Size); #if MEDIAINFO_DEMUX if (Demux_Level==4 && Config->Demux_EventWasSent && Essence->second.StreamKind==Stream_Video && Essence->second.Parsers[Pos]->ParserIDs[StreamIDs_Size]==MediaInfo_Parser_Jpeg) // Only File_Jpeg. TODO: limit to File_Jpeg instead of video streams { Demux_CurrentParser=Essence->second.Parsers[Pos]; Demux_CurrentEssence=Essence; } #endif //MEDIAINFO_DEMUX switch (Essence->second.Parsers[Pos]->Field_Count_InThisBlock) { case 1 : Essence->second.Field_Count_InThisBlock_1++; break; case 2 : Essence->second.Field_Count_InThisBlock_2++; break; default: ; } //Multiple parsers if (Essence->second.Parsers.size()>1) { if (!Essence->second.Parsers[Pos]->Status[IsAccepted] && Essence->second.Parsers[Pos]->Status[IsFinished]) { delete *(Essence->second.Parsers.begin()+Pos); Essence->second.Parsers.erase(Essence->second.Parsers.begin()+Pos); Pos--; } else if (Essence->second.Parsers.size()>1 && Essence->second.Parsers[Pos]->Status[IsAccepted]) { File__Analyze* Parser=Essence->second.Parsers[Pos]; for (size_t Pos2=0; Pos2second.Parsers.size(); Pos2++) { if (Pos2!=Pos) delete *(Essence->second.Parsers.begin()+Pos2); } Essence->second.Parsers.clear(); Essence->second.Parsers.push_back(Parser); } } } Element_Offset=Element_Size; } if (Essence->second.Parsers.size()==1 && Essence->second.Parsers[0]->Status[IsAccepted] && Essence->second.Frame_Count_NotParsedIncluded==(int64u)-1) { Essence->second.FrameInfo.DTS=Essence->second.Parsers[0]->FrameInfo.DTS; Essence->second.FrameInfo.PTS=Essence->second.Parsers[0]->FrameInfo.PTS; Essence->second.FrameInfo.DUR=Essence->second.Parsers[0]->FrameInfo.DUR; } else if (Buffer_End) { Essence->second.Frame_Count_NotParsedIncluded=(int64u)-1; Essence->second.FrameInfo=frame_info(); } else { if (Essence->second.Frame_Count_NotParsedIncluded!=(int64u)-1) Essence->second.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.Parsers.size()==1 && Essence->second.Parsers[0]->Status[IsFilled]) { 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"); //Frame info is specific to the container, and it is not updated if (Essence->first==Essences_UsedForFrameCount) { FrameInfo=Essence->second.FrameInfo; Frame_Count_NotParsedIncluded=Essence->second.Frame_Count_NotParsedIncluded; } else { FrameInfo=FrameInfo_Temp; Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded_Temp; } //Ignore tail #if MEDIAINFO_DEMUX if (DemuxedSampleCount_Total!=(int64u)-1 && DemuxedSampleCount_Current!=(int64u)-1) { DemuxedSampleCount_Total+=DemuxedSampleCount_Current; Frame_Count_NotParsedIncluded=DemuxedSampleCount_Total; } #endif //MEDIAINFO_DEMUX if (Config->ParseSpeed>=1.0 && Frame_Count_NotParsedIncluded!=(int64u)-1 && Config->File_IgnoreEditsAfter!=(int64u)-1) { descriptors::iterator SingleDescriptor=Descriptors.end(); for (descriptors::iterator SingleDescriptor_Temp=Descriptors.begin(); SingleDescriptor_Temp!=Descriptors.end(); ++SingleDescriptor_Temp) if (SingleDescriptor_Temp->second.StreamKind!=Stream_Max) { if (SingleDescriptor!=Descriptors.end()) { SingleDescriptor=Descriptors.end(); break; // 2 or more descriptors, can not be used } SingleDescriptor=SingleDescriptor_Temp; } int64u RealSampleRate=(SingleDescriptor==Descriptors.end() || SingleDescriptor->second.StreamKind!=Stream_Audio)?((int64u)Config->File_EditRate):SingleDescriptor->second.Infos["SamplingRate"].To_int64u(); int64u IgnoreSamplesAfter; if (!RealSampleRate || RealSampleRate==Config->File_EditRate) IgnoreSamplesAfter=Config->File_IgnoreEditsAfter; else IgnoreSamplesAfter=float64_int64s(((float64)Config->File_IgnoreEditsAfter)/Config->File_EditRate*RealSampleRate); if (Frame_Count_NotParsedIncluded>=IgnoreSamplesAfter) { if (PartitionMetadata_FooterPartition!=(int64u)-1 && PartitionMetadata_FooterPartition>=File_Offset+Buffer_Offset+Element_Size) GoTo(PartitionMetadata_FooterPartition); else GoToFromEnd(0); } } #if MEDIAINFO_DEMUX if (DemuxedSampleCount_Total!=(int64u)-1) { Frame_Count_NotParsedIncluded=(int64u)-1; } #endif //MEDIAINFO_DEMUX } else Skip_XX(Element_Size, "Unknown"); if (Buffer_End && (File_Offset+Buffer_Offset+Element_Size>=Buffer_End || File_GoTo!=(int64u)-1) ) { Buffer_Begin=(int64u)-1; Buffer_End=0; Buffer_End_Unlimited=false; Buffer_Header_Size=0; MustSynchronize=true; } if ((!IsParsingEnd && IsParsingMiddle_MaxOffset==(int64u)-1 && MediaInfoLib::Config.ParseSpeed_Get()<1.0) && ((!IsSub && File_Offset>=Buffer_PaddingBytes+0x4000000) //TODO: 64 MB by default (security), should be changed || (Streams_Count==0 && !Descriptors.empty()))) { Fill(); IsParsingEnd=true; if (PartitionMetadata_FooterPartition!=(int64u)-1 && PartitionMetadata_FooterPartition>File_Offset+Buffer_Offset+(size_t)Element_Size) { if (PartitionMetadata_FooterPartition+17<=File_Size) { GoTo(PartitionMetadata_FooterPartition); IsCheckingFooterPartitionAddress=true; } else { GoToFromEnd(4); //For random access table FooterPartitionAddress_Jumped=true; } } else { GoToFromEnd(4); //For random access table FooterPartitionAddress_Jumped=true; } Open_Buffer_Unsynch(); } if (File_Offset+Buffer_Offset+Element_Size>=RandomIndexMetadatas_MaxOffset) NextRandomIndexMetadata(); } //*************************************************************************** // 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&0xFFFFFF00)==(Elements::_ELEMENT##2&0xFFFFFF00) \ && Code_Compare3==Elements::_ELEMENT##3 \ && Code_Compare4==Elements::_ELEMENT##4) \ { \ Element_Name(_NAME); \ _ELEMENT(); \ } //--------------------------------------------------------------------------- void File_Mxf::AES3PCMDescriptor() { Descriptors[InstanceUID].IsAes3Descriptor=true; 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() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(SubDescriptors, "Sub Descriptors") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } 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->File_IgnoreEditsBefore && !Config->File_IsDetectingDuration_Get() && Config->Event_CallBackFunction_IsSet()) //Only if demux packet may be requested Open_Buffer_Seek(3, 0, (int64u)-1); //Forcing seek to Config->File_IgnoreEditsBefore 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->File_IgnoreEditsBefore && !Config->File_IsDetectingDuration_Get() && Config->Event_CallBackFunction_IsSet()) //Only if demux packet may be requested Open_Buffer_Seek(3, 0, (int64u)-1); //Forcing seek to Config->File_IgnoreEditsBefore 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->File_IgnoreEditsBefore && !Config->File_IsDetectingDuration_Get() && Config->Event_CallBackFunction_IsSet()) //Only if demux packet may be requested Open_Buffer_Seek(3, 0, (int64u)-1); //Forcing seek to Config->File_IgnoreEditsBefore 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->File_IgnoreEditsBefore && !Config->File_IsDetectingDuration_Get() && Config->Event_CallBackFunction_IsSet()) //Only if demux packet may be requested Open_Buffer_Seek(3, 0, (int64u)-1); //Forcing seek to Config->File_IgnoreEditsBefore 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(0202, DMSegment_Duration, "Duration") ELEMENT(6101, DMSegment_DMFramework, "DM Framework") ELEMENT(6102, DMSegment_TrackIDs, "Track IDs") 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=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(JPEG2000PictureSubDescriptor_Rsiz, "Rsiz - Decoder capabilities") ELEMENT_UUID(JPEG2000PictureSubDescriptor_Xsiz, "Xsiz - Width") ELEMENT_UUID(JPEG2000PictureSubDescriptor_Ysiz, "Ysiz - Height") ELEMENT_UUID(JPEG2000PictureSubDescriptor_XOsiz, "XOsiz - Horizontal offset") ELEMENT_UUID(JPEG2000PictureSubDescriptor_YOsiz, "YOsiz - Vertical offset") ELEMENT_UUID(JPEG2000PictureSubDescriptor_XTsiz, "XTsiz - Width of one reference tile") ELEMENT_UUID(JPEG2000PictureSubDescriptor_YTsiz, "YTsiz - Height of one reference tile") ELEMENT_UUID(JPEG2000PictureSubDescriptor_XTOsiz, "XTOsiz - Horizontal offset of the first tile") ELEMENT_UUID(JPEG2000PictureSubDescriptor_YTOsiz, "YTOsiz - Vertical offset of the first tile") ELEMENT_UUID(JPEG2000PictureSubDescriptor_Csiz, "Csiz - Number of components in the picture") ELEMENT_UUID(JPEG2000PictureSubDescriptor_PictureComponentSizing, "Picture Component Sizing") ELEMENT_UUID(JPEG2000PictureSubDescriptor_CodingStyleDefault, "Coding Style Default") ELEMENT_UUID(JPEG2000PictureSubDescriptor_QuantizationDefault, "Quantization Default") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } 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_TransferCharacteristic, "Transfer Characteristic") 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") ELEMENT(3219, GenericPictureEssenceDescriptor_ColorPrimaries, "Color Primaries") ELEMENT(321A, GenericPictureEssenceDescriptor_CodingEquations, "Coding Equations") 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::GenericDataEssenceDescriptor() { //Parsing switch(Code2) { ELEMENT(3E01, GenericDataEssenceDescriptor_DataEssenceCoding, "DataEssenceCoding") default: FileDescriptor(); } } //--------------------------------------------------------------------------- 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; Possecond.Packages.size(); Pos++) if (InstanceUID==ContentStorage->second.Packages[Pos]) { Element_Level--; Element_Info1("Valid from Content storage"); Element_Level++; } } } } //--------------------------------------------------------------------------- void File_Mxf::MPEG2VideoDescriptor() { Descriptors[InstanceUID].HasMPEG2VideoDescriptor=true; if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } CDCIEssenceDescriptor(); } //--------------------------------------------------------------------------- void File_Mxf::MultipleDescriptor() { if (Descriptors[InstanceUID].Type==descriptor::Type_Unknown) Descriptors[InstanceUID].Type=descriptor::type_Mutiple; /* //TODO: check when MPEG-4 Visual subdescriptor, it disabled stream info merge if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(SubDescriptors, "Sub Descriptors") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } */ switch(Code2) { ELEMENT(3F01, MultipleDescriptor_SubDescriptorUIDs, "SubDescriptorUIDs") default: FileDescriptor(); } } //--------------------------------------------------------------------------- void File_Mxf::DMSourceClip() { InterchangeObject(); } //--------------------------------------------------------------------------- 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; Possecond.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=0x8000) //user defined Primer_Values[LocalTag]=UID; FILLING_END(); } } //--------------------------------------------------------------------------- void File_Mxf::RGBAEssenceDescriptor() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(SubDescriptors, "Sub Descriptors") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } 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() { if (RandomIndexMetadatas_AlreadyParsed) { Skip_XX(Element_Size, "(Already parsed)"); return; } //Parsing while (Element_Offset+4File_Mxf_ParseIndex_Get()) { IsParsingEnd=true; GoTo(RandomIndexMetadatas[0].ByteOffset); RandomIndexMetadatas.erase(RandomIndexMetadatas.begin()); Open_Buffer_Unsynch(); //Hints if (File_Buffer_Size_Hint_Pointer) (*File_Buffer_Size_Hint_Pointer)=64*1024; } else if (!RandomIndexMetadatas_AlreadyParsed && !Partitions_IsFooter && !RandomIndexMetadatas.empty() && (!RandomIndexMetadatas[RandomIndexMetadatas.size()-1].BodySID || File_Offset+Buffer_Offset-Header_Size-RandomIndexMetadatas[RandomIndexMetadatas.size()-1].ByteOffset<16*1024*1024)) // If footer was not parsed but is available { GoTo(RandomIndexMetadatas[RandomIndexMetadatas.size()-1].ByteOffset); } RandomIndexMetadatas_AlreadyParsed=true; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mxf::DMFiller() { switch(Code2) { ELEMENT(0202, DMSegment_Duration, "Duration") default: StructuralComponent(); } FILLING_BEGIN(); DMSegments[InstanceUID].IsAs11SegmentFiller=true; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mxf::Sequence() { switch(Code2) { ELEMENT(1001, Sequence_StructuralComponents, "StructuralComponents") default: StructuralComponent(); } if (Code2==0x3C0A) { for (std::map::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() { systemschemes::iterator SystemScheme=SystemSchemes.find(Element_Code&0xFFFF); if (SystemScheme==SystemSchemes.end()) { SystemSchemes[Element_Code&0xFFFF].IsTimeCode=false; } switch(Code2) { #if MEDIAINFO_TRACE ELEMENT(0101, SystemScheme1_FrameCount, "Frame Count") #endif //MEDIAINFO_TRACE ELEMENT(0102, SystemScheme1_TimeCodeArray, "Time Code Array") #if MEDIAINFO_TRACE ELEMENT(0103, SystemScheme1_ClipIDArray, "Clip ID Array") ELEMENT(0104, SystemScheme1_ExtendedClipIDArray, "Extended Clip ID Array") ELEMENT(0105, SystemScheme1_VideoIndexArray, "Video Index Array") ELEMENT(0106, SystemScheme1_KLVMetadataSequence, "KLV Metadata Sequence") ELEMENT(3001, SystemScheme1_SampleRate, "Sample Rate") ELEMENT(4804, SystemScheme1_EssenceTrackNumber, "Essence Track Number") ELEMENT(6801, SystemScheme1_EssenceTrackNumberBatch, "Essence TrackNumber Batch") ELEMENT(6803, SystemScheme1_ContentPackageIndexArray, "Content Package Index Array") #endif //MEDIAINFO_TRACE default: InterchangeObject(); } } //--------------------------------------------------------------------------- // void File_Mxf::AS11_AAF_Core() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(AS11_Core_SeriesTitle, "Series Title") ELEMENT_UUID(AS11_Core_ProgrammeTitle, "Programme Title") ELEMENT_UUID(AS11_Core_EpisodeTitleNumber, "Episode Title Number") ELEMENT_UUID(AS11_Core_ShimName, "Shim Name") ELEMENT_UUID(AS11_Core_AudioTrackLayout, "Audio Track Layout") ELEMENT_UUID(AS11_Core_PrimaryAudioLanguage, "Primary Audio Language") ELEMENT_UUID(AS11_Core_ClosedCaptionsPresent, "Closed Captions Present") ELEMENT_UUID(AS11_Core_ClosedCaptionsType, "Closed Captions Type") ELEMENT_UUID(AS11_Core_ClosedCaptionsLanguage, "Closed Captions Language") ELEMENT_UUID(AS11_Core_ShimVersion, "Shim Version") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } StructuralComponent(); if (Code2==0x3C0A) //InstanceIUD AS11s[InstanceUID].Type=as11::Type_Core; } //--------------------------------------------------------------------------- // void File_Mxf::AS11_AAF_Segmentation() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(AS11_Segment_PartNumber, "Part Number") ELEMENT_UUID(AS11_Segment_PartTotal, "Part Total") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } StructuralComponent(); if (Code2==0x3C0A) //InstanceIUD AS11s[InstanceUID].Type=as11::Type_Segmentation; } //--------------------------------------------------------------------------- // void File_Mxf::AS11_AAF_UKDPP() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(AS11_UKDPP_ProductionNumber, "Production Number") ELEMENT_UUID(AS11_UKDPP_Synopsis, "Synopsis") ELEMENT_UUID(AS11_UKDPP_Originator, "Originator") ELEMENT_UUID(AS11_UKDPP_CopyrightYear, "Copyright Year") ELEMENT_UUID(AS11_UKDPP_OtherIdentifier, "Other Identifier") ELEMENT_UUID(AS11_UKDPP_OtherIdentifierType, "Other Identifier Type") ELEMENT_UUID(AS11_UKDPP_Genre, "Genre") ELEMENT_UUID(AS11_UKDPP_Distributor, "Distributor") ELEMENT_UUID(AS11_UKDPP_PictureRatio, "Picture Ratio") ELEMENT_UUID(AS11_UKDPP_3D, "3D") ELEMENT_UUID(AS11_UKDPP_3DType, "3D Type") ELEMENT_UUID(AS11_UKDPP_ProductPlacement, "Product Placement") ELEMENT_UUID(AS11_UKDPP_FpaPass, "FPA Pass") ELEMENT_UUID(AS11_UKDPP_FpaManufacturer, "FPA Manufacturer") ELEMENT_UUID(AS11_UKDPP_FpaVersion, "FPA Version") ELEMENT_UUID(AS11_UKDPP_VideoComments, "Video Comments") ELEMENT_UUID(AS11_UKDPP_SecondaryAudioLanguage, "Secondary Audio Language") ELEMENT_UUID(AS11_UKDPP_TertiaryAudioLanguage, "Tertiary Audio Language") ELEMENT_UUID(AS11_UKDPP_AudioLoudnessStandard, "Audio Loudness Standard") ELEMENT_UUID(AS11_UKDPP_AudioComments, "Audio Comments") ELEMENT_UUID(AS11_UKDPP_LineUpStart, "Line Up Start") ELEMENT_UUID(AS11_UKDPP_IdentClockStart, "Ident Clock Start") ELEMENT_UUID(AS11_UKDPP_TotalNumberOfParts, "Total Number Of Parts") ELEMENT_UUID(AS11_UKDPP_TotalProgrammeDuration, "Total Programme Duration") ELEMENT_UUID(AS11_UKDPP_AudioDescriptionPresent, "Audio Description Present") ELEMENT_UUID(AS11_UKDPP_AudioDescriptionType, "Audio Description Type") ELEMENT_UUID(AS11_UKDPP_OpenCaptionsPresent, "Open Captions Present") ELEMENT_UUID(AS11_UKDPP_OpenCaptionsType, "Open Captions Type") ELEMENT_UUID(AS11_UKDPP_OpenCaptionsLanguage, "Open Captions Language") ELEMENT_UUID(AS11_UKDPP_SigningPresent, "Signing Present") ELEMENT_UUID(AS11_UKDPP_SignLanguage, "Sign Language") ELEMENT_UUID(AS11_UKDPP_CompletionDate, "Completion Date") ELEMENT_UUID(AS11_UKDPP_TextlessElementsExist, "Textless Elements Exist") ELEMENT_UUID(AS11_UKDPP_ProgrammeHasText, "Programme Has Text") ELEMENT_UUID(AS11_UKDPP_ProgrammeTextLanguage, "Programme Text Language") ELEMENT_UUID(AS11_UKDPP_ContactEmail, "Contact Email") ELEMENT_UUID(AS11_UKDPP_ContactTelephoneNumber, "Contact Telephone Number") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } StructuralComponent(); if (Code2==0x3C0A) //InstanceIUD AS11s[InstanceUID].Type=as11::Type_UKDPP; } //--------------------------------------------------------------------------- //SMPTE 380M void File_Mxf::DMScheme1() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(PrimaryExtendedSpokenLanguage, "Primary Extended Spoken Language") ELEMENT_UUID(SecondaryExtendedSpokenLanguage, "Secondary Extended Spoken Language") ELEMENT_UUID(OriginalExtendedSpokenLanguage, "Original Extended Spoken Language") ELEMENT_UUID(SecondaryOriginalExtendedSpokenLanguage, "Secondary Original Extended Spoken Language") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } 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::StereoscopicPictureSubDescriptor() { StereoscopicPictureSubDescriptor_IsPresent=true; //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::TimecodeComponent() { if (Element_Offset==4) { MxfTimeCodeForDelay=mxftimecode(); DTS_Delay=0; FrameInfo.DTS=0; } switch(Code2) { ELEMENT(1501, TimecodeComponent_StartTimecode, "StartTimecode") ELEMENT(1502, TimecodeComponent_RoundedTimecodeBase, "RoundedTimecodeBase") ELEMENT(1503, TimecodeComponent_DropFrame, "DropFrame") default: StructuralComponent(); } } //--------------------------------------------------------------------------- void File_Mxf::WaveAudioDescriptor() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(SubDescriptors, "Sub Descriptors") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } 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") default: GenericSoundEssenceDescriptor(); } } //--------------------------------------------------------------------------- void File_Mxf::VbiPacketsDescriptor() { //switch(Code2) //{ // default: GenericDataEssenceDescriptor(); //} 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::AncPacketsDescriptor() { //switch(Code2) //{ // default: GenericDataEssenceDescriptor(); //} 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::MpegAudioDescriptor() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(MpegAudioDescriptor_BitRate, "Bit Rate") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } //switch(Code2) //{ // default: GenericSoundEssenceDescriptor(); //} } //--------------------------------------------------------------------------- void File_Mxf::PackageMarkerObject() { //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::ApplicationPlugInObject() { //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::ApplicationReferencedObject() { //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::MCALabelSubDescriptor() { if (Descriptors[InstanceUID].Type==descriptor::Type_Unknown) Descriptors[InstanceUID].Type=descriptor::Type_MCALabelSubDescriptor; if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(MCAChannelID, "MCA Channel ID") ELEMENT_UUID(MCALabelDictionaryID, "MCA Label Dictionary ID") ELEMENT_UUID(MCATagSymbol, "MCA Tag Symbol") ELEMENT_UUID(MCATagName, "MCA Tag Name") ELEMENT_UUID(GroupOfSoundfieldGroupsLinkID, "Group Of Soundfield Groups Link ID") ELEMENT_UUID(MCALinkID, "MCA Link ID") ELEMENT_UUID(SoundfieldGroupLinkID, "Soundfield Group Link ID") ELEMENT_UUID(MCAPartitionKind, "MCA Partition Kind") ELEMENT_UUID(MCAPartitionNumber, "MCA Partition Number") ELEMENT_UUID(MCATitle, "MCA Title") ELEMENT_UUID(MCATitleVersion, "MCA Title Version") ELEMENT_UUID(MCATitleSubVersion, "MCA Title Sub-version") ELEMENT_UUID(MCAEpisode, "MCA Episode") ELEMENT_UUID(MCAAudioContentKind, "MCA Audio Content Kind") ELEMENT_UUID(MCAAudioElementKind, "MCA Audio Element Kind") ELEMENT_UUID(RFC5646AudioLanguageCode, "Secondary Original Extended Spoken Language") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::TimedTextDescriptor() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(ResourceID, "Resource ID") ELEMENT_UUID(NamespaceURI, "Namespace URI") ELEMENT_UUID(UCSEncoding, "UCS Encoding") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } //switch(Code2) //{ // default: GenericDataEssenceDescriptor(); //} if (Descriptors[InstanceUID].StreamKind==Stream_Max) { Descriptors[InstanceUID].StreamKind=Stream_Text; if (Streams_Count==(size_t)-1) Streams_Count=0; Streams_Count++; } } //--------------------------------------------------------------------------- void File_Mxf::TimedTextResourceSubDescriptor() { //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::Unknown67SubDescriptor() { //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::Mpeg4VisualSubDescriptor() { if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(Mpeg4VisualDescriptor_SingleSequence, "Single sequence") ELEMENT_UUID(Mpeg4VisualDescriptor_ConstantBFrames, "Number of B frames always constant") ELEMENT_UUID(Mpeg4VisualDescriptor_CodedContentType, "Coded content type") ELEMENT_UUID(Mpeg4VisualDescriptor_LowDelay, "Low delay") ELEMENT_UUID(Mpeg4VisualDescriptor_ClosedGOP, "Closed GOP") ELEMENT_UUID(Mpeg4VisualDescriptor_IdenticalGOP, "Identical GOP") ELEMENT_UUID(Mpeg4VisualDescriptor_MaxGOP, "Maximum occurring spacing between I frames") ELEMENT_UUID(Mpeg4VisualDescriptor_BPictureCount, "Maximum number of B pictures between P or I frames") ELEMENT_UUID(Mpeg4VisualDescriptor_ProfileAndLevel, "Profile and level") ELEMENT_UUID(Mpeg4VisualDescriptor_BitRate, "Maximum bit rate") else { Element_Info1(Ztring().From_UUID(Primer_Value->second)); Skip_XX(Length2, "Data"); } return; } } //switch(Code2) //{ // default: GenerationInterchangeObject(); //} } //--------------------------------------------------------------------------- void File_Mxf::ResourceID() { //Parsing Info_UUID(Data, "UUID"); Element_Info1(Ztring().From_UUID(Data)); } //--------------------------------------------------------------------------- void File_Mxf::NamespaceURI() { //Parsing Info_UTF16B (Length2, Value, "Value"); Element_Info1(Value); } //--------------------------------------------------------------------------- void File_Mxf::UCSEncoding() { //Parsing Info_UTF16B (Length2, Value, "Value"); Element_Info1(Value); } //--------------------------------------------------------------------------- void File_Mxf::AudioChannelLabelSubDescriptor() { if (Descriptors[InstanceUID].Type==descriptor::Type_Unknown) Descriptors[InstanceUID].Type=descriptor::Type_AudioChannelLabelSubDescriptor; if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(SoundfieldGroupLinkID, "Soundfield Group Link ID") else MCALabelSubDescriptor(); return; } } //switch(Code2) //{ // default: MCALabelSubDescriptor(); //} } //--------------------------------------------------------------------------- void File_Mxf::SoundfieldGroupLabelSubDescriptor() { if (Descriptors[InstanceUID].Type==descriptor::Type_Unknown) Descriptors[InstanceUID].Type=descriptor::Type_SoundfieldGroupLabelSubDescriptor; if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { 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(GroupOfSoundfieldGroupsLinkID, "Group Of Soundfield Groups Link ID") else MCALabelSubDescriptor(); return; } } //switch(Code2) //{ // default: MCALabelSubDescriptor(); //} } //--------------------------------------------------------------------------- void File_Mxf::GroupOfSoundfieldGroupsLabelSubDescriptor() { if (Descriptors[InstanceUID].Type==descriptor::Type_Unknown) Descriptors[InstanceUID].Type=descriptor::Type_GroupOfSoundfieldGroupsLabelSubDescriptor; if (Code2>=0x8000) { // Not a short code std::map::iterator Primer_Value=Primer_Values.find(Code2); if (Primer_Value!=Primer_Values.end()) { MCALabelSubDescriptor(); return; } } //switch(Code2) //{ // default: MCALabelSubDescriptor(); //} } //--------------------------------------------------------------------------- void File_Mxf::MCAChannelID() { if (Length2==4) { Info_B4(Value, "Value"); Element_Info1(Value); } else Skip_XX(Length2, "Data"); } //--------------------------------------------------------------------------- void File_Mxf::MCALabelDictionaryID() { //Parsing int128u Value; Get_UL (Value, "Value", NULL); Element_Info1(Ztring().From_UUID(Value)); FILLING_BEGIN(); Descriptors[InstanceUID].MCALabelDictionaryID=Value; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mxf::MCATagSymbol() { //Parsing Ztring Value; Get_UTF16B (Length2, Value, "Value"); Element_Info1(Value); FILLING_BEGIN(); Descriptors[InstanceUID].MCATagSymbol=Value; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mxf::MCATagName() { //Parsing Ztring Value; Get_UTF16B (Length2, Value, "Value"); Element_Info1(Value); FILLING_BEGIN(); Descriptors[InstanceUID].MCATagName=Value; FILLING_END(); } //--------------------------------------------------------------------------- void File_Mxf::GroupOfSoundfieldGroupsLinkID() { if (Length2==0) return; //Parsing //Vector int32u Count, Length; Get_B4 (Count, "Count"); Get_B4 (Length, "Length"); for (int32u Pos=0; Pos>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::TimelineTrack() { //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; Possecond.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 (!Partitions_IsFooter || Descriptors[InstanceUID].Infos["BitDepth"].empty()) { 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() { ContentStorages[InstanceUID].Packages.clear(); //Parsing //Vector int32u Count, Length; Get_B4 (Count, "Count"); Get_B4 (Length, "Length"); for (int32u Pos=0; Pos>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)); if (!DataMustAlwaysBeComplete && Descriptors[InstanceUID].Infos["Format_Settings_Wrapping"].find(__T("Frame"))!=string::npos) DataMustAlwaysBeComplete=true; 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::iterator Descriptor_Previous=Descriptors.find(InstanceUID); if (Descriptor_Previous!=Descriptors.end()) { //Merging Descriptor->second.Infos.insert(Descriptor_Previous->second.Infos.begin(), Descriptor_Previous->second.Infos.end()); //TODO: better implementation } 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=1.3?true:false; if (!Is1dot3 && Element_Size && Buffer[(size_t)(Buffer_Offset+Element_Offset)]&0x60) Is1dot3=true; BS_Begin(); if (Is1dot3) { Skip_SB( "Reserved"); Get_S1 (4, Data, "Data"); Element_Info1C((Data<16), AfdBarData_active_format[Data]); Skip_SB( "AR"); Skip_S1(2, "Reserved"); } else { Skip_S1(3, "Reserved"); Get_S1 (4, Data, "Data"); Element_Info1C((Data<16), AfdBarData_active_format[Data]); Skip_SB( "AR"); } BS_End(); FILLING_BEGIN(); Descriptors[InstanceUID].ActiveFormat=Data; FILLING_END(); } //--------------------------------------------------------------------------- // 0x3219 void File_Mxf::GenericPictureEssenceDescriptor_ColorPrimaries() { //Parsing int128u Data; Get_UL(Data, "Data", Mxf_ColorPrimaries); Element_Info1(Mxf_ColorPrimaries(Data)); FILLING_BEGIN(); Descriptors[InstanceUID].Infos["colour_primaries"]=Mxf_ColorPrimaries(Data); FILLING_END(); } //--------------------------------------------------------------------------- // 0x321A void File_Mxf::GenericPictureEssenceDescriptor_CodingEquations() { //Parsing int128u Data; Get_UL(Data, "Data", Mxf_CodingEquations); Element_Info1(Mxf_CodingEquations(Data)); FILLING_BEGIN(); Descriptors[InstanceUID].Infos["matrix_coefficients"]=Mxf_CodingEquations(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 Value; Get_B4 (Value, "Value"); Element_Info1(Value); FILLING_BEGIN(); Descriptors[InstanceUID].ChannelCount=Value; Descriptors[InstanceUID].Infos["Channel(s)"].From_Number(Value); //if (Descriptors[InstanceUID].ChannelAssignment.lo!=(int64u)-1) //{ //Descriptors[InstanceUID].Infos["ChannelLayout"]=Mxf_ChannelAssignment_ChannelLayout(Descriptors[InstanceUID].ChannelAssignment, Value); //Ztring ChannelLayoutID; //ChannelLayoutID.From_Number(Descriptors[InstanceUID].ChannelAssignment.lo, 16); //if (ChannelLayoutID.size()<16) // ChannelLayoutID.insert(0, 16-ChannelLayoutID.size(), __T('0')); //Descriptors[InstanceUID].Infos["ChannelLayoutID"]=ChannelLayoutID; //Descriptors[InstanceUID].Infos["ChannelPositions"]=Mxf_ChannelAssignment_ChannelPositions(Descriptors[InstanceUID].ChannelAssignment, Value); //if (Descriptors[InstanceUID].Infos["ChannelPositions"].empty()) // Descriptors[InstanceUID].Infos["ChannelPositions"]=ChannelLayoutID; //Descriptors[InstanceUID].Infos["ChannelPositions/String2"]=Mxf_ChannelAssignment_ChannelPositions2(Descriptors[InstanceUID].ChannelAssignment, Value); //} FILLING_END(); } //--------------------------------------------------------------------------- // 0x3D0C void File_Mxf::GenericSoundEssenceDescriptor_DialNorm() { //Parsing Info_B1(Data, "Data"); Element_Info2(Data, " dB"); } //--------------------------------------------------------------------------- // 0x3E01 void File_Mxf::GenericDataEssenceDescriptor_DataEssenceCoding() { //Parsing Skip_UL( "UUID"); } //--------------------------------------------------------------------------- // 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(); if (Tracks[InstanceUID].TrackNumber==(int32u)-1 || Data) // In some cases, TrackNumber is 0 for all track and we have replaced with the right value during the parsing 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(); if (Major || Minor || Patch || Build || Release) 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 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(); if (Major || Minor || Patch || Build || Release) Identifications[InstanceUID].ToolkitVersion=Version; FILLING_END(); } //--------------------------------------------------------------------------- // 0x3C08 void File_Mxf::Identification_Platform() { //Parsing Ztring Data; Get_UTF16B(Length2, Data, "Data"); Element_Info1(Data); FILLING_BEGIN(); if (Data!=__T("Unknown")) Identifications[InstanceUID].Platform=Data; FILLING_END(); } //--------------------------------------------------------------------------- // 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=4) { int32u Size; Peek_B4(Size); if (Size==((int32u)Length2)-4) { SizeIsPresent=true; Skip_B4( "Value size"); } } //Parsing Ztring Value; Get_Local (Length2-(SizeIsPresent?4:0), Value, "Value"); Element_Info1(Value); FILLING_BEGIN(); Descriptors[InstanceUID].Infos["Language"]=Value; 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 (!Partitions_IsFooter || Descriptors[InstanceUID].ScanType.empty()) { if (Data==2 && Descriptors[InstanceUID].ScanType.empty()) { 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].ScanType.From_UTF8(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::Mpeg4VisualDescriptor_ProfileAndLevel() { //Parsing int8u profile_and_level_indication; Get_B1 (profile_and_level_indication, "profile_and_level_indication"); Param_Info1(Mpeg4v_Profile_Level(profile_and_level_indication)); FILLING_BEGIN(); if (profile_and_level_indication) Descriptors[InstanceUID].Infos["Format_Profile"]=Ztring().From_Local(Mpeg4v_Profile_Level(profile_and_level_indication)); 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() { Descriptors[InstanceUID].SubDescriptors.clear(); //Parsing //Vector int32u Count, Length; Get_B4 (Count, "Count"); Get_B4 (Length, "Length"); for (int32u Pos=0; Pos>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; #if MEDIAINFO_HASH delete Hash; Hash=NULL; #endif //MEDIAINFO_HASH } 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; #if MEDIAINFO_HASH delete Hash; Hash=NULL; #endif //MEDIAINFO_HASH } break; case 0x04 : Fill(Stream_General, 0, General_Format_Settings, "Closed / Complete" , Unlimited, true, true); break; default : ; } if ((Code.lo&0xFF0000)==0x030000) //If Body Partition Pack { if (IsParsingEnd) { //Parsing only index RandomIndexMetadatas_MaxOffset=File_Offset+Buffer_Offset+Element_Size+HeaderByteCount+IndexByteCount; //Hints if (File_Buffer_Size_Hint_Pointer && Buffer_Offset+Element_Size+HeaderByteCount+IndexByteCount>=Buffer_Size) { size_t Buffer_Size_Target=(size_t)(Buffer_Offset+Element_Size+HeaderByteCount+IndexByteCount-Buffer_Size); if (Buffer_Size_Target<128*1024) Buffer_Size_Target=128*1024; //if ((*File_Buffer_Size_Hint_Pointer)>8)&0xFF) { case 0x02 : case 0x04 : Config->File_IsGrowing=false; break; default : ; } #if MEDIAINFO_ADVANCED if (Footer_Position==(int64u)-1) Footer_Position=File_Offset+Buffer_Offset-Header_Size; #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED //IsTruncated bool IsTruncated; if (!Trusted_Get()) IsTruncated=true; else { int32u KAGSize_Corrected=KAGSize; if (!KAGSize || KAGSize>=File_Size) // Checking incoherent behaviors KAGSize_Corrected=1; int64u Element_Size_WithPadding=Element_Offset; if (Element_Size_WithPadding%KAGSize_Corrected) { Element_Size_WithPadding-=Element_Size_WithPadding%KAGSize_Corrected; Element_Size_WithPadding+=KAGSize_Corrected; } if (File_Offset+Buffer_Offset+Element_Size_WithPadding+HeaderByteCount+IndexByteCount > File_Size) IsTruncated=true; else IsTruncated=false; } if (IsTruncated) Fill(Stream_General, 0, "IsTruncated", "Yes", Unlimited, true, true); #endif //MEDIAINFO_ADVANCED } 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; PosDemux_Offset_DTS_FromStream=FrameInfo.DTS; #endif //MEDIAINFO_DEMUX } } Components[InstanceUID].MxfTimeCode.StartTimecode=Data; 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) { MxfTimeCodeForDelay.RoundedTimecodeBase=Data; if (MxfTimeCodeForDelay.StartTimecode!=(int64u)-1) { DTS_Delay=((float64)MxfTimeCodeForDelay.StartTimecode)/MxfTimeCodeForDelay.RoundedTimecodeBase; if (MxfTimeCodeForDelay.DropFrame) { DTS_Delay*=1001; DTS_Delay/=1000; } FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000); #if MEDIAINFO_DEMUX Config->Demux_Offset_DTS_FromStream=FrameInfo.DTS; #endif //MEDIAINFO_DEMUX } } Components[InstanceUID].MxfTimeCode.RoundedTimecodeBase=Data; 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) { MxfTimeCodeForDelay.DropFrame=true; if (DTS_Delay) { DTS_Delay*=1001; DTS_Delay/=1000; } FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000); #if MEDIAINFO_DEMUX Config->Demux_Offset_DTS_FromStream=FrameInfo.DTS; #endif //MEDIAINFO_DEMUX } Components[InstanceUID].MxfTimeCode.DropFrame=Data?true:false; 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 int64u Data; Get_B8 (Data, "Data"); Element_Info1(Data); FILLING_BEGIN(); if (Data!=(int64u)-1) Tracks[InstanceUID].Origin=Data; FILLING_END(); } //--------------------------------------------------------------------------- // 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 int128u Value; Get_UL (Value, "Value", Mxf_ChannelAssignment_ChannelLayout); Element_Info1(Mxf_ChannelAssignment_ChannelLayout(Value, Descriptors[InstanceUID].ChannelCount)); FILLING_BEGIN(); Descriptors[InstanceUID].ChannelAssignment=Value; //Descriptors[InstanceUID].Infos["ChannelLayout"]=Mxf_ChannelAssignment_ChannelLayout(Value, Descriptors[InstanceUID].ChannelCount); //Ztring ChannelLayoutID; //ChannelLayoutID.From_Number(Value.lo, 16); //if (ChannelLayoutID.size()<16) // ChannelLayoutID.insert(0, 16-ChannelLayoutID.size(), __T('0')); //Descriptors[InstanceUID].Infos["ChannelLayoutID"]=ChannelLayoutID; //Descriptors[InstanceUID].Infos["ChannelPositions"]=Mxf_ChannelAssignment_ChannelPositions(Value, Descriptors[InstanceUID].ChannelCount); //if (Descriptors[InstanceUID].Infos["ChannelPositions"].empty()) // Descriptors[InstanceUID].Infos["ChannelPositions"]=ChannelLayoutID; //Descriptors[InstanceUID].Infos["ChannelPositions/String2"]=Mxf_ChannelAssignment_ChannelPositions2(Value, Descriptors[InstanceUID].ChannelCount); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_IrisFNumber() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(0x100000*(1-(log(float(Value))-log(2.0))/8), 0).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_FocusPositionFromImagePlane() { //Parsing float32 Value; Get_BF2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_FocusPositionFromFrontLensVertex() { //Parsing float32 Value; Get_BF2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_MacroSetting() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Value?"On":"Off"); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_LensZoom35mmStillCameraEquivalent() { //Parsing float32 Value; Get_BF2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_LensZoomActualFocalLength() { //Parsing float32 Value; Get_BF2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_OpticalExtenderMagnification() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::LensUnitMetadata_LensAttributes() { //Parsing Ztring Value; Get_UTF8(Length2, Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Value.To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CaptureGammaEquation() { //Parsing int128u Value; Get_UUID(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_CaptureGammaEquation(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_AutoExposureMode() { //Parsing int128u Value; Get_UUID(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_AutoExposureMode(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_AutoFocusSensingAreaSetting() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_AutoFocusSensingAreaSetting(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ColorCorrectionFilterWheelSetting() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_ColorCorrectionFilterWheelSetting(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_NeutralDensityFilterWheelSetting() { //Parsing int16u Value; Get_B2(Value, "Value"); Element_Info1(Mxf_CameraUnitMetadata_NeutralDensityFilterWheelSetting(Value).c_str()); FILLING_BEGIN(); if (Value==1) AcquisitionMetadata_Add(Code2, "Clear"); else AcquisitionMetadata_Add(Code2, "1/"+Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ImageSensorDimensionEffectiveWidth() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float64)Value)/1000, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ImageSensorDimensionEffectiveHeight() { //Parsing //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float64)Value)/1000, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CaptureFrameRate() { //Parsing float64 Value; Get_Rational(Value); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ImageSensorReadoutMode() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_ImageSensorReadoutMode(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ShutterSpeed_Angle() { //Parsing int32u Value; Get_B4(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float)Value) / 60, 1).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ShutterSpeed_Time() { //Parsing int32u Num, Den; Get_B4(Num, "Num"); Get_B4(Den, "Den"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Num).To_UTF8()+'/'+Ztring::ToZtring(Den).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraMasterGainAdjustment() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float64)Value)/100, 2).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ISOSensitivity() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ElectricalExtenderMagnification() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_AutoWhiteBalanceMode() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_AutoWhiteBalanceMode(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_WhiteBalance() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraMasterBlackLevel() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float64)Value)/10, 1).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraKneePoint() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float64)Value)/10, 1).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraKneeSlope() { //Parsing float64 Value; Get_Rational(Value); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value, 3).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraLuminanceDynamicRange() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(((float64)Value)/10, 1).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraSettingFileURI() { //Parsing Ztring Value; Get_UTF8(Length2, Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Value.To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_CameraAttributes() { //Parsing Ztring Value; Get_UTF8(Length2, Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Value.To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ExposureIndexofPhotoMeter() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_GammaForCDL() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_CameraUnitMetadata_GammaforCDL(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::CameraUnitMetadata_ASC_CDL_V12() { //Parsing //Vector int32u Count, Length; Get_B4 (Count, "Count"); Get_B4 (Length, "Length"); if (Count!=10 || Length!=2) { Skip_XX (Length2-8, "Data"); return; } float32 sR, sG, sB, oR, oG, oB, pR, pG, pB, sat; Get_BF2(sR, "sR"); Get_BF2(sG, "sG"); Get_BF2(sB, "sB"); Get_BF2(oR, "oR"); Get_BF2(oG, "oG"); Get_BF2(oB, "oB"); Get_BF2(pR, "pR"); Get_BF2(pG, "pG"); Get_BF2(pB, "pB"); Get_BF2(sat, "sat"); FILLING_BEGIN(); Ztring ValueS=__T("sR=")+Ztring::ToZtring(sR, 1)+__T(" sG=")+Ztring::ToZtring(sG, 1)+__T(" sB=")+Ztring::ToZtring(sB, 1)+__T(" oR=")+Ztring::ToZtring(oR, 1)+__T(" oG=")+Ztring::ToZtring(oG, 1)+__T(" oB=")+Ztring::ToZtring(oB, 1)+__T(" pR=")+Ztring::ToZtring(pR, 1)+__T(" pG=")+Ztring::ToZtring(pG, 1)+__T(" pB=")+Ztring::ToZtring(pB, 1)+__T(" sat=")+Ztring::ToZtring(sat, 1); AcquisitionMetadata_Add(Code2, ValueS.To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_UdamSetIdentifier() { //Parsing int128u Value; Get_UUID(Value, "Value"); FILLING_BEGIN(); if ((Value.hi==0x966908004678031CLL && Value.lo==0x20500000F0C01181LL) || (Value.hi==0x966908004678031CLL && Value.lo==0x20500002F0C01181LL)) //Found Sony metadata with 00 or 02, what is the difference? UserDefinedAcquisitionMetadata_UdamSetIdentifier_IsSony=true; FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E101() { //Parsing int32u Width, Height; Get_B4 (Width, "Width"); Get_B4 (Height, "Height"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring(Ztring::ToZtring(Width)+__T("x")+Ztring::ToZtring(Height)).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E102() { //Parsing int32u Width, Height; Get_B4 (Width, "Width"); Get_B4 (Height, "Height"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring(Ztring::ToZtring(Width)+__T("x")+Ztring::ToZtring(Height)).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E103() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Mxf_AcquisitionMetadata_Sony_CameraProcessDiscriminationCode(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E104() { //Parsing int8u Value; Get_B1(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Value?"On":"Off"); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E105() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E106() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E107() { //Parsing int16u Value; Get_B2(Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Ztring::ToZtring(Value).To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E109() { //Parsing Ztring Value; Get_UTF8(Length2, Value, "Value"); FILLING_BEGIN(); AcquisitionMetadata_Add(Code2, Value.To_UTF8()); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E10B() { //Parsing int128u Value; Get_UUID(Value, "Value"); FILLING_BEGIN(); Ztring ValueS; ValueS.From_Number(Value.lo, 16); if (ValueS.size()<16) ValueS.insert(0, 16-ValueS.size(), __T('0')); AcquisitionMetadata_Add(Code2, Mxf_AcquisitionMetadata_Sony_MonitoringBaseCurve(Value)); FILLING_END(); } //--------------------------------------------------------------------------- // void File_Mxf::UserDefinedAcquisitionMetadata_Sony_E201() { if (AcquisitionMetadata_Sony_E201_Lists.empty()) AcquisitionMetadata_Sony_E201_Lists.resize(Mxf_AcquisitionMetadata_Sony_E201_ElementCount); //Parsing Ztring FocusDistance, ApertureValue, ApertureScale, HyperfocalDistance, NearFocusDistance, FarFocusDistance, EntrancePupilPosition; string LensSerialNumber; int16u EffectiveFocaleLength, HorizontalFieldOfView, NormalizedZoomValue; if (Length2<27) { Skip_XX(Length2, "Unknown"); return; } int64u End=Element_Offset+Length2; Skip_C1( "Tag"); BS_Begin(); Element_Begin1("Focus Distance"); { int8u B1, B2, B3, B4; Mark_0(); Mark_1(); Get_S1 (6, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); Mark_0(); Mark_1(); Get_S1 (6, B3, "3"); Mark_0(); Mark_1(); Get_S1 (6, B4, "4"); int32u Value=(B1<<18)|(B2<<12)|(B3<<6)|B4; if (Value==0xFFFFFF) FocusDistance=__T("Infinite"); else switch (AcquisitionMetadata_Sony_CalibrationType) { case 1 : FocusDistance=Ztring::ToZtring(((float)Value)/10, 1); break; default: FocusDistance=Ztring::ToZtring(Value); break; } Element_Info1(FocusDistance); } Element_End0(); Element_Begin1("Aperture Value"); { int8u B1, B2; Mark_0(); Mark_1(); Get_S1 (6, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); int16u Value=(B1<<6)|B2; ApertureValue.From_Number(((float)Value)/100, 2); Element_Info1(ApertureValue); } Element_End0(); Element_Begin1("Aperture Scale"); { int8u B1, B2, Fraction; Mark_1(); Get_S1 (7, B2, "Integer 2"); Mark_1(); Get_S1 (1, B1, "Integer 1"); Mark_0(); Mark_0(); Get_S1 (4, Fraction, "Fraction"); int8u Value=((B1<<7)|B2); ApertureScale=__T("T ")+Ztring::ToZtring(((float)Value)/10, 2)+__T(" + ")+Ztring::ToZtring(Fraction)+__T("/10"); Element_Info1(ApertureScale); } Element_End0(); Element_Begin1("Effective Focale Length"); { int8u B1, B2; Mark_0(); Mark_1(); Mark_0(); Mark_0(); Get_S1 (4, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); EffectiveFocaleLength=(B1<<6)|B2; Element_Info2(EffectiveFocaleLength, "mm"); } Element_End0(); Element_Begin1("Hyperfocal Distance"); { int8u B1, B2, B3, B4; Mark_0(); Mark_1(); Get_S1 (6, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); Mark_0(); Mark_1(); Get_S1 (6, B3, "3"); Mark_0(); Mark_1(); Get_S1 (6, B4, "4"); int32u Value=(B1<<18)|(B2<<12)|(B3<<6)|B4; if (Value==0xFFFFFF) HyperfocalDistance=__T("Infinite"); else switch (AcquisitionMetadata_Sony_CalibrationType) { case 1 : HyperfocalDistance=Ztring::ToZtring(((float)Value)/10, 1); break; default: HyperfocalDistance=Ztring::ToZtring(Value); } Element_Info1(HyperfocalDistance); } Element_End0(); Element_Begin1("Near Focus Distance"); { int8u B1, B2, B3, B4; Mark_0(); Mark_1(); Get_S1 (6, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); Mark_0(); Mark_1(); Get_S1 (6, B3, "3"); Mark_0(); Mark_1(); Get_S1 (6, B4, "4"); int32u Value=(B1<<18)|(B2<<12)|(B3<<6)|B4; if (Value==0xFFFFFF) NearFocusDistance=__T("Infinite"); else switch (AcquisitionMetadata_Sony_CalibrationType) { case 1 : NearFocusDistance=Ztring::ToZtring(((float)Value)/10, 1); break; default: NearFocusDistance=Ztring::ToZtring(Value); } Element_Info1(NearFocusDistance); } Element_End0(); Element_Begin1("Far Focus Distance"); { int8u B1, B2, B3, B4; Mark_0(); Mark_1(); Get_S1 (6, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); Mark_0(); Mark_1(); Get_S1 (6, B3, "3"); Mark_0(); Mark_1(); Get_S1 (6, B4, "4"); int32u Value=(B1<<18)|(B2<<12)|(B3<<6)|B4; if (Value==0xFFFFFF) FarFocusDistance=__T("Infinite"); else switch (AcquisitionMetadata_Sony_CalibrationType) { case 1 : FarFocusDistance=Ztring::ToZtring(((float)Value)/10, 1); break; default: FarFocusDistance=Ztring::ToZtring(Value); } Element_Info1(FarFocusDistance); } Element_End0(); Element_Begin1("Horizontal Field of View"); { int8u B1, B2; Mark_0(); Mark_1(); Mark_0(); Get_S1 (5, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); HorizontalFieldOfView=(B1<<6)|B2; Element_Info1(Ztring::ToZtring(((float)HorizontalFieldOfView)/10, 1)); } Element_End0(); Element_Begin1("Entrance Pupil Position"); { int8u B1, B2; bool Minus; Mark_0(); Mark_1(); Get_SB (Minus, "Minus"); Mark_0(); Get_S1 (4, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); int32u Value=(B1<<6)|B2; switch (AcquisitionMetadata_Sony_CalibrationType) { case 1 : EntrancePupilPosition=Ztring::ToZtring(((float)Value)/10, 1); break; default: EntrancePupilPosition=Ztring::ToZtring(Value); } Element_Info1(EntrancePupilPosition); } Element_End0(); Element_Begin1("Normalized Zoom Value"); { int8u B1, B2; Mark_0(); Mark_1(); Mark_0(); Mark_0(); Get_S1 (4, B1, "1"); Mark_0(); Mark_1(); Get_S1 (6, B2, "2"); NormalizedZoomValue=(B1<<6)|B2; Element_Info1(Ztring::ToZtring(((float)NormalizedZoomValue)/1000, 3)); } Element_End0(); BS_End(); Skip_C1( "S"); Get_String(9, LensSerialNumber, "Lens Serial Number"); if (Element_Offset+2=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("Identification and location"); Info_B1(Code2, "Code (2)"); switch (Code2) { case 0x01 : { Param_Info1("Globally Unique Identifiers"); Info_B1(Code3, "Code (3)"); switch (Code3) { case 0x01 : { Param_Info1("SDTI Payload Identifiers"); Skip_B5( "Data"); } break; case 0x02 : { Param_Info1("File Format Identifiers"); Skip_B5( "Data"); } break; case 0x03 : { Param_Info1("Definition Identifiers"); Skip_B5( "Data"); } break; default : Skip_B5( "Unknown"); } } break; case 0x02 : { Param_Info1("Globally Unique Locators"); Info_B1(Code3, "Code (3)"); Skip_B5( "Unknown"); } break; case 0x03 : { Param_Info1("Locally Unique Identifiers"); Info_B1(Code3, "Code (3)"); switch (Code3) { case 0x01 : { Param_Info1("For Information Only Do Not Use"); Skip_B5( "Unknown"); } break; case 0x02 : { Param_Info1("Track Identifiers"); Info_B1(Code4, "Kind"); switch (Code4) { case 0x01 : { Param_Info1("Metadata Track Kinds"); Skip_B1( "Unknown"); Skip_B3( "Unknown"); } break; case 0x02 : { Param_Info1("Essence Track Kinds"); Skip_B1( "Unknown"); Skip_B3( "Unknown"); } break; case 0x03 : { Param_Info1("Other Track Kinds"); Skip_B1( "Unknown"); Skip_B3( "Unknown"); } break; default : Skip_B4( "Unknown"); } } 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("Per element?"); Info_B1(Code3, "Code (3)"); switch (Code3) { case 0x01 : { Param_Info1("Channels?"); Info_B1(Code4, "Code (4)"); switch (Code4) { case 0x01 : { Param_Info1("L"); Skip_B4( "Reserved"); } break; case 0x02 : { Param_Info1("R"); Skip_B4( "Reserved"); } break; case 0x03 : { Param_Info1("C"); Skip_B4( "Reserved"); } break; case 0x04 : { Param_Info1("LFE"); Skip_B4( "Reserved"); } break; case 0x05 : { Param_Info1("Ls"); Skip_B4( "Reserved"); } break; case 0x06 : { Param_Info1("Rs"); Skip_B4( "Reserved"); } break; case 0x20 : { Param_Info1("M1"); Skip_B4( "Reserved"); } break; case 0x21 : { Param_Info1("M2"); Skip_B4( "Reserved"); } break; case 0x22 : { Param_Info1("Lt"); Skip_B4( "Reserved"); } break; case 0x23 : { Param_Info1("Rt"); Skip_B4( "Reserved"); } break; default : Skip_B4( "Unknown"); } } break; case 0x02 : { Param_Info1("Per group?"); Info_B1(Code4, "Code (4)"); switch (Code4) { case 0x01 : { Param_Info1("5.1"); Skip_B4( "Reserved"); } break; case 0x11 : { Param_Info1("Dual Mono"); Skip_B4( "Reserved"); } break; case 0x18 : { Param_Info1("Lt+Rt"); Skip_B4( "Reserved"); } break; default : Skip_B4( "Unknown"); } } break; default : Skip_B5( "Unknown"); } } break; case 0x02 : { Param_Info1("Per element?"); Info_B1(Code3, "Code (3)"); switch (Code3) { case 0x01 : { Param_Info1("Channels?"); Info_B1(Code4, "Code (4)"); switch (Code4) { case 0x01 : { Param_Info1("L"); Skip_B4( "Reserved"); } break; case 0x02 : { Param_Info1("R"); Skip_B4( "Reserved"); } break; case 0x03 : { Param_Info1("C"); Skip_B4( "Reserved"); } break; case 0x04 : { Param_Info1("LFE"); Skip_B4( "Reserved"); } break; case 0x05 : { Param_Info1("Ls"); Skip_B4( "Reserved"); } break; case 0x06 : { Param_Info1("Rs"); Skip_B4( "Reserved"); } break; case 0x20 : { Param_Info1("Lt+Rt?"); Info_B1(Code5, "Code (5)"); switch (Code5) { case 0x03 : { Param_Info1("Lt"); Skip_B3( "Reserved"); } break; case 0x04 : { Param_Info1("Rt"); Skip_B3( "Reserved"); } break; default : Skip_B3( "Unknown"); } } break; default : Skip_B4( "Unknown"); } } break; case 0x02 : { Param_Info1("Per group?"); Info_B1(Code4, "Code (4)"); switch (Code4) { case 0x01 : { Param_Info1("5.1"); Skip_B4( "Reserved"); } break; case 0x10 : { Param_Info1("2.0"); Skip_B4( "Reserved"); } break; case 0x18 : { Param_Info1("Lt+Rt"); Skip_B4( "Reserved"); } break; case 0x20 : { Param_Info1("?"); Info_B1(Code5, "Code (5)"); switch (Code5) { case 0x01 : { Param_Info1("2.0"); Skip_B3( "Reserved"); } break; case 0x09 : { Param_Info1("Lt+Rt"); Skip_B3( "Reserved"); } break; default : Skip_B3( "Unknown"); } } break; default : Skip_B4( "Unknown"); } } 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"); Info_B1(Code4, "Code (4)"); switch (Code4) { case 0x01 : { Param_Info1("Picture Source Characteristics"); Info_B1(Code5, "Code (5)"); switch (Code5) { case 0x01 : { Param_Info1("Transfer Characteristic"); Info_B1(Code6, "Code (6)"); switch (Code6) { case 0x01 : Param_Info1("BT.470"); Skip_B2( "Reserved"); break; case 0x02 : Param_Info1("BT.709"); Skip_B2( "Reserved"); break; case 0x03 : Param_Info1("SMPTE 240M"); Skip_B2( "Reserved"); break; case 0x04 : Param_Info1("SMPTE 274M"); Skip_B2( "Reserved"); break; case 0x05 : Param_Info1("BT.1361 extended colour gamut system"); Skip_B2( "Reserved"); break; case 0x06 : Param_Info1("Linear"); Skip_B2( "Reserved"); break; case 0x07 : Param_Info1("SMPTE 428M"); Skip_B2( "Reserved"); break; default : Skip_B2( "Unknown"); } } break; case 0x02 : { Param_Info1("Coding Equations"); Info_B1(Code6, "Code (6)"); switch (Code6) { case 0x01 : Param_Info1("BT.601"); Skip_B2( "Reserved"); break; case 0x02 : Param_Info1("BT.709"); Skip_B2( "Reserved"); break; case 0x03 : Param_Info1("SMPTE 240M"); Skip_B2( "Reserved"); break; default : Skip_B2( "Unknown"); } } break; case 0x03 : { Param_Info1("Color Primaries"); Info_B1(Code6, "Code (6)"); switch (Code6) { case 0x01 : Param_Info1("BT.601 NTSC"); Skip_B2( "Reserved"); break; case 0x02 : Param_Info1("BT.470 System B"); Skip_B2( "Reserved"); break; case 0x03 : Param_Info1("BT.709"); Skip_B2( "Reserved"); break; default : Skip_B2( "Unknown"); } } break; default : Skip_B3( "Unknown"); } } break; default : Skip_B4( "Unknown"); } } 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("Undefined"); 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_B1("Unknown"); } } break; default : Skip_B2( "Unknown"); } } break; default : Skip_B3( "Unknown"); } } break; case 0x10 : { Param_Info1("Sound Channel Labeling"); Info_B1(Code5, "Code (5)"); switch (Code5) { case 0x03 : { Param_Info1("Sound Channel Labeling SMPTE 429-2"); Info_B1(Code6, "Code (6)"); switch (Code6) { case 0x01 : { Param_Info1("Sound Channel Labeling SMPTE 429-2 Sets"); Info_B1(Code7, "Code (7)"); switch (Code7) { case 0x01 : Param_Info1("SMPTE-429-2 Channel Configuration 1"); Skip_B1("Reserved"); break; default : Skip_B1("Unknown"); } } break; default : Skip_B2( "Unknown"); } } break; case 0x04 : { Param_Info1("Sound Channel Labeling SMPTE 2067-2"); Info_B1(Code6, "Code (6)"); switch (Code6) { case 0x01 : { Param_Info1("MXF Multichannel Audio Framework"); Skip_B2( "Reserved"); } 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, 0x00)); 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 0x13 : { Param_Info1("Timed Text"); Skip_B1( "Reserved"); 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; case 0x06 : { Param_Info1("Sony"); Info_B1(Code3, "Code (3)"); switch (Code3) { case 0x04 : { 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("?"); Info_B1(Code7, "Code (7)"); switch (Code7) { case 0x02 : Param_Info1("?"); Info_B1(Code8, "Code (8)"); switch (Code8) { case 0x01 : Param_Info1("RAW SQ"); break; default : ; } break; default : Skip_B1( "Unknown"); } } break; default : Skip_B2( "Unknown"); } } break; default : Skip_B3( "Unknown"); } } break; default : Skip_B4( "Unknown"); } } break; case 0x0D : { Param_Info1("Essence Container?"); Info_B1(Code4, "?"); switch (Code4) { case 0x03 : { Param_Info1("?"); Info_B1(Code5, "?"); switch (Code5) { case 0x02 : { Param_Info1("?"); Info_B1(Code6, "Code (6)"); switch (Code6) { case 0x01 : { Param_Info1("?"); Info_B1(Code7, "Code (7)"); switch (Code7) { case 0x01 : Param_Info1("RAW?"); Skip_B1( "Unknown"); break; default : Skip_B1( "Unknown"); } } break; default : Skip_B2( "Unknown"); } } break; default : Skip_B3( "Unknown"); } } break; default : Skip_B4( "Unknown"); } } break; default : Skip_B5( "Private"); } } 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 //*************************************************************************** //--------------------------------------------------------------------------- void 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; } 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 0x30 : case 0x31 : case 0x32 : case 0x33 : case 0x34 : case 0x35 : case 0x36 : case 0x37 : case 0x38 : case 0x39 : case 0x3A : case 0x3B : case 0x3C : case 0x3D : case 0x3E : case 0x3F : return ChooseParser_Avc(Essence, Descriptor); default : return; } case 0x02 : return ChooseParser_DV(Essence, Descriptor); case 0x03 : //Individual Picture Coding Schemes switch (Code6) { case 0x01 : return ChooseParser_Jpeg2000(Essence, Descriptor); default : return; } case 0x71 : return ChooseParser_Vc3(Essence, Descriptor); default : return; } default : return; } default : return; } case 0x02 : //Sound switch (Code3) { case 0x02 : //Coding characteristics switch (Code4) { case 0x01 : //Uncompressed Sound Coding ChooseParser__FromEssenceContainer (Essence, Descriptor); //e.g. for D-10 Audio if (!Essence->second.Parsers.empty()) return; switch (Code5) { case 0x01 : case 0x7F : if (Descriptor->second.ChannelCount==1) //PCM, but one file is found with Dolby E in it ChooseParser_ChannelGrouping(Essence, Descriptor); if (Descriptor->second.ChannelCount==2) //PCM, but one file is found with Dolby E in it ChooseParser_SmpteSt0337(Essence, Descriptor); default : 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; } case 0x02 : //SMPTE 338M Audio Coding switch (Code7) { case 0x01 : if (Descriptor->second.IsAes3Descriptor) return ChooseParser_SmpteSt0337(Essence, Descriptor); else return ChooseParser_Ac3(Essence, Descriptor); case 0x04 : case 0x05 : case 0x06 : if (Descriptor->second.IsAes3Descriptor) return ChooseParser_SmpteSt0337(Essence, Descriptor); else return ChooseParser_Mpega(Essence, Descriptor); case 0x1C : if (Descriptor->second.ChannelCount==1) return ChooseParser_ChannelGrouping(Essence, Descriptor); //Dolby E (in 2 mono streams) else return ChooseParser_SmpteSt0337(Essence, Descriptor); //Dolby E (in 1 stereo streams) default : return; } case 0x03 : //MPEG-2 Coding (not defined in SMPTE 338M) switch (Code7) { case 0x01 : return ChooseParser_Aac(Essence, Descriptor); default : return; } 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; } default : return; } default : return; } default : return; } default : return; } default : return; } } //--------------------------------------------------------------------------- void 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_SmpteSt0331(Essence, Descriptor); default : return; } case 0x02 : return; //DV case 0x05 : return ChooseParser_Raw(Essence, Descriptor); case 0x06 : if (Descriptor->second.ChannelCount==1) //PCM, but one file is found with Dolby E in it ChooseParser_ChannelGrouping(Essence, Descriptor); if (Descriptor->second.ChannelCount==2) //PCM, but one file is found with Dolby E in it ChooseParser_SmpteSt0337(Essence, Descriptor); return ChooseParser_Pcm(Essence, Descriptor); case 0x04 : return; //MPEG ES mappings with Stream ID case 0x0A : return ChooseParser_Alaw(Essence, Descriptor); case 0x0C : return ChooseParser_Jpeg2000(Essence, Descriptor); case 0x10 : return ChooseParser_Avc(Essence, Descriptor); case 0x11 : return ChooseParser_Vc3(Essence, Descriptor); case 0x13 : return ChooseParser_TimedText(Essence, Descriptor); 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 ChooseParser_Vc3(Essence, Descriptor); default : return; } default : return; } default : return; } default : return; } default : return; } default : return; } } //--------------------------------------------------------------------------- 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); case Elements::GenericContainer_Sony3 : return ChooseParser__Sony(Essence, Descriptor); default : return; } } //--------------------------------------------------------------------------- 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 ; } } //--------------------------------------------------------------------------- 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 ; } } //--------------------------------------------------------------------------- // 0x05, SMPTE 386M 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 ChooseParser_Mpegv(Essence, Descriptor); break; default : //Unknown ; } } //--------------------------------------------------------------------------- void File_Mxf::ChooseParser__Sony(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__Sony_Picture(Essence, Descriptor); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 0x06, SMPTE 386M 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 ChooseParser_SmpteSt0331(Essence, Descriptor); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 0x07, SMPTE 386M void File_Mxf::ChooseParser__Aaf_CP_Data(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { } //--------------------------------------------------------------------------- // 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? Essence->second.Parsers.push_back(new File_Mxf()); break; default : ; } } //--------------------------------------------------------------------------- // 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 ChooseParser_RV24(Essence, Descriptor); break; case 0x02 : //Raw video ChooseParser_Raw(Essence, Descriptor); break; case 0x05 : //SMPTE 381M, Frame wrapped ChooseParser_Mpegv(Essence, Descriptor); //Trying... Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Frame"); DataMustAlwaysBeComplete=true; break; case 0x06 : //SMPTE 381M, Clip wrapped ChooseParser_Mpegv(Essence, Descriptor); //Trying... Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Clip"); break; case 0x07 : //SMPTE 381M, Custom wrapped ChooseParser_Mpegv(Essence, Descriptor); //Trying... Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Custom"); break; case 0x08 : //JPEG 2000 ChooseParser_Jpeg2000(Essence, Descriptor); break; case 0x0D : //VC-3 ChooseParser_Vc3(Essence, Descriptor); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 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) ChooseParser_Pcm(Essence, Descriptor); break; case 0x05 : //MPEG Audio ChooseParser_Mpega(Essence, Descriptor); break; case 0x08 : //A-law, Frame wrapped ChooseParser_Alaw(Essence, Descriptor); Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Frame"); DataMustAlwaysBeComplete=true; break; case 0x09 : //A-law, Clip wrapped ChooseParser_Alaw(Essence, Descriptor); Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Clip"); break; case 0x0A : //A-law, Custom wrapped ChooseParser_Alaw(Essence, Descriptor); Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Custom"); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 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 0x01 : //VBI, SMPTE ST 436 Essence->second.Parsers.push_back(new File__Analyze()); break; case 0x02 : //Ancillary #if defined(MEDIAINFO_ANCILLARY_YES) if (!Ancillary) { Ancillary=new File_Ancillary(); MayHaveCaptionsInStream=true; } Essence->second.Parsers.push_back(Ancillary); Ancillary_IsBinded=true; #endif //defined(MEDIAINFO_ANCILLARY_YES) 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; case 0x0B : //Timed Text ChooseParser_TimedText(Essence, Descriptor); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 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 ChooseParser_DV(Essence, Descriptor); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 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 ChooseParser_Vc3(Essence, Descriptor); Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Frame"); DataMustAlwaysBeComplete=true; break; case 0x06 : //VC-1, Clip wrapped ChooseParser_Vc3(Essence, Descriptor); Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Clip"); break; case 0x07 : //VC-1, Custom wrapped ChooseParser_Vc3(Essence, Descriptor); Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=__T("Custom"); break; default : //Unknown ; } } //--------------------------------------------------------------------------- // 0x15 void File_Mxf::ChooseParser__Sony_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { int32u Code_Compare4=(int32u)Code.lo; Essences[Code_Compare4].StreamKind=Stream_Video; Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF; } //--------------------------------------------------------------------------- void 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; MayHaveCaptionsInStream=true; #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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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; MayHaveCaptionsInStream=true; #if MEDIAINFO_ADVANCED Parser->InitDataNotRepeated_Optional=true; #endif // MEDIAINFO_ADVANCED #if MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX #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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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"); Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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"); Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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; if (Descriptor!=Descriptors.end()) Parser->FrameRate=Descriptor->second.SampleRate; #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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void File_Mxf::ChooseParser_TimedText(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { Essence->second.StreamKind=Stream_Text; //Filling #if defined(MEDIAINFO_TTML_YES) File_Ttml* Parser=new File_Ttml; #else //Filling File__Analyze* Parser=new File_Unknown(); Open_Buffer_Init(Parser); Parser->Stream_Prepare(Stream_Text); Parser->Fill(Stream_Text, 0, Text_Format, "Timed Text"); #endif Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void 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"); Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void File_Mxf::ChooseParser_ChannelGrouping(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { Essence->second.StreamKind=Stream_Audio; if ((Essence->first&0x000000FF)==0x00000000) StreamPos_StartAtZero.set(Essence->second.StreamKind); // Need to do it here because we use StreamPos_StartAtZero immediately #if defined(MEDIAINFO_SMPTEST0337_YES) //Creating the parser if (!((Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1))%2 && Essences[Essence->first-1].Parsers.size()<=1)) { File_ChannelGrouping* Parser; if ((Essence->second.StreamPos-(StreamPos_StartAtZero[Essence->second.StreamKind]?0:1))%2) //If the first half-stream was already rejected, don't try this one { 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].Parsers[0])->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->SamplingRate=Descriptor->second.Infos["SamplingRate"].To_int16u(); Essence->second.IsChannelGrouping=true; } Parser->Channel_Total=2; if (Descriptor!=Descriptors.end()) { Parser->BitDepth=(int8u)(Descriptor->second.BlockAlign<=4?(Descriptor->second.BlockAlign*8):(Descriptor->second.BlockAlign*4)); //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 Essence->second.Parsers.push_back(Parser); } #endif //defined(MEDIAINFO_SMPTEST0337_YES) //Adding PCM ChooseParser_Pcm(Essence, Descriptor); } //--------------------------------------------------------------------------- void 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 Essence->second.Parsers.push_back(Parser); } //--------------------------------------------------------------------------- void File_Mxf::ChooseParser_Pcm(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { Essence->second.StreamKind=Stream_Audio; int8u Channels=0; if (Descriptor!=Descriptors.end()) { if (Descriptor->second.Infos.find("Channel(s)")!=Descriptor->second.Infos.end()) Channels=Descriptor->second.Infos["Channel(s)"].To_int8u(); //Handling some buggy cases if (Channels>1 && Descriptor->second.BlockAlign!=(int16u)-1 && Descriptor->second.QuantizationBits!=(int32u)-1) { if (((int32u)Descriptor->second.BlockAlign)*8==Descriptor->second.QuantizationBits) Descriptor->second.BlockAlign*=Channels; //BlockAlign is by channel, it should be by block. } } //Creating the parser #if defined(MEDIAINFO_PCM_YES) File_Pcm* Parser=new File_Pcm; if (Descriptor!=Descriptors.end()) { if (Channels) Parser->Channels=Channels; if (Descriptor->second.Infos.find("SamplingRate")!=Descriptor->second.Infos.end()) Parser->SamplingRate=Descriptor->second.Infos["SamplingRate"].To_int16u(); if (Parser->Channels && Descriptor->second.BlockAlign!=(int16u)-1) Parser->BitDepth=(int8u)(Descriptor->second.BlockAlign*8/Parser->Channels); else if (Descriptor->second.QuantizationBits<256) Parser->BitDepth=(int8u)Descriptor->second.QuantizationBits; else if (Descriptor->second.Infos.find("BitDepth")!=Descriptor->second.Infos.end()) Parser->BitDepth=Descriptor->second.Infos["BitDepth"].To_int8u(); //Handling of quantization bits not being same as BlockAlign/Channels if (Channels && Descriptor->second.BlockAlign!=(int16u)-1 && Descriptor->second.QuantizationBits!=(int32u)-1) { if (Channels*Descriptor->second.QuantizationBits!=((int32u)Descriptor->second.BlockAlign)*8) { //Moving Bit depth info to the "Significant" piece of etadata if (Descriptor->second.QuantizationBits<256) Parser->BitDepth_Significant=(int8u)Descriptor->second.QuantizationBits; else Parser->BitDepth_Significant=Parser->BitDepth; Parser->BitDepth=((int8u)Descriptor->second.BlockAlign)*8/Channels; } } 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 Essence->second.Parsers.push_back(Parser); #endif } //--------------------------------------------------------------------------- void File_Mxf::ChooseParser_SmpteSt0331(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { Essence->second.StreamKind=Stream_Audio; //Filling #if defined(MEDIAINFO_SMPTEST0331_YES) File_SmpteSt0331* Parser=new File_SmpteSt0331; if (Descriptor!=Descriptors.end() && Descriptor->second.QuantizationBits!=(int32u)-1) Parser->QuantizationBits=Descriptor->second.QuantizationBits; #if MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Essence->second.Parsers.push_back(Parser); #endif } //--------------------------------------------------------------------------- void File_Mxf::ChooseParser_SmpteSt0337(const essences::iterator &Essence, const descriptors::iterator &Descriptor) { Essence->second.StreamKind=Stream_Audio; //Filling #if defined(MEDIAINFO_SMPTEST0337_YES) File_SmpteSt0337* Parser=new File_SmpteSt0337; if (Descriptor!=Descriptors.end()) { if (Descriptor->second.BlockAlign<64) Parser->Container_Bits=(int8u)(Descriptor->second.BlockAlign*4); else if (Descriptor->second.QuantizationBits!=(int32u)-1) Parser->Container_Bits=(int8u)Descriptor->second.QuantizationBits; 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'; Parser->Aligned=true; #if MEDIAINFO_DEMUX if (Demux_UnpacketizeContainer) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; } #endif //MEDIAINFO_DEMUX Essence->second.Parsers.push_back(Parser); #endif } //--------------------------------------------------------------------------- void 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()) { Parser->Interlaced=Descriptor->second.ScanType==__T("Interlaced"); #if MEDIAINFO_DEMUX if (Parser->Interlaced) { Parser->Demux_Level=2; //Container Parser->Demux_UnpacketizeContainer=true; Parser->FrameRate=Descriptor->second.SampleRate; } #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, "JPEG 2000"); #endif Essence->second.Parsers.push_back(Parser); } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- void File_Mxf::Subsampling_Compute(descriptors::iterator Descriptor) { if (Descriptor==Descriptors.end() || (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; } } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_REFERENCES_YES) 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; Possecond.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; } } #endif //defined(MEDIAINFO_REFERENCES_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_REFERENCES_YES) 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()) { sequence* Sequence=new sequence; Sequence->AddFileName(Locator->second.EssenceLocator); Sequence->StreamKind=Locator->second.StreamKind; Sequence->StreamPos=Locator->second.StreamPos; if (Locator->second.LinkedTrackID!=(int32u)-1) Sequence->StreamID=Locator->second.LinkedTrackID; else if (!Retrieve(Locator->second.StreamKind, Locator->second.StreamPos, General_ID).empty()) Sequence->StreamID=Retrieve(Locator->second.StreamKind, Locator->second.StreamPos, General_ID).To_int64u(); Sequence->Delay=float64_int64s(DTS_Delay*1000000000); //Special cases 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; LocatorPossecond.Locators.size(); LocatorPos++) if (Descriptor->second.Locators[LocatorPos]==Locator->first) Sequence->FrameRate_Set(Descriptor->second.SampleRate); } if (Sequence->StreamID!=(int32u)-1) { //Descriptive Metadata std::vector DMScheme1s_List; for (dmsegments::iterator DMSegment=DMSegments.begin(); DMSegment!=DMSegments.end(); ++DMSegment) for (size_t Pos=0; Possecond.TrackIDs.size(); Pos++) if (DMSegment->second.TrackIDs[Pos]==Sequence->StreamID) DMScheme1s_List.push_back(DMSegment->second.Framework); for (size_t Pos=0; PosInfos["Language"]=DMScheme1->second.PrimaryExtendedSpokenLanguage; } } } ReferenceFiles->AddSequence(Sequence); } else { Fill(Stream_General, 0, "UnsupportedSources", Locator->second.EssenceLocator); (*Stream_More)[Stream_General][0](Ztring().From_Local("UnsupportedSources"), Info_Options)=__T("N NT"); } ReferenceFiles->ParseReferences(); } } #endif //defined(MEDIAINFO_REFERENCES_YES) //--------------------------------------------------------------------------- void File_Mxf::NextRandomIndexMetadata() { //We have the necessary for indexes, jumping to next index Skip_XX(Element_Size-Element_Offset, "Data"); if (RandomIndexMetadatas.empty()) { if (!RandomIndexMetadatas_AlreadyParsed) { Partitions_Pos=0; while (Partitions_PosParseSpeed && Config->ParseSpeed<1 && IsParsingMiddle_MaxOffset==(int64u)-1 && File_Size/2>0x4000000) //TODO: 64 MB by default; // Do not search in the middle of the file if quick pass or full pass { 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; } Finish(); } } //NameSpace #endif //MEDIAINFO_MXF_* MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg4_Descriptors.cpp0000664000000000000000000014213412652076434023744 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 #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 "MediaInfo/MediaInfo_Config_MediaInfo.h" #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; PosOfStream=(size_t)-1; 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 if (ObjectTypeId!=0x21 || !Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get()) //0x21 is AVC 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, PosOfStream, "Demux_InitBytes", Data_Base64); if (PosOfStream<(*Parser->Stream_More)[KindOfStream].size()) (*Parser->Stream_More)[KindOfStream][PosOfStream](Ztring().From_Local("Demux_InitBytes"), Info_Options)=__T("N NT"); } 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg_Descriptors.cpp0000664000000000000000000046602312652076434023666 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) #include 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 HEVC=0x48455643; //HEVC 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_teletext_type_more(int8u teletext_type) { switch (teletext_type) { case 0x03 : return "Additional information page"; case 0x04 : return "Programme schedule page"; case 0x05 : return "For hearing impaired people"; default : return ""; } } 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::HEVC : return "HEVC"; 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::HEVC : return Stream_Video; 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::HEVC : return "HEVC"; 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::HEVC : return "HEVC"; 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::HEVC : return Stream_Video; 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 float64 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_system_ID) { switch (CA_system_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 0x4B13 : return "PlayReady"; case 0x5500 : return "Z-Crypt or DRE-Crypt"; case 0x5501 : return "Griffin"; default : return "Encrypted"; } } //--------------------------------------------------------------------------- bool Mpeg_Descriptors_CA_system_ID_MustSkipSlices(int16u CA_system_ID) { switch (CA_system_ID) { case 0x4B13 : // PlayReady return true; default : return false; //We try, it is not sure } } //*************************************************************************** // 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; registration_format_identifier = 0x00000000; stream_type=0x00; event_id=0x0000; elementary_PID_IsValid=false; program_number_IsValid=false; registration_format_identifier_IsValid = false; stream_type_IsValid=false; event_id_IsValid=false; //Out } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- void File_Mpeg_Descriptors::FileHeader_Parse() { Accept(); } //*************************************************************************** // 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 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"); ELEMENT_CASE(30, "SVC extension"); ELEMENT_CASE(31, "MVC extension"); ELEMENT_CASE(32, "J2K video"); ELEMENT_CASE(33, "MVC operation point"); ELEMENT_CASE(34, "MPEG2_stereoscopic_video_format"); ELEMENT_CASE(35, "Stereoscopic_program_info"); ELEMENT_CASE(36, "Stereoscopic_video_info"); ELEMENT_CASE(37, "ODUpdate"); ELEMENT_CASE(38, "Transport_profile"); ELEMENT_CASE(39, "HEVC video"); ELEMENT_CASE(3A, "HEVC timing and HRD"); ELEMENT_CASE(3F, "Extension"); //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"); ELEMENT_CASE(C1, "ARIB - Digital Copy Control"); ELEMENT_CASE(C4, "SMPTE - ANC"); //SMPTE ST 2038 ELEMENT_CASE(C8, "ARIB - Video Decode Control"); ELEMENT_CASE(DE, "ARIB - Content Availability"); ELEMENT_CASE(E9, "CableLabs - Encoder Boundary Point"); ELEMENT_CASE(FC, "ARIB - Emergency Information"); ELEMENT_CASE(FD, "ARIB - Data Component"); 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 if (elementary_PID_IsValid) { //Per PES Complete_Stream->Streams[elementary_PID]->registration_format_identifier=format_identifier; Complete_Stream->Streams[elementary_PID]->Infos["format_identifier"]=Ztring().From_CC4(format_identifier); if (Complete_Stream->Streams[elementary_PID]->Infos["format_identifier"].size()!=4) { Ztring Temp; Temp.From_Number(format_identifier, 16); if (Temp.size()<8) Temp.insert(0, 8-Temp.size(), __T('0')); Complete_Stream->Streams[elementary_PID]->Infos["format_identifier"]=__T("0x")+Temp; } Complete_Stream->Streams[elementary_PID]->Infos_Option["format_identifier"]=__T("N NT"); if (format_identifier==Elements::KLVA) { Complete_Stream->Streams[elementary_PID]->Infos["Format"]=__T("KLV"); Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].HasNotDisplayableStreams=true; } //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 } else { //Per program Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].registration_format_identifier=format_identifier; } break; default : ; } FILLING_ELSE() switch (table_id) { case 0x02 : //program_map_section if (elementary_PID_IsValid) { //Per PES Complete_Stream->Streams[elementary_PID]->Infos["format_identifier"]=__T("(INVALID)"); Complete_Stream->Streams[elementary_PID]->Infos_Option["format_identifier"]=__T("N NT"); } else { //Per program //do nothing } 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) { Complete_Stream->Streams[elementary_PID]->CA_system_ID=CA_system_ID; Complete_Stream->Streams[elementary_PID]->CA_system_ID_MustSkipSlices=Mpeg_Descriptors_CA_system_ID_MustSkipSlices(CA_system_ID); if (CA_PIDStreams.size() && 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_OffsetTransport_Streams[Complete_Stream->transport_stream_id].Infos["Encoded_Library"]=__T("Manzanita Systems"); } if (Element_OffsetStreams[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_OffsetStreams[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_OffsetTransport_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_OffsetTransport_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_OffsetStreams[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["Language_More"]=Mpeg_Descriptors_teletext_type_more(teletext_type); 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_OffsetTimeZones[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_OffsetStreams[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_OffsetTransport_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_7F() { //Parsing int8u descriptor_tag_extension; Get_B1(descriptor_tag_extension, "descriptor_tag_extension"); switch (descriptor_tag_extension) { case 0x0F : Descriptor_7F_0F(); break; default : Skip_XX(Element_Size-Element_Offset, "Unknown"); if (elementary_PID_IsValid) { Ztring &Temp=Complete_Stream->Streams[elementary_PID]->Infos["descriptor_tag_extension"]; if (!Temp.empty()) Temp+=__T(" / "); Temp+=Ztring::ToZtring(descriptor_tag_extension); } } } //--------------------------------------------------------------------------- void File_Mpeg_Descriptors::Descriptor_7F_0F() { //Parsing int8u config_id; Get_B1(config_id, "config_id"); FILLING_BEGIN(); if (elementary_PID_IsValid) { Complete_Stream->Streams[elementary_PID]->Infos["Matrix_Format"]=__T("DTS Neural Audio"); Complete_Stream->Streams[elementary_PID]->Infos["Matrix_ChannelPositions"]=__T("DTS Neural Audio ")+Ztring::ToZtring(config_id); } 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() { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) //Global information Config->File_DtvccTransport_Descriptor_IsPresent=true; if (event_id_IsValid) { delete Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].ServiceDescriptors; Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].ServiceDescriptors=new File__Analyze::servicedescriptors; } else if (elementary_PID_IsValid) { //delete Complete_Stream->Streams[elementary_PID]->ServiceDescriptors; //Complete_Stream->Streams[elementary_PID]->ServiceDescriptors=new File__Analyze::servicedescriptors; Complete_Stream->Streams[elementary_PID]->ServiceDescriptors.ServiceDescriptors608.clear(); Complete_Stream->Streams[elementary_PID]->ServiceDescriptors.ServiceDescriptors708.clear(); Complete_Stream->Streams[elementary_PID]->ServiceDescriptors_IsPresent=true; } else if (program_number_IsValid) { delete Complete_Stream->Transport_Streams[transport_stream_id].Programs[program_number].ServiceDescriptors; Complete_Stream->Transport_Streams[transport_stream_id].Programs[program_number].ServiceDescriptors=new File__Analyze::servicedescriptors; } #endif //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; PosSources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].ServiceDescriptors->ServiceDescriptors708[caption_service_number].language; if (!Value.empty()) Value+=", "; Value+=language; #endif } else { #if defined(MEDIAINFO_EIA608_YES) string &Value=Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].ServiceDescriptors->ServiceDescriptors608[line21_field?1:0].language; if (!Value.empty()) Value+=", "; Value+=language; #endif } } else if (elementary_PID_IsValid) { if (digital_cc) { #if defined(MEDIAINFO_EIA708_YES) string &Value=Complete_Stream->Streams[elementary_PID]->ServiceDescriptors.ServiceDescriptors708[caption_service_number].language; if (!Value.empty()) Value+=", "; Value+=language; #endif } else { #if defined(MEDIAINFO_EIA608_YES) string &Value=Complete_Stream->Streams[elementary_PID]->ServiceDescriptors.ServiceDescriptors608[line21_field?1:0].language; if (!Value.empty()) Value+=", "; Value+=language; #endif } } else if (program_number_IsValid) { if (digital_cc) { #if defined(MEDIAINFO_EIA708_YES) string &Value=Complete_Stream->Transport_Streams[transport_stream_id].Programs[program_number].ServiceDescriptors->ServiceDescriptors708[caption_service_number].language; if (!Value.empty()) Value+=", "; Value+=language; #endif } else { #if defined(MEDIAINFO_EIA608_YES) string &Value=Complete_Stream->Transport_Streams[transport_stream_id].Programs[program_number].ServiceDescriptors->ServiceDescriptors608[line21_field?1:0].language; if (!Value.empty()) Value+=", "; Value+=language; #endif } } #endif } } //--------------------------------------------------------------------------- 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_PosTransport_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; PosStreams.size() && 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::Descriptor_C1() { // ARIB B15 //Parsing int8u copy_control_type; bool maximum_bit_rate_flag, component_control_flag; BS_Begin(); Skip_S1(2, "digital_recording_control_data"); Get_SB ( maximum_bit_rate_flag, "maximum_bit_rate_flag "); Get_SB ( component_control_flag, "component_control_flag "); Get_S1 (2, copy_control_type, "copy_control_type"); //Skip_S1(2, (copy_control_type&0x1)?"copy_control_type":"reserved_future_use"); BS_End(); while (Element_OffsetStreams[elementary_PID]->Infos["EBP_Mode"]=EBP_data_explicit_flag?__T("Explicit"):__T("Implicit"); if (EBP_distance!=(int64u)-1) Complete_Stream->Streams[elementary_PID]->Infos["EBP_Distance"]=ticks_per_second==1?Ztring::ToZtring(EBP_distance):Ztring::ToZtring(((float64)EBP_distance)/ticks_per_second, 3); FILLING_END(); } } //--------------------------------------------------------------------------- void File_Mpeg_Descriptors::Descriptor_FC() { //Parsing Skip_XX(Element_Size, "?"); } //--------------------------------------------------------------------------- void File_Mpeg_Descriptors::Descriptor_FD() { //Parsing int16u data_component_id; Get_B2 (data_component_id, "data_component_id"); while (Element_OffsetStreams[elementary_PID]->Infos["Format"]=__T("ARIB STD B24/B37"); //Complete_Stream->Streams[elementary_PID]->StreamKind=Stream_Text; } break; default : ; } FILLING_END(); } } //--------------------------------------------------------------------------- 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; PosStreams[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>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 MediaInfoLib/Source/MediaInfo/Multiple/File_DcpPkl.h0000664000000000000000000000433512652076434021231 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DCP/IMF Package List files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DcpPklH #define MediaInfo_File_DcpPklH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; //*************************************************************************** // Class File_DcpPkl //*************************************************************************** class File_DcpPkl : public File__Analyze { public : //Constructor/Destructor File_DcpPkl(); ~File_DcpPkl(); //Streams struct stream { stream_t StreamKind; // With special cases: Stream_Max+1 means CPL, Stream_Max+2 means PKL string Id; string OriginalFileName; string Type; string AnnotationText; struct chunk { string Path; }; typedef std::vector chunks; chunks ChunkList; stream() { StreamKind=Stream_Max; } }; typedef std::vector streams; streams Streams; 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(); //AM void MergeFromAm (File_DcpPkl::streams &StreamsToMerge); //Temp File__ReferenceFilesHelper* ReferenceFiles; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Pmp.cpp0000664000000000000000000001176012652076434021143 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PMP_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Pmp.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Info //*************************************************************************** //--------------------------------------------------------------------------- const char* Pmp_video_format(int32u video_format) { switch (video_format) { case 0 : return "MPEG-4 Visual"; case 1 : return "AVC"; default : return ""; } } //--------------------------------------------------------------------------- const char* Pmp_audio_format(int32u audio_format) { switch (audio_format) { case 0 : return "MPEG Audio"; case 1 : return "AAC"; default : return ""; } } //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Pmp::FileHeader_Begin() { //Synchro if (4>Buffer_Size) return false; if (Buffer[0]!=0x70 //"pmpm" || Buffer[1]!=0x6D || Buffer[2]!=0x70 || Buffer[3]!=0x6D) { Reject(); return false; } return true; } //--------------------------------------------------------------------------- void File_Pmp::FileHeader_Parse() { //Parsing int32u version, video_format=0, nb_frames=0, video_width=0, video_height=0, time_base_num=0, time_base_den=0, audio_format=0, sample_rate=0, channels=0; Skip_C4( "Signature"); Get_L4 (version, "Version"); if (version==1) { Get_L4 (video_format, "video_format"); Get_L4 (nb_frames, "number of frames"); Get_L4 (video_width, "video_width"); Get_L4 (video_height, "video_height"); Get_L4 (time_base_num, "time_base_num"); Get_L4 (time_base_den, "time_base_den"); Skip_L4( "number of audio streams"); Get_L4 (audio_format, "audio_format"); Get_L4 (channels, "channels"); Skip_L4( "unknown"); Get_L4 (sample_rate, "sample_rate"); } FILLING_BEGIN(); Accept("PMP"); Fill(Stream_General, 0, General_Format, "PMP"); if (version==1) { Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Format, Pmp_video_format(video_format)); Fill(Stream_Video, 0, Video_FrameCount, nb_frames); Fill(Stream_Video, 0, Video_Width, video_width); Fill(Stream_Video, 0, Video_Height, video_height); Fill(Stream_Video, 0, Video_FrameRate, (float)time_base_den / 100); Stream_Prepare(Stream_Audio); Fill(Stream_Audio, 0, Audio_Format, Pmp_audio_format(audio_format)); Fill(Stream_Audio, 0, Audio_Channel_s_, channels); Fill(Stream_Audio, 0, Audio_SamplingRate, sample_rate); } //No more need data Finish("PMP"); FILLING_END(); } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_PMP_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg_Descriptors.h0000664000000000000000000010567212652076434023333 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about MPEG files, Descriptors // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Mpeg_DescriptorsH #define MediaInfo_Mpeg_DescriptorsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h" #include "MediaInfo/Duplicate/File__Duplicate_MpegTs.h" #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) #include "MediaInfo/File__Analyze.h" #endif #include //--------------------------------------------------------------------------- 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 TimeZones; //Key is country code //Per transport_stream struct transport_stream { bool HasChanged; std::map Infos; struct program { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) File__Analyze::servicedescriptors* ServiceDescriptors; #endif bool HasChanged; std::map Infos; std::map ExtraInfos_Content; std::map ExtraInfos_Option; std::map EPGs; std::vector 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 HasNotDisplayableStreams; //e.g. unknown stream, KLV, SCTE 35 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 events; //Key is event_id events Events; //Key is event_id }; typedef std::map 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 segments; //Key is segmentation_type_id segments Segments; ; }; typedef std::map segmentations; //Key is segmentation_event_id segmentations Segmentations; int16u pid; scte35() { pid=(int16u)-1; } }; scte35* Scte35; //Constructor/Destructor program() : #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) ServiceDescriptors(NULL), #endif 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), HasNotDisplayableStreams(false), Update_Needed_IsRegistered(false), Update_Needed_StreamCount(false), Update_Needed_StreamPos(false), Update_Needed_Info(false), DVB_EPG_Blocks_IsUpdated(false), Scte35(NULL) {} program(const program& p) : HasChanged(p.HasChanged), Infos(p.Infos), ExtraInfos_Content(p.ExtraInfos_Content), ExtraInfos_Option(p.ExtraInfos_Option), EPGs(p.EPGs), elementary_PIDs(p.elementary_PIDs), StreamPos(p.StreamPos), registration_format_identifier(p.registration_format_identifier), pid(p.pid), PCR_PID(p.PCR_PID), source_id(p.source_id), source_id_IsValid(p.source_id_IsValid), IsParsed(p.IsParsed), IsRegistered(p.IsRegistered), HasNotDisplayableStreams(p.HasNotDisplayableStreams), Update_Needed_IsRegistered(p.Update_Needed_IsRegistered), Update_Needed_StreamCount(p.Update_Needed_StreamCount), Update_Needed_StreamPos(p.Update_Needed_StreamPos), Update_Needed_Info(p.Update_Needed_Info), DVB_EPG_Blocks_IsUpdated(p.DVB_EPG_Blocks_IsUpdated), Scte35(p.Scte35) { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (p.ServiceDescriptors) { ServiceDescriptors=new File__Analyze::servicedescriptors; *ServiceDescriptors=*p.ServiceDescriptors; } else ServiceDescriptors=NULL; #endif } program& operator=(const program& p) { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (p.ServiceDescriptors) { ServiceDescriptors=new File__Analyze::servicedescriptors; *ServiceDescriptors=*p.ServiceDescriptors; } else ServiceDescriptors=NULL; #endif HasChanged=p.HasChanged; Infos=p.Infos; ExtraInfos_Content=p.ExtraInfos_Content; ExtraInfos_Option=p.ExtraInfos_Option; EPGs=p.EPGs; elementary_PIDs=p.elementary_PIDs; StreamPos=p.StreamPos; registration_format_identifier=p.registration_format_identifier; pid=p.pid; PCR_PID=p.PCR_PID; source_id=p.source_id; source_id_IsValid=p.source_id_IsValid; IsParsed=p.IsParsed; IsRegistered=p.IsRegistered; HasNotDisplayableStreams=p.HasNotDisplayableStreams; Update_Needed_IsRegistered=p.Update_Needed_IsRegistered; Update_Needed_StreamCount=p.Update_Needed_StreamCount; Update_Needed_StreamPos=p.Update_Needed_StreamPos; Update_Needed_Info=p.Update_Needed_Info; DVB_EPG_Blocks_IsUpdated=p.DVB_EPG_Blocks_IsUpdated; Scte35=p.Scte35; return *this; } ~program() { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) delete ServiceDescriptors; #endif } }; typedef std::map programs; //Key is program_number programs Programs; //Key is program_number std::vector programs_List; 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 iod_ess; //Key is ES_ID std::map IOD_ESs; //Key is ES_ID //ATSC int16u source_id; //Global bool source_id_IsValid; transport_stream() { HasChanged=false; source_id=(int16u)-1; source_id_IsValid=false; Programs_NotParsedCount=(size_t)-1; } }; typedef std::map 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 program_numbers; struct table_id { struct table_id_extension { typedef std::vector section_numbers; //Key is section_number section_numbers Section_Numbers; //Key is section_number int8u version_number; }; typedef std::map 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_ids; table_ids Table_IDs; //Key is table_id std::map Infos; std::map Infos_Option; struct teletext { std::map Infos; stream_t StreamKind; size_t StreamPos; teletext() : StreamKind(Stream_Max) , StreamPos((size_t)-1) {} }; std::map 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; float64 TimeStamp_InstantaneousBitRate_Current_Min; float64 TimeStamp_InstantaneousBitRate_Current_Raw; float64 TimeStamp_InstantaneousBitRate_Current_Max; int64u TimeStamp_InstantaneousBitRate_BitRateMode_IsCbr; int64u TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr; #if MEDIAINFO_ADVANCED float64 TimeStamp_InstantaneousBitRate_Min_Raw; float64 TimeStamp_InstantaneousBitRate_Max_Raw; int64u TimeStamp_Distance_Min; int64u TimeStamp_Distance_Max; int64u TimeStamp_Distance_Total; int64u TimeStamp_Distance_Count; int64u TimeStamp_HasProblems; std::vector TimeStamp_Intermediate; #endif // MEDIAINFO_ADVANCED #endif //MEDIAINFO_MPEGTS_PCR_YES int32u registration_format_identifier; int16u FMC_ES_ID; int16u table_type; //ATSC int8u stream_type; int8u descriptor_tag; int8u DtsNeural_config_id; 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; bool CA_system_ID_MustSkipSlices; bool EBP_IsPresent; size_t Scrambled_Count; int16u CA_system_ID; int16u SubStream_pid; #if MEDIAINFO_IBIUSAGE int64u Ibi_SynchronizationOffset_BeginOfFrame; #endif //MEDIAINFO_IBIUSAGE #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) File__Analyze::servicedescriptors ServiceDescriptors; bool ServiceDescriptors_IsPresent; #endif //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; TimeStamp_InstantaneousBitRate_Current_Min=0; TimeStamp_InstantaneousBitRate_Current_Raw=0; TimeStamp_InstantaneousBitRate_Current_Max=0; TimeStamp_InstantaneousBitRate_BitRateMode_IsCbr=0; TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr=0; #if MEDIAINFO_ADVANCED TimeStamp_InstantaneousBitRate_Min_Raw=DBL_MAX; TimeStamp_InstantaneousBitRate_Max_Raw=0; TimeStamp_Distance_Min=(int64u)-1; TimeStamp_Distance_Max=0; TimeStamp_Distance_Total=0; TimeStamp_Distance_Count=0; TimeStamp_HasProblems=0; #endif // MEDIAINFO_ADVANCED #endif //MEDIAINFO_MPEGTS_PCR_YES registration_format_identifier=0x00000000; FMC_ES_ID=0x0000; table_type=0x0000; stream_type=(int8u)-1; descriptor_tag=(int8u)-1; DtsNeural_config_id=(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; Scrambled_Count=0; CA_system_ID_MustSkipSlices=false; CA_system_ID=0x0000; EBP_IsPresent=false; SubStream_pid=0x0000; #if MEDIAINFO_IBIUSAGE Ibi_SynchronizationOffset_BeginOfFrame=(int64u)-1; #endif //MEDIAINFO_IBIUSAGE #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) ServiceDescriptors_IsPresent=false; #endif } ~stream() { delete Parser; //Parser=NULL; for (size_t Pos=0; Pos 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 texts; struct atsc_epg_block { struct event { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) File__Analyze::servicedescriptors* ServiceDescriptors; #endif int32u start_time; Ztring duration; Ztring title; std::map texts; event() : #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) ServiceDescriptors(NULL), #endif start_time((int32u)-1) {} event(const event& e) : start_time(e.start_time) { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (e.ServiceDescriptors) { ServiceDescriptors=new File__Analyze::servicedescriptors; *ServiceDescriptors=*e.ServiceDescriptors; } else ServiceDescriptors=NULL; #endif } event& operator=(const event& e) { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) if (e.ServiceDescriptors) { ServiceDescriptors=new File__Analyze::servicedescriptors; *ServiceDescriptors=*e.ServiceDescriptors; } else ServiceDescriptors=NULL; #endif start_time=e.start_time; return *this; } ~event() { #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) delete ServiceDescriptors; #endif } }; typedef std::map events; //Key is event_id events Events; //Key is event_id }; typedef std::map 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 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 Duplicates_Speed; std::vector > Duplicates_Speed_FromPID; std::map 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 > StreamPos_ToRemove; std::map PCR_PIDs; //Key is PCR_PID, value is count of programs using it std::set PES_PIDs; //Key is pid std::vector 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); File__Duplicate_HasChanged_ = false; Config_File_Duplicate_Get_AlwaysNeeded_Count = 0; } ~complete_stream() { for (size_t StreamID=0; StreamID::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 - File header void FileHeader_Parse(); //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_30() {Skip_XX(Element_Size, "Data");}; void Descriptor_31() {Skip_XX(Element_Size, "Data");}; void Descriptor_32() {Skip_XX(Element_Size, "Data");}; void Descriptor_33() {Skip_XX(Element_Size, "Data");}; void Descriptor_34() {Skip_XX(Element_Size, "Data");}; void Descriptor_35() {Skip_XX(Element_Size, "Data");}; void Descriptor_36() {Skip_XX(Element_Size, "Data");}; void Descriptor_37() {Skip_XX(Element_Size, "Data");}; void Descriptor_38() {Skip_XX(Element_Size, "Data");}; void Descriptor_39() {Skip_XX(Element_Size, "Data");}; void Descriptor_3A() {Skip_XX(Element_Size, "Data");}; void Descriptor_3F() {Skip_XX(Element_Size, "Data");}; 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(); void Descriptor_7F_0F(); 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");}; void Descriptor_C1(); void Descriptor_C4() {Skip_XX(Element_Size, "Data");}; void Descriptor_C8(); void Descriptor_DE(); void Descriptor_E9(); void Descriptor_FC(); void Descriptor_FD(); //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 MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg4_TimeCode.cpp0000664000000000000000000000675112652076434023140 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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" #include "MediaInfo/TimeCode.h" //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Mpeg4_TimeCode::File_Mpeg4_TimeCode() :File__Analyze() { //Out Pos=(int32u)-1; NumberOfFrames=0; DropFrame=false; NegativeTimes=false; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Mpeg4_TimeCode::Streams_Fill() { if (Pos!=(int32u)-1 && NumberOfFrames) { int64s Pos_Temp=Pos; float64 FrameRate_WithDF=NumberOfFrames; if (DropFrame) { float64 FramesPerHour_NDF=FrameRate_WithDF*60*60; FrameRate_WithDF*=(FramesPerHour_NDF-108)/FramesPerHour_NDF; } Fill(Stream_General, 0, "Delay", Pos_Temp*1000/FrameRate_WithDF, 0); TimeCode TC(Pos_Temp, NumberOfFrames, DropFrame); Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_Type, "Time code"); Fill(Stream_Other, StreamPos_Last, Other_TimeCode_FirstFrame, TC.ToString().c_str()); if (Frame_Count==1) Fill(Stream_Other, StreamPos_Last, Other_TimeCode_Striped, "Yes"); } } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Mpeg4_TimeCode::Read_Buffer_Continue() { //Parsing int32u Position=0; while (Element_Offset Buffers; demux() { } ~demux() { for (size_t Pos=0; Pos 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 Parsers; //Sometimes, we need to do parallel tests Mpeg_TimeStamp TimeStamp_Start; Mpeg_TimeStamp TimeStamp_End; size_t StreamRegistration_Count; size_t StreamOrder; size_t FirstPacketOrder; 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; StreamRegistration_Count=0; StreamOrder=(size_t)-1; FirstPacketOrder=(size_t)-1; Searching_Payload=false; Searching_TimeStamp_Start=false; Searching_TimeStamp_End=false; IsFilled=false; } ~ps_stream() { for (size_t Pos=0; Pos Streams; std::vector Streams_Private1; //There can have multiple streams in one private stream std::vector 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 video_stream_PTS; size_t StreamOrder_CountOfPrivateStreams_Minus1; size_t StreamOrder_CountOfPrivateStreams_Temp; size_t FirstPacketOrder_Last; //Helpers bool Header_Parser_QuickSearch(); //Parsers File__Analyze* ChooseParser_Mpegv(); File__Analyze* ChooseParser_Mpeg4v(); File__Analyze* ChooseParser_Avc(); File__Analyze* ChooseParser_Hevc(); 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_SmpteSt0302(); File__Analyze* ChooseParser_RLE(); File__Analyze* ChooseParser_AribStdB24B37(bool HasCcis=false); 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 Unsynch_Frame_Counts; int64u Seek_Value; int64u Seek_Value_Maximal; int64u Seek_ID; bool Duration_Detected; #endif //MEDIAINFO_SEEK }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_Ism.h0000664000000000000000000000307712652076434020606 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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_Accept (); 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 MediaInfoLib/Source/MediaInfo/Multiple/File_DashMpd.h0000664000000000000000000000320212652076434021364 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about DASH (.mpd) files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_DashMpdH #define MediaInfo_File_DashMpdH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; //*************************************************************************** // Class File_DashMpd //*************************************************************************** class File_DashMpd : public File__Analyze { public : //Constructor/Destructor File_DashMpd(); ~File_DashMpd(); 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(); //Helpers void Representation(); //Temp File__ReferenceFilesHelper* ReferenceFiles; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Multiple/File_SequenceInfo.h0000664000000000000000000000320612652076434022434 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about XML files starting with SEQUENCEINFO // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_SequenceInfoH #define MediaInfo_File_SequenceInfoH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Multiple/File_MpegTs.cpp0000664000000000000000000060424412652076434021613 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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 #include #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_IBIUSAGE && MEDIAINFO_SEEK #include "MediaInfo/Multiple/File_Ibi.h" #endif //MEDIAINFO_IBIUSAGE && MEDIAINFO_SEEK using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constants //*************************************************************************** namespace Elements { const int32u HDMV=0x48444D56; //BluRay } #if !MEDIAINFO_ADVANCED const float64 Config_VbrDetection_Delta=0; const int64u Config_VbrDetection_Occurences=4; #endif // MEDIAINFO_ADVANCED const char* Scte128_tag (int8u tag) { switch (tag) { case 0x00: return "Forbidden"; case 0x01: return "Used by DVB"; case 0x02: return "AU_Information"; case 0xDF: return "Registered"; case 0xFF: return "Reserved"; default : return tag<0xE0?"Reserved":"User private"; } } //*************************************************************************** // 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); extern const char* Mpeg_Descriptors_CA_system_ID(int16u CA_system_ID); //--------------------------------------------------------------------------- //DTS Neural (ETSI EN 300 468 v1.14+) const size_t MpegTs_DtsNeural_2_Count=9; const size_t MpegTs_DtsNeural_6_Count=4; const int8u MpegTs_DtsNeural_Channels_2[MpegTs_DtsNeural_2_Count]= { 0, 3, 4, 5, 6, 7, 8, 6, 7, }; const int8u MpegTs_DtsNeural_Channels_6[MpegTs_DtsNeural_6_Count]= { 0, 6, 7, 8, }; const int8u MpegTs_DtsNeural_Channels(int8u Channels, int8u config_id) { if (config_id==0) return 0; switch (Channels) { case 2 : if (config_id>=MpegTs_DtsNeural_2_Count) return 0; return MpegTs_DtsNeural_Channels_2[config_id]; case 6 : if (config_id>=MpegTs_DtsNeural_6_Count) return 0; return MpegTs_DtsNeural_Channels_6[config_id]; default: return 0; } } const char* MpegTs_DtsNeural_ChannelPositions_2[MpegTs_DtsNeural_2_Count]= { "", "Front: L R, LFE", "Front: L C R, LFE", "Front: L R, Side: L R, LFE", "Front: L C R, Side: L R, LFE", "Front: L C R, Side: L R, Back: C, LFE", "Front: L C R, Side: L R, Back: L R, LFE", "Front: L R, Side: L R, Back: C, LFE", "Front: L R, Side: L R, Back: L R, LFE", }; const char* MpegTs_DtsNeural_ChannelPositions_6[MpegTs_DtsNeural_6_Count]= { "", "Front: L C R, Side: L R", "Front: L C R, Side: L R, Back: C", "Front: L C R, Side: L R, Back: L R", }; const char* MpegTs_DtsNeural_ChannelPositions(int8u Channels, int8u config_id) { if (config_id==0) return ""; switch (Channels) { case 2 : if (config_id>=MpegTs_DtsNeural_2_Count) return ""; return MpegTs_DtsNeural_ChannelPositions_2[config_id]; case 6 : if (config_id>=MpegTs_DtsNeural_6_Count) return ""; return MpegTs_DtsNeural_ChannelPositions_6[config_id]; default: return ""; } } const char* MpegTs_DtsNeural_ChannelPositions2_2[MpegTs_DtsNeural_2_Count]= { "", "2/0/0.1", "3/0/0.1", "2/2/0.1", "3/2/0.1", "3/2/1.1", "3/2/2.1", "2/2/1.1", "2/2/2.1", }; const char* MpegTs_DtsNeural_ChannelPositions2_6[MpegTs_DtsNeural_6_Count]= { "", "3/2/0.1", "3/2/1.1", "3/2/2.1", }; const char* MpegTs_DtsNeural_ChannelPositions2(int8u Channels, int8u config_id) { if (config_id==0) return ""; switch (Channels) { case 2 : if (config_id>=MpegTs_DtsNeural_2_Count) return ""; return MpegTs_DtsNeural_ChannelPositions2_2[config_id]; case 6 : if (config_id>=MpegTs_DtsNeural_6_Count) return ""; return MpegTs_DtsNeural_ChannelPositions2_6[config_id]; default: return ""; } } //--------------------------------------------------------------------------- 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 #ifdef MEDIAINFO_ARIBSTDB24B37_YES FromAribStdB24B37=false; #endif //Data MpegTs_JumpTo_Begin=MediaInfoLib::Config.MpegTs_MaximumOffset_Get(); MpegTs_JumpTo_End=MediaInfoLib::Config.MpegTs_MaximumOffset_Get()/4; MpegTs_ScanUpTo=(int64u)-1; Searching_TimeStamp_Start=true; Complete_Stream=NULL; Begin_MaxDuration=MediaInfoLib::Config.ParseSpeed_Get()>=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 && MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet()) Config->Demux_EventWasSent=true; #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (!IsSub) { #if MEDIAINFO_ADVANCED // TODO: temporary disabling theses options for MPEG-TS, because it does not work as expected if (Config->File_IgnoreSequenceFileSize_Get()) Config->File_IgnoreSequenceFileSize_Set(false); if (Config->File_IgnoreSequenceFilesCount_Get()) Config->File_IgnoreSequenceFilesCount_Set(false); #endif //MEDIAINFO_ADVANCED TestContinuousFileNames(24, Ztring(), true); } } //--------------------------------------------------------------------------- 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::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::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::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) { 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::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, LawRating, Title; for (size_t Pos=0; Possecond.elementary_PIDs.size(); Pos++) { int16u elementary_PID=Program->second.elementary_PIDs[Pos]; if (PerStream_AlwaysParse || Complete_Stream->Streams[elementary_PID]->IsRegistered) { if (!Complete_Stream->Streams[elementary_PID]->Teletexts.empty()) { for (std::map::iterator Teletext=Complete_Stream->Streams[elementary_PID]->Teletexts.begin(); Teletext!=Complete_Stream->Streams[elementary_PID]->Teletexts.end(); ++Teletext) { Ztring Format; Ztring Language; if (Teletext->second.StreamKind!=Stream_Max) { StreamKinds+=Ztring::ToZtring(Teletext->second.StreamKind); StreamPoss+=Ztring::ToZtring(Teletext->second.StreamPos); Format=Retrieve(Teletext->second.StreamKind, Teletext->second.StreamPos, "Format"); Language=Retrieve(Teletext->second.StreamKind, Teletext->second.StreamPos, "Language"); } Formats+=Format+__T(" / "); Codecs+=Format+__T(" / "); StreamKinds+=__T(" / "); StreamPoss+=__T(" / "); elementary_PIDs+=Ztring::ToZtring(elementary_PID)+__T('-')+Ztring::ToZtring(Teletext->first)+__T(" / "); Languages+=Language+__T(" / "); Ztring List_String=Decimal_Hexa(elementary_PID)+__T('-')+Ztring::ToZtring(Teletext->first); List_String+=__T(" ("); List_String+=Format; if (!Language.empty()) { List_String+=__T(", "); List_String+=Language; } List_String+=__T(")"); elementary_PIDs_String+=List_String+__T(" / "); } } else { 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)); if (Format.empty()) Format=Mpeg_Psi_stream_type_Format(Complete_Stream->Streams[elementary_PID]->stream_type, Program->second.registration_format_identifier); if (Format.empty()) { std::map::iterator Format_FromInfo=Complete_Stream->Streams[elementary_PID]->Infos.find("Format"); if (Format_FromInfo!=Complete_Stream->Streams[elementary_PID]->Infos.end()) Format=Format_FromInfo->second; } if (Format.empty()) Program->second.HasNotDisplayableStreams=true; 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); } //Law rating if (Complete_Stream->Streams[elementary_PID] && Complete_Stream->Streams[elementary_PID]->Parser) { Ztring LawRating_Temp=Complete_Stream->Streams[elementary_PID]->Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating_Temp.empty()) LawRating+=LawRating_Temp+__T(" / ");; Ztring Title_Temp=Complete_Stream->Streams[elementary_PID]->Parser->Retrieve(Stream_General, 0, General_Title); if (!Title_Temp.empty()) Title+=Title_Temp+__T(" / "); } } } 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.HasNotDisplayableStreams || !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_numberprogram_number_Order.size(); program_number++) if (Program->firstprogram_number_Order[program_number]) { StreamPos=program_number; for (size_t program_number2=program_number; program_number2program_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); Clear(Stream_Menu, StreamPos_Last, General_StreamOrder); for (size_t programs_List_Pos=0; programs_List_Possecond.programs_List.size(); ++programs_List_Pos) if (Transport_Stream->second.programs_List[programs_List_Pos]==Program->first) Fill(Stream_Menu, StreamPos_Last, General_StreamOrder, programs_List_Pos); for (std::map::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(); for (std::map::iterator Info=Program->second.ExtraInfos_Content.begin(); Info!=Program->second.ExtraInfos_Content.end(); ++Info) Fill(Stream_Menu, StreamPos_Last, Info->first.c_str(), Info->second, true); Program->second.ExtraInfos_Content.clear(); for (std::map::iterator Info=Program->second.ExtraInfos_Option.begin(); Info!=Program->second.ExtraInfos_Option.end(); ++Info) (*Stream_More)[Stream_Menu][StreamPos_Last](Ztring().From_Local(Info->first.c_str()), Info_Options)=Info->second; Program->second.ExtraInfos_Option.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); if (!LawRating.empty()) LawRating.resize(LawRating.size()-3); Fill(Stream_Menu, StreamPos_Last, "LawRating", LawRating, true); if (StreamPos_Last) Clear(Stream_General, 0, General_LawRating); //More than 1 menu, can not be in General part if (!Title.empty()) Title.resize(Title.size()-3); Fill(Stream_Menu, StreamPos_Last, "Title", Title, true); if (StreamPos_Last) Clear(Stream_General, 0, General_Title); //More than 1 menu, can not be in General part } } //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; if (Temp->Parser) Temp->Parser->Open_Buffer_Update(); //Merging from a previous merge size_t Count; if (Temp->StreamKind != Stream_Max && Temp->StreamPos != (size_t)-1 && Temp->Parser) { 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 && !Temp->program_numbers.empty() && !Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.empty()) { 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 registration_format_identifier if (StreamKind_Last==Stream_Max && Temp->registration_format_identifier && Temp->IsRegistered && Mpeg_Descriptors_registration_format_identifier_StreamKind(Temp->registration_format_identifier)!=Stream_Max) { StreamKind_Last=Mpeg_Descriptors_registration_format_identifier_StreamKind(Temp->registration_format_identifier); Stream_Prepare(StreamKind_Last); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), Mpeg_Descriptors_registration_format_identifier_Format(Temp->registration_format_identifier)); Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Mpeg_Descriptors_registration_format_identifier_Format(Temp->registration_format_identifier)); Count=1; } //By the stream_type if (StreamKind_Last==Stream_Max && Complete_Stream->transport_stream_id_IsValid && !Temp->program_numbers.empty() && !Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.empty()) { 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 || (!Temp->program_numbers.empty() && 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->CA_system_ID) Fill(StreamKind_Last, StreamPos, "Encryption", Mpeg_Descriptors_CA_system_ID(Temp->CA_system_ID)); else if (Temp->Scrambled_Count>16) Fill(StreamKind_Last, StreamPos, "Encryption", "Encrypted"); //TS info for (std::map::iterator Info=Temp->Infos.begin(); Info!=Temp->Infos.end(); ++Info) { if (Retrieve(StreamKind_Last, StreamPos, Info->first.c_str()).empty()) { //Special case : DTS Neural if (StreamKind_Last==Stream_Audio && Info->first=="Matrix_ChannelPositions" && Info->second.find(__T("DTS Neural Audio "))==0) { int8u Channels=Retrieve(Stream_Audio, StreamPos, Audio_Channel_s_).To_int8u(); if (Channels) { int8u config_id=Ztring(Info->second.substr(17, string::npos)).To_int8u(); int8u Matrix_Channels=MpegTs_DtsNeural_Channels(Channels, config_id); if (Matrix_Channels) { Fill(Stream_Audio, StreamPos, Audio_Matrix_Channel_s_, Matrix_Channels); Fill(Stream_Audio, StreamPos, Audio_Matrix_ChannelPositions, MpegTs_DtsNeural_ChannelPositions(Channels, config_id)); Fill(Stream_Audio, StreamPos, Audio_ChannelPositions_String2, MpegTs_DtsNeural_ChannelPositions2(Channels, config_id)); } } } else Fill(StreamKind_Last, StreamPos, Info->first.c_str(), Info->second, true); } } Temp->Infos.clear(); for (std::map::iterator Info=Temp->Infos_Option.begin(); Info!=Temp->Infos_Option.end(); ++Info) (*Stream_More)[StreamKind_Last][StreamPos](Ztring().From_Local(Info->first.c_str()), Info_Options)=Info->second; Temp->Infos_Option.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 || (StreamKind_Last==Stream_Text && Retrieve(StreamKind_Last, StreamPos, General_ID).find(__T('-'))!=string::npos)) { Ztring ID=Retrieve(StreamKind_Last, StreamPos, General_ID); size_t ID_Pos=ID.find(__T('-')); if (ID_Pos!=string::npos) ID.erase(ID.begin(), ID.begin()+ID_Pos+1); //Removing the PS part Ztring ID_String=Retrieve(StreamKind_Last, StreamPos, General_ID_String); size_t ID_String_Pos=ID_String.find(__T('-')); if (ID_String_Pos!=string::npos) ID_String.erase(ID_String.begin(), ID_String.begin()+ID_String_Pos+1); //Removing the PS part #ifdef MEDIAINFO_ARIBSTDB24B37_YES if (FromAribStdB24B37) { Fill(StreamKind_Last, StreamPos, General_ID, ID, true); Fill(StreamKind_Last, StreamPos, General_ID_String, ID_String, true); } else #endif //MEDIAINFO_ARIBSTDB24B37_YES { 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; Posprogram_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); } //StreamOrder Clear(StreamKind_Last, StreamPos, General_StreamOrder); for (size_t program_FromStream=0; program_FromStreamprogram_numbers.size(); ++program_FromStream) { int16u program_number=Temp->program_numbers[program_FromStream]; std::vector &programs_List=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].programs_List; size_t programs_List_Pos=0; for (; programs_List_PosTransport_Streams[Complete_Stream->transport_stream_id].Programs[program_number]; for (size_t elementary_PID_Pos=0; elementary_PID_PosParser && Temp->Parser->Count_Get(Stream_Text)) { } } //Special cases if (Temp->Parser && Temp->Parser->Count_Get(Stream_Video)) { //Video and Text may be together size_t Text_Count=Temp->Parser->Count_Get(Stream_Text); for (size_t Text_Pos=0; Text_PosParser->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; PosParser->Retrieve(Stream_Text, Text_Pos, "MuxingMode")) { StreamPos_Last=Pos; break; } if (StreamPos_Last==(size_t)-1) Stream_Prepare(Stream_Text, StreamPos_Last); if (!IsSub) Fill(Stream_Text, StreamPos_Last, "MuxingMode_MoreInfo", __T("Muxed in Video #")+Ztring().From_Number(Temp->StreamPos+1), true); Merge(*Temp->Parser, Stream_Text, Text_Pos, StreamPos_Last); 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_StreamOrder, Retrieve(Stream_Video, Temp->StreamPos, Video_StreamOrder), 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); } StreamKind_Last=Temp->StreamKind; StreamPos_Last=Temp->StreamPos; } } //Teletext if (StreamKind_Last==Stream_Max) { for (std::map::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; Posprogram_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::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(); Teletext->second.StreamKind=StreamKind_Last; Teletext->second.StreamPos=StreamPos_Last; } } //Law rating if (Temp->Parser) { Ztring LawRating=Temp->Parser->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) { if (Count_Get(Stream_Menu)) { Ztring MenuID=Retrieve(Temp->StreamKind, Temp->StreamPos, General_MenuID); for (size_t Pos=0; PosParser) { Ztring Title=Temp->Parser->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) { if (Count_Get(Stream_Menu)) { Ztring MenuID=Retrieve(Temp->StreamKind, Temp->StreamPos, General_MenuID); for (size_t Pos=0; Postransport_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 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::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=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::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 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::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::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::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() { bool IsVbr=false; bool IsCbr=false; #if MEDIAINFO_ADVANCED float64 TimeStamp_InstantaneousBitRate_Min_Raw=DBL_MAX; float64 TimeStamp_InstantaneousBitRate_Max_Raw=0; int64u TimeStamp_Distance_Min=(int64u)-1; int64u TimeStamp_Distance_Max=0; int64u TimeStamp_Distance_Total=0; int64u TimeStamp_Distance_Count=0; int64u TimeStamp_HasProblems=0; #endif // MEDIAINFO_ADVANCED for (std::map::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 && (*Stream)->TimeStamp_End_IsUpdated) { if ((*Stream)->TimeStamp_End<0x100000000LL*300 && (*Stream)->TimeStamp_Start>0x100000000LL*300) (*Stream)->TimeStamp_End+=0x200000000LL*300; //33 bits, cyclic if ((*Stream)->TimeStamp_Start<(*Stream)->TimeStamp_End) { int64u Duration=0; int64u Bytes=0; #if MEDIAINFO_ADVANCED if (Config->ParseSpeed>=1 && !(*Stream)->TimeStamp_Intermediate.empty()) { Duration=(*Stream)->TimeStamp_Intermediate[0]-(*Stream)->TimeStamp_Start; size_t Last=(*Stream)->TimeStamp_Intermediate.size()-1; for (size_t Pos=1; Pos+1TimeStamp_Intermediate[Pos+1]-(*Stream)->TimeStamp_Intermediate[Pos]; Duration+=(*Stream)->TimeStamp_End-(*Stream)->TimeStamp_Intermediate[Last]; } else #endif // MEDIAINFO_ADVANCED { Duration=(*Stream)->TimeStamp_End-(*Stream)->TimeStamp_Start; } Bytes=(*Stream)->TimeStamp_End_Offset-(*Stream)->TimeStamp_Start_Offset; if (Duration && Bytes) { Fill(Stream_General, 0, General_Duration, ((float64)Duration)/27000, 6, true); Fill(Stream_General, 0, General_OverallBitRate, Bytes*8/(((float64)Duration)/27000000), 0, true); } (*Stream)->TimeStamp_End_IsUpdated=false; (*Stream)->IsPCR_Duration=(float64)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, ((float64)Duration)/27000, 6, true); } } } } if ((*Stream)->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr>=Config_VbrDetection_Occurences) IsVbr=true; if ((*Stream)->TimeStamp_InstantaneousBitRate_BitRateMode_IsCbr) IsCbr=true; #if MEDIAINFO_ADVANCED if (Config->ParseSpeed>=1) { if (TimeStamp_InstantaneousBitRate_Min_Raw>(*Stream)->TimeStamp_InstantaneousBitRate_Min_Raw) TimeStamp_InstantaneousBitRate_Min_Raw=(*Stream)->TimeStamp_InstantaneousBitRate_Min_Raw; if (TimeStamp_InstantaneousBitRate_Max_Raw<(*Stream)->TimeStamp_InstantaneousBitRate_Max_Raw) TimeStamp_InstantaneousBitRate_Max_Raw=(*Stream)->TimeStamp_InstantaneousBitRate_Max_Raw; TimeStamp_Distance_Total+=(*Stream)->TimeStamp_Distance_Total; TimeStamp_Distance_Count+=(*Stream)->TimeStamp_Distance_Count; if (TimeStamp_Distance_Min>(*Stream)->TimeStamp_Distance_Min) TimeStamp_Distance_Min=(*Stream)->TimeStamp_Distance_Min; if (TimeStamp_Distance_Max<(*Stream)->TimeStamp_Distance_Max) TimeStamp_Distance_Max=(*Stream)->TimeStamp_Distance_Max; TimeStamp_HasProblems+=(*Stream)->TimeStamp_HasProblems; } #endif // MEDIAINFO_ADVANCED } } if (IsVbr) Fill(Stream_General, 0, General_OverallBitRate_Mode, "VBR", Unlimited, true, true); else if (IsCbr) Fill(Stream_General, 0, General_OverallBitRate_Mode, "CBR", Unlimited, true, true); else Clear(Stream_General, 0, General_OverallBitRate_Mode); #if MEDIAINFO_ADVANCED if (Config->ParseSpeed>=1) { if ((IsVbr || !IsCbr) && TimeStamp_InstantaneousBitRate_Min_RawDuration_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, false); 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_IBICREATE if (!IsSub && Config_Ibi_Create) { for (ibi::streams::iterator IbiStream_Temp=Ibi.Streams.begin(); IbiStream_Temp!=Ibi.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; Possecond->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; Possecond->Infos.size(); Pos++) { int64u Temp=IbiStream_Temp->second->Infos[Pos].Dts*90/1000000; IbiStream_Temp->second->Infos[Pos].Dts=Temp; } } } } } #endif //MEDIAINFO_IBIUSAGE } //*************************************************************************** // Buffer - Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File_MpegTs::Synchronize() { //Synchronizing while ( Buffer_Offset+188*16+BDAV_Size*16+TSP_Size*16<=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[Buffer_Offset+188* 8+BDAV_Size* 9+TSP_Size* 8]==0x47 && Buffer[Buffer_Offset+188* 9+BDAV_Size*10+TSP_Size* 9]==0x47 && Buffer[Buffer_Offset+188*10+BDAV_Size*11+TSP_Size*10]==0x47 && Buffer[Buffer_Offset+188*11+BDAV_Size*12+TSP_Size*11]==0x47 && Buffer[Buffer_Offset+188*12+BDAV_Size*13+TSP_Size*12]==0x47 && Buffer[Buffer_Offset+188*13+BDAV_Size*14+TSP_Size*13]==0x47 && Buffer[Buffer_Offset+188*14+BDAV_Size*15+TSP_Size*14]==0x47 && Buffer[Buffer_Offset+188*15+BDAV_Size*16+TSP_Size*15]==0x47)) { Buffer_Offset++; while ( Buffer_Offset+BDAV_Size+1<=Buffer_Size && Buffer[Buffer_Offset+BDAV_Size]!=0x47) Buffer_Offset++; } if (Buffer_Offset+188*16+BDAV_Size*16+TSP_Size*16>=Buffer_Size #ifdef MEDIAINFO_ARIBSTDB24B37_YES && !FromAribStdB24B37 #endif ) 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 true; } //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_IBIUSAGE 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_IBIUSAGE 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) { int8u adaptation_field_length=Buffer[Buffer_Offset+BDAV_Size+4]; if (adaptation_field_length>=5) //adaptation_field_length { bool discontinuity_indicator=(Buffer[Buffer_Offset+BDAV_Size+5]&0x80)!=0; 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); if (program_clock_reference!=Complete_Stream->Streams[pid]->TimeStamp_End) //Some PCRs are buggy (low precision), using the first stream offset in the case of duplicate PCR value { if (Complete_Stream->Streams[pid]->TimeStamp_End_Offset!=(int64u)-1) { if (program_clock_reference+0x12c00000000LLStreams[pid]->TimeStamp_End) program_clock_reference+=0x25800000000LL; //33 bits and *300 if (!discontinuity_indicator && program_clock_reference>Complete_Stream->Streams[pid]->TimeStamp_End && program_clock_referenceStreams[pid]->TimeStamp_End+10*27000000) //Not before, not after 10 seconds, else there is a problem { float64 Duration_InstantaneousBitRate_Min=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End-(Config_VbrDetection_Delta?0:810)); float64 Duration_InstantaneousBitRate_Max=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End+(Config_VbrDetection_Delta?0:810)); float64 Bytes_InstantaneousBitRate=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); float64 TimeStamp_InstantaneousBitRate_Current_Min=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Max*27000000*(1-Config_VbrDetection_Delta); float64 TimeStamp_InstantaneousBitRate_Current_Raw=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Min*27000000; float64 TimeStamp_InstantaneousBitRate_Current_Max=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Min*27000000*(1+Config_VbrDetection_Delta); if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Min) { if (TimeStamp_InstantaneousBitRate_Current_MaxStreams[pid]->TimeStamp_InstantaneousBitRate_Current_Min || TimeStamp_InstantaneousBitRate_Current_Min>Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Max) { Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr++; #if MEDIAINFO_ADVANCED if (Config_VbrDetection_GiveUp && Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr>=Config_VbrDetection_Occurences) Config->ParseSpeed=0; #endif // MEDIAINFO_ADVANCED } else Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsCbr++; } float64 Duration_Min=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End-1); float64 Duration_Raw=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End); float64 Duration_Max=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End+1); float64 Bytes=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); float64 TimeStamp_Min=Bytes*8/Duration_Max*27000000*(1-Config_VbrDetection_Delta); float64 TimeStamp_Raw=Bytes*8/Duration_Raw*27000000; float64 TimeStamp_Max=Bytes*8/Duration_Min*27000000*(1+Config_VbrDetection_Delta); Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Min=TimeStamp_Min; Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw=TimeStamp_Raw; Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Max=TimeStamp_Max; #if MEDIAINFO_ADVANCED if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Min_Raw>TimeStamp_InstantaneousBitRate_Current_Raw) Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Min_Raw=TimeStamp_InstantaneousBitRate_Current_Raw; if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Max_RawStreams[pid]->TimeStamp_InstantaneousBitRate_Max_Raw=TimeStamp_InstantaneousBitRate_Current_Raw; int64u Distance=program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End; if (Complete_Stream->Streams[pid]->TimeStamp_Distance_Min>Distance) Complete_Stream->Streams[pid]->TimeStamp_Distance_Min=Distance; if (Complete_Stream->Streams[pid]->TimeStamp_Distance_MaxStreams[pid]->TimeStamp_Distance_Max=Distance; Complete_Stream->Streams[pid]->TimeStamp_Distance_Total+=Distance; Complete_Stream->Streams[pid]->TimeStamp_Distance_Count++; #endif // MEDIAINFO_ADVANCED } #if MEDIAINFO_ADVANCED else { if (!discontinuity_indicator) Complete_Stream->Streams[pid]->TimeStamp_HasProblems++; float64 Bytes=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); int64u TimeToAdd; if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw) TimeToAdd=float64_int64s(Bytes*8/Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw*27000000); else TimeToAdd=0; Complete_Stream->Streams[pid]->TimeStamp_Intermediate.push_back(Complete_Stream->Streams[pid]->TimeStamp_End+TimeToAdd); Complete_Stream->Streams[pid]->TimeStamp_Intermediate.push_back(program_clock_reference); } #endif // MEDIAINFO_ADVANCED } 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)*2Streams[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; if (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; } } } } } } } } #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; } if (File_Offset+Buffer_Size>=File_Size) Detect_EOF(); //for TRP files 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; // Program Association Table 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; // Conditional Access Table Complete_Stream->Streams[0x0001]->Table_IDs.resize(0x100); Complete_Stream->Streams[0x0001]->Table_IDs[0x01]=new complete_stream::stream::table_id; // CA_section Complete_Stream->Streams[0x0002]->Searching_Payload_Start_Set(true); Complete_Stream->Streams[0x0002]->Kind=complete_stream::stream::psi; // Transport Stream Description Table Complete_Stream->Streams[0x0002]->Table_IDs.resize(0x100); Complete_Stream->Streams[0x0003]->Searching_Payload_Start_Set(true); Complete_Stream->Streams[0x0003]->Kind=complete_stream::stream::psi; // IPMP Control Information Table Complete_Stream->Streams[0x0003]->Table_IDs.resize(0x100); //Temp MpegTs_JumpTo_Begin=(File_Offset_FirstSynched==(int64u)-1?0:Buffer_TotalBytes_LastSynched)+MediaInfoLib::Config.MpegTs_MaximumOffset_Get(); MpegTs_JumpTo_End=MediaInfoLib::Config.MpegTs_MaximumOffset_Get()/4; 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; #if MEDIAINFO_ADVANCED Config_VbrDetection_Delta=MediaInfoLib::Config.MpegTs_VbrDetection_Delta_Get(); Config_VbrDetection_Occurences=MediaInfoLib::Config.MpegTs_VbrDetection_Occurences_Get(); Config_VbrDetection_GiveUp=MediaInfoLib::Config.MpegTs_VbrDetection_GiveUp_Get(); #endif // MEDIAINFO_ADVANCED #ifdef MEDIAINFO_ARIBSTDB24B37_YES if (FromAribStdB24B37) { #if MEDIAINFO_EVENTS StreamIDs_Width[0]=0; #endif //MEDIAINFO_EVENTS SetAllToPES(); } #endif //MEDIAINFO_ARIBSTDB24B37_YES //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::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 if (File_GoTo==0) Complete_Stream->Streams[StreamID]->Parser->Unsynch_Frame_Count=0; Complete_Stream->Streams[StreamID]->Parser->Open_Buffer_Unsynch(); } #if MEDIAINFO_IBIUSAGE 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_IBIUSAGE } 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; StreamPosParseSpeed>=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, false); 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 SetAllToPES(); 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::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; PosStreams[*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::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; // if (!(Buffer_TotalBytes-Buffer_TotalBytes_FirstSynched>=MpegTs_JumpTo_Begin && Config->ParseSpeed<0.8)) { MpegTs_JumpTo_Begin=File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched; MpegTs_JumpTo_End=MpegTs_JumpTo_Begin; //Avoid too short duration of the end. e.g. with quick pass, MpegTs_JumpTo_End may have content only for 2 frames which is not enough for catching an I-frame at the end of the file. Forcing to 2 seconds if (Config->ParseSpeed < 0.5) { complete_stream::streams::iterator It_End=Complete_Stream->Streams.end(); for (complete_stream::streams::iterator It=Complete_Stream->Streams.begin(); It!=It_End; ++It) { complete_stream::stream* &Stream=*It; if (Stream && Stream->Kind==complete_stream::stream::pes && Stream->TimeStamp_Start!=(int64u)-1) { int64u Duration=Stream->TimeStamp_End-Stream->TimeStamp_Start; if (Duration<27000000*2) // 2 seconds { int64u Ratio=(27000000*2)/Duration; MpegTs_JumpTo_End*=Ratio; break; //Using the first PES found } } } } if (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; } } //Jumping if (Config->ParseSpeed<1.0 && Config->File_IsSeekable_Get() #if MEDIAINFO_ADVANCED && (!Config->File_IgnoreSequenceFileSize_Get() || Config->File_Names_Pos!=Config->File_Names.size()) // TODO: temporary disabling theses options for MPEG-TS (see above), because it does not work as expected #endif //MEDIAINFO_ADVANCED && MpegTs_ScanUpTo == (int64u)-1 && File_Offset+Buffer_SizeFile_DtvccTransport_Stream_IsPresent && !Config->File_DtvccTransport_Descriptor_IsPresent) #if defined(MEDIAINFO_EIA608_YES) || Config->File_Scte20_IsPresent #endif //defined(MEDIAINFO_EIA608_YES) )) { MpegTs_ScanUpTo=File_Size/2+MpegTs_JumpTo_Begin; GoTo(File_Size/2-MpegTs_JumpTo_Begin); } else #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) GoToFromEnd(MpegTs_JumpTo_End); Searching_TimeStamp_Start=false; #endif //!defined(MEDIAINFO_MPEGTS_PCR_YES) && !defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES) Open_Buffer_Unsynch(); } } } if (MpegTs_ScanUpTo != (int64u)-1 && File_Offset+Buffer_Size>=MpegTs_ScanUpTo) { MpegTs_ScanUpTo = (int64u)-1; GoToFromEnd(MpegTs_JumpTo_End); 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; #if MEDIAINFO_DEMUX Config->Demux_IsSeeking=false; #endif //MEDIAINFO_DEMUX //Init if (!Duration_Detected) { //External IBI #if MEDIAINFO_IBIUSAGE 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()); Config->File_Names.Separator_Set(0, ","); 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 (size_t)-1; 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; Possecond->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 } #endif //#if MEDIAINFO_IBIUSAGE 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_IBIUSAGE { 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()) { for (IbiStream_Temp=Ibi.Streams.begin(); IbiStream_Temp!=Ibi.Streams.end(); ++IbiStream_Temp) if (!IbiStream_Temp->second->Infos.empty()) break; if (IbiStream_Temp==Ibi.Streams.end()) 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; Possecond->Infos.size(); Pos++) { if (Value<=IbiStream_Temp->second->Infos[Pos].Dts || Pos+1==IbiStream_Temp->second->Infos.size()) { if (Valuesecond->Infos[Pos].Dts && Pos) Pos--; //Checking continuity of Ibi if (!IbiStream_Temp->second->Infos[Pos].IsContinuous && Pos+1second->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_IBIUSAGE return (size_t)-2; //Not supported / IBI disabled #endif //MEDIAINFO_IBIUSAGE case 3 : //FrameNumber #if MEDIAINFO_IBIUSAGE { 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()) { for (IbiStream_Temp=Ibi.Streams.begin(); IbiStream_Temp!=Ibi.Streams.end(); ++IbiStream_Temp) if (!IbiStream_Temp->second->Infos.empty()) break; if (IbiStream_Temp==Ibi.Streams.end()) return 5; //Invalid ID } for (size_t Pos=0; Possecond->Infos.size(); Pos++) { if (Value<=IbiStream_Temp->second->Infos[Pos].FrameNumber || Pos+1==IbiStream_Temp->second->Infos.size()) { if (Valuesecond->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_IBIUSAGE return (size_t)-2; //Not supported / IBI disabled #endif //MEDIAINFO_IBIUSAGE 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 //False positives detection: detect some headers from other files, DV parser is not smart enough if (CC8(Buffer+Buffer_Offset)==0x444C472056312E30LL //DLG || 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 { 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; PosStreams[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]->Scrambled_Count++; } else if (Element_Offset+TSP_Size0) Complete_Stream->Streams[pid]->Scrambled_Count++; } //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 discontinuity_indicator, PCR_flag, OPCR_flag, splicing_point_flag, transport_private_data_flag, adaptation_field_extension_flag; BS_Begin(); Get_SB ( discontinuity_indicator, "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); if (program_clock_reference!=Complete_Stream->Streams[pid]->TimeStamp_End) //Some PCRs are buggy (low precision), using the first stream offset in the case of duplicate PCR value { if (Complete_Stream->Streams[pid]->TimeStamp_End_Offset!=(int64u)-1) { if (program_clock_reference+0x12c00000000LLStreams[pid]->TimeStamp_End) program_clock_reference+=0x25800000000LL; //33 bits and *300 if (!discontinuity_indicator && program_clock_reference>Complete_Stream->Streams[pid]->TimeStamp_End && program_clock_referenceStreams[pid]->TimeStamp_End+10*27000000) //Not before, not after 10 seconds, else there is a problem { float64 Duration_InstantaneousBitRate_Min=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End-(Config_VbrDetection_Delta?0:810)); float64 Duration_InstantaneousBitRate_Max=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End+(Config_VbrDetection_Delta?0:810)); float64 Bytes_InstantaneousBitRate=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); float64 TimeStamp_InstantaneousBitRate_Current_Min=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Max*27000000*(1-Config_VbrDetection_Delta); float64 TimeStamp_InstantaneousBitRate_Current_Raw=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Min*27000000; float64 TimeStamp_InstantaneousBitRate_Current_Max=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Min*27000000*(1+Config_VbrDetection_Delta); if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Min) { if (TimeStamp_InstantaneousBitRate_Current_MaxStreams[pid]->TimeStamp_InstantaneousBitRate_Current_Min || TimeStamp_InstantaneousBitRate_Current_Min>Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Max) { Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr++; #if MEDIAINFO_ADVANCED if (Config_VbrDetection_GiveUp && Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr>=Config_VbrDetection_Occurences) Config->ParseSpeed=0; #endif // MEDIAINFO_ADVANCED } else Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsCbr++; } float64 Duration_Min=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End-1); float64 Duration_Raw=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End); float64 Duration_Max=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End+1); float64 Bytes=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); float64 TimeStamp_Min=Bytes*8/Duration_Max*27000000*(1-Config_VbrDetection_Delta); float64 TimeStamp_Raw=Bytes*8/Duration_Raw*27000000; float64 TimeStamp_Max=Bytes*8/Duration_Min*27000000*(1+Config_VbrDetection_Delta); Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Min=TimeStamp_Min; Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw=TimeStamp_Raw; Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Max=TimeStamp_Max; #if MEDIAINFO_ADVANCED if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Min_Raw>TimeStamp_InstantaneousBitRate_Current_Raw) Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Min_Raw=TimeStamp_InstantaneousBitRate_Current_Raw; if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Max_RawStreams[pid]->TimeStamp_InstantaneousBitRate_Max_Raw=TimeStamp_InstantaneousBitRate_Current_Raw; int64u Distance=program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End; if (Complete_Stream->Streams[pid]->TimeStamp_Distance_Min>Distance) Complete_Stream->Streams[pid]->TimeStamp_Distance_Min=Distance; if (Complete_Stream->Streams[pid]->TimeStamp_Distance_MaxStreams[pid]->TimeStamp_Distance_Max=Distance; Complete_Stream->Streams[pid]->TimeStamp_Distance_Total+=Distance; Complete_Stream->Streams[pid]->TimeStamp_Distance_Count++; #endif // MEDIAINFO_ADVANCED } #if MEDIAINFO_ADVANCED else { if (!discontinuity_indicator) Complete_Stream->Streams[pid]->TimeStamp_HasProblems++; float64 Bytes=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); int64u TimeToAdd; if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw) TimeToAdd=float64_int64s(Bytes*8/Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw*27000000); else TimeToAdd=0; Complete_Stream->Streams[pid]->TimeStamp_Intermediate.push_back(Complete_Stream->Streams[pid]->TimeStamp_End+TimeToAdd); Complete_Stream->Streams[pid]->TimeStamp_Intermediate.push_back(program_clock_reference); } #endif // MEDIAINFO_ADVANCED } 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)*2Streams[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; if (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; } } } } #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) transport_private_data(transport_private_data_length); 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_Offset188-4-1) //TS size - header - adaptation_field_length adaptation_field_length=188-4-1; else if (adaptation_field_length) { bool discontinuity_indicator=(Buffer[Buffer_Offset+BDAV_Size+5]&0x80)!=0; bool PCR_flag=(Buffer[Buffer_Offset+BDAV_Size+5]&0x10)!=0; bool OPCR_flag=(Buffer[Buffer_Offset+BDAV_Size+5]&0x08)!=0; bool splicing_point_flag=(Buffer[Buffer_Offset+BDAV_Size+5]&0x04)!=0; bool transport_private_data_flag=(Buffer[Buffer_Offset+BDAV_Size+5]&0x02)!=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); if (program_clock_reference!=Complete_Stream->Streams[pid]->TimeStamp_End) //Some PCRs are buggy (low precision), using the first stream offset in the case of duplicate PCR value { if (Complete_Stream->Streams[pid]->TimeStamp_End_Offset!=(int64u)-1) { if (program_clock_reference+0x12c00000000LLStreams[pid]->TimeStamp_End) program_clock_reference+=0x25800000000LL; //33 bits and *300 if (!discontinuity_indicator && program_clock_reference>Complete_Stream->Streams[pid]->TimeStamp_End && program_clock_referenceStreams[pid]->TimeStamp_End+10*27000000) //Not before, not after 10 seconds, else there is a problem { float64 Duration_InstantaneousBitRate_Min=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End-(Config_VbrDetection_Delta?0:810)); float64 Duration_InstantaneousBitRate_Max=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End+(Config_VbrDetection_Delta?0:810)); float64 Bytes_InstantaneousBitRate=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); float64 TimeStamp_InstantaneousBitRate_Current_Min=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Max*27000000*(1-Config_VbrDetection_Delta); float64 TimeStamp_InstantaneousBitRate_Current_Max=Bytes_InstantaneousBitRate*8/Duration_InstantaneousBitRate_Min*27000000*(1+Config_VbrDetection_Delta); if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Min) { if (TimeStamp_InstantaneousBitRate_Current_MaxStreams[pid]->TimeStamp_InstantaneousBitRate_Current_Min || TimeStamp_InstantaneousBitRate_Current_Min>Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Max) { Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr++; #if MEDIAINFO_ADVANCED if (Config_VbrDetection_GiveUp && Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsVbr>=Config_VbrDetection_Occurences) Config->ParseSpeed=0; #endif // MEDIAINFO_ADVANCED } else Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_BitRateMode_IsCbr++; } float64 Duration_Min=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End-1); float64 Duration_Raw=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End); float64 Duration_Max=(float64)(program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End+1); float64 Bytes=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); float64 InstantaneousBitRate_Min=Bytes*8/Duration_Max*27000000*(1-Config_VbrDetection_Delta); float64 InstantaneousBitRate_Raw=Bytes*8/Duration_Raw*27000000; float64 InstantaneousBitRate_Max=Bytes*8/Duration_Min*27000000*(1+Config_VbrDetection_Delta); Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Min=InstantaneousBitRate_Min; Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw=InstantaneousBitRate_Raw; Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Max=InstantaneousBitRate_Max; #if MEDIAINFO_ADVANCED if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Min_Raw>InstantaneousBitRate_Raw) Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Min_Raw=InstantaneousBitRate_Raw; if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Max_RawStreams[pid]->TimeStamp_InstantaneousBitRate_Max_Raw=InstantaneousBitRate_Raw; int64u Distance=program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_End; if (Complete_Stream->Streams[pid]->TimeStamp_Distance_Min>Distance) Complete_Stream->Streams[pid]->TimeStamp_Distance_Min=Distance; if (Complete_Stream->Streams[pid]->TimeStamp_Distance_MaxStreams[pid]->TimeStamp_Distance_Max=Distance; Complete_Stream->Streams[pid]->TimeStamp_Distance_Total+=Distance; Complete_Stream->Streams[pid]->TimeStamp_Distance_Count++; #endif // MEDIAINFO_ADVANCED } #if MEDIAINFO_ADVANCED else { if (!discontinuity_indicator) Complete_Stream->Streams[pid]->TimeStamp_HasProblems++; float64 Bytes=(float64)(File_Offset+Buffer_Offset-Complete_Stream->Streams[pid]->TimeStamp_End_Offset); int64u TimeToAdd; if (Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw) TimeToAdd=float64_int64s(Bytes*8/Complete_Stream->Streams[pid]->TimeStamp_InstantaneousBitRate_Current_Raw*27000000); else TimeToAdd=0; Complete_Stream->Streams[pid]->TimeStamp_Intermediate.push_back(Complete_Stream->Streams[pid]->TimeStamp_End+TimeToAdd); Complete_Stream->Streams[pid]->TimeStamp_Intermediate.push_back(program_clock_reference); } #endif // MEDIAINFO_ADVANCED } 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)*2Streams[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; if (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; } } } } } if (transport_private_data_flag && adaptation_field_length>1+(PCR_flag?6:0)+(OPCR_flag?6:0)+(splicing_point_flag?1:0)+1) { int8u transport_private_data_length=Buffer[Buffer_Offset+BDAV_Size+5+1+(PCR_flag?6:0)+(OPCR_flag?6:0)+(splicing_point_flag?1:0)]; if (1+(PCR_flag?6:0)+(OPCR_flag?6:0)+(splicing_point_flag?1:0)+1+transport_private_data_length<=adaptation_field_length) { int64u Element_Offset_Save=Element_Offset; Element_Offset=5+1+(PCR_flag?6:0)+(OPCR_flag?6:0)+(splicing_point_flag?1:0)+1; transport_private_data(transport_private_data_length); Element_Offset=Element_Offset_Save; } } } #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 //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED2 void File_MpegTs::Read_Buffer_SegmentChange() { if (Complete_Stream==NULL || Complete_Stream->Streams.empty()) return; for (size_t StreamID=0; StreamID<0x2000; StreamID++)//std::map::iterator Stream=Streams.begin(); Stream!=Streams.end(); Stream++) if (Complete_Stream->Streams[StreamID]->Parser) Complete_Stream->Streams[StreamID]->Parser->Open_Buffer_SegmentChange(); } #endif //MEDIAINFO_ADVANCED2 //--------------------------------------------------------------------------- void File_MpegTs::Data_Parse() { //Counting Frame_Count++; //TSP specific if (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; switch(TSP_Size) { case 16: Skip_B16( "TSP"); break; //TSP supplement default: Skip_XX(TSP_Size, "TSP"); } } } //*************************************************************************** // 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; PosStreams[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]->Scrambled_Count>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 if (!Complete_Stream->Streams[pid]->IsParsed && Complete_Stream->Streams_NotParsedCount) { Complete_Stream->Streams[pid]->IsParsed=true; Complete_Stream->Streams_NotParsedCount--; } } Skip_XX(Element_Size-Element_Offset, "Scrambled data"); return; } else if (Complete_Stream->Streams[pid]->Scrambled_Count) Complete_Stream->Streams[pid]->Scrambled_Count--; //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 if (!Complete_Stream->Streams[pid]->IsParsed && Complete_Stream->Streams_NotParsedCount) { 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 #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (FromAribStdB24B37) ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FromAribStdB24B37=true; #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) #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 Complete_Stream->Streams[pid]->Parser->CA_system_ID_MustSkipSlices=Complete_Stream->Streams[pid]->CA_system_ID_MustSkipSlices; #if MEDIAINFO_IBIUSAGE if (Ibi.Streams[pid]==NULL) Ibi.Streams[pid]=new ibi::stream; Complete_Stream->Streams[pid]->Parser->IbiStream=Ibi.Streams[pid]; #endif //MEDIAINFO_IBIUSAGE 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_IBIUSAGE 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_IBIUSAGE #if defined(MEDIAINFO_ARIBSTDB24B37_YES) if (FromAribStdB24B37) Complete_Stream->Streams[pid]->Parser->FrameInfo=FrameInfo; #endif //defined(MEDIAINFO_ARIBSTDB24B37_YES) //EIA-608/EIA-708 descriptors #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Complete_Stream->Streams[pid]->Parser->ServiceDescriptors=NULL; if (Complete_Stream->Streams[pid]->ServiceDescriptors_IsPresent) Complete_Stream->Streams[pid]->Parser->ServiceDescriptors=&Complete_Stream->Streams[pid]->ServiceDescriptors; if (Complete_Stream->Streams[pid]->Parser->ServiceDescriptors==NULL) { for (size_t ProgramPos=0; ProgramPosStreams[pid]->program_numbers.size(); ++ProgramPos) { Complete_Stream->Streams[pid]->Parser->ServiceDescriptors=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[ProgramPos]].ServiceDescriptors; if (Complete_Stream->Streams[pid]->Parser->ServiceDescriptors) break; } } if (Complete_Stream->Streams[pid]->Parser->ServiceDescriptors==NULL) { for (size_t ProgramPos=0; ProgramPosStreams[pid]->program_numbers.size(); ++ProgramPos) if (Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[ProgramPos]].source_id_IsValid) { int16u source_id=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[ProgramPos]].source_id; complete_stream::sources::iterator Source=Complete_Stream->Sources.find(source_id); if (Source!=Complete_Stream->Sources.end()) 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.ServiceDescriptors) { Complete_Stream->Streams[pid]->Parser->ServiceDescriptors=Event->second.ServiceDescriptors; break; } } } if (Complete_Stream->Streams[pid]->Parser->ServiceDescriptors==NULL) Complete_Stream->Streams[pid]->Parser->ServiceDescriptors=&Complete_Stream->Streams[pid]->ServiceDescriptors; //Default to empty descriptor present in order to say descriptor info is supported #endif 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; PosStreams[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) { if (Config->File_StopSubStreamAfterFilled_Get()) { Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(false); Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(false); } if (!Complete_Stream->Streams[pid]->IsParsed && 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 && MEDIAINFO_IBIUSAGE 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 && MEDIAINFO_IBIUSAGE } //--------------------------------------------------------------------------- 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_IBIUSAGE Complete_Stream->Streams[pid]->Parser->Ibi_SynchronizationOffset_Current=File_Offset+Buffer_Offset-Header_Size; #endif //MEDIAINFO_IBIUSAGE 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; StreamKindStreamPos_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; TextPosStreamPos_ToRemove[StreamKind][Pos]); //Moving other StreamPos for (size_t Pos2=Pos+1; Pos2StreamPos_ToRemove[StreamKind].size(); Pos2++) Complete_Stream->StreamPos_ToRemove[StreamKind][Pos2]--; //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]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); } //--------------------------------------------------------------------------- void File_MpegTs::SetAllToPES() { Complete_Stream->Streams_NotParsedCount=(size_t)-1; for (size_t StreamID=0; StreamID<0x2000; StreamID++) { delete Complete_Stream->Streams[StreamID]; Complete_Stream->Streams[StreamID]=new complete_stream::stream; } #ifdef MEDIAINFO_ARIBSTDB24B37_YES size_t StreamID=FromAribStdB24B37?0x00:0x20; #else //MEDIAINFO_ARIBSTDB24B37_YES size_t StreamID=0x20; #endif //MEDIAINFO_ARIBSTDB24B37_YES for (; StreamID<0x1FFF; StreamID++) { 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; } //--------------------------------------------------------------------------- void File_MpegTs::transport_private_data(int8u transport_private_data_length) { //Trying SCTE 128 int64u End=Element_Offset+transport_private_data_length; #if MEDIAINFO_TRACE bool Trace_Activated_Save=Trace_Activated; Trace_Activated=false; #endif //MEDIAINFO_TRACE Element_Begin1("SCTE 128 coherency test"); bool IsOk=true; while (Element_Offset+2<=End) { int8u tag, length; Get_B1 (tag, "tag"); Get_B1 (length, "length"); if (Element_Offset+length>End || (tag==0xDF && length<4)) { Skip_XX(End-Element_Offset, "problem"); IsOk=false; } else Skip_XX(length, "data"); } if (Element_Offset=4) { int32u format_identifier; Get_C4 (format_identifier, "format identifier"); switch (format_identifier) { case 0x45425030 : //EBP0 { int64u End2=Element_Offset+length-4; Element_Info1("CableLabs - Encoder Boundary Point"); BS_Begin(); bool EBP_fragment_flag, EBP_segment_flag, EBP_SAP_flag, EBP_grouping_flag, EBP_time_flag, EBP_concealment_flag, EBP_extension_flag; Get_SB (EBP_fragment_flag, "EBP_fragment_flag"); Get_SB (EBP_segment_flag, "EBP_segment_flag"); Get_SB (EBP_SAP_flag, "EBP_SAP_flag"); Get_SB (EBP_grouping_flag, "EBP_grouping_flag"); Get_SB (EBP_time_flag, "EBP_time_flag"); Get_SB (EBP_concealment_flag, "EBP_concealment_flag"); Skip_SB( "Reserved"); Get_SB (EBP_extension_flag, "EBP_extension_flag"); if (EBP_extension_flag) { Skip_SB( "EBP_ext_partition_flag"); Skip_S1(7, "reserved"); } if (EBP_SAP_flag) { Skip_S1(3, "EBP_SAP_type"); Skip_S1(5, "reserved"); } if (EBP_grouping_flag) { bool EBP_grouping_ext_flag=true; while (EBP_grouping_ext_flag && Element_OffsetStreams[pid] && !Complete_Stream->Streams[pid]->EBP_IsPresent) { int32u Seconds, Fraction; Get_B4 (Seconds, "Seconds"); Param_Info1(Ztring().Date_From_Seconds_1970((int32u)(Seconds-2208988800))); //Param_Info1(Ztring().Date_From_Seconds_1900(Seconds)); //Temp for old ZenLib Get_B4 (Fraction, "Fraction"); Param_Info1(Ztring::ToZtring(((float64)Fraction)/0x100000000LL, 9)); Complete_Stream->Streams[pid]->Infos["EBP_AcquisitionTime"]=Ztring().Date_From_Seconds_1970((int32u)(Seconds-2208988800))+__T('.')+Ztring::ToZtring(((float64)Fraction)/0x100000000LL, 9).substr(2); //.Date_From_Seconds_1900(Seconds)); //Temp for old ZenLib Complete_Stream->Streams[pid]->EBP_IsPresent=true; } else { Info_B4(Seconds, "Seconds"); Param_Info1(Ztring().Date_From_Seconds_1970((int32u)(Seconds-2208988800))); //Param_Info1(Ztring().Date_From_Seconds_1900(Seconds)); //Temp for old ZenLib Info_B4(Fraction, "Fraction"); Param_Info1(Ztring::ToZtring(((float64)Fraction)/0x100000000LL, 9)); } Element_End0(); } if (EBP_concealment_flag) { Skip_B8( "EBP_ext_partitions"); } if (Element_Offset //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg4.cpp0000664000000000000000000037575612652076434021405 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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" #include // std::sort //--------------------------------------------------------------------------- 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___ard=0xA9617264; const int64u moov_meta___arg=0xA9617267; const int64u moov_meta___aut=0xA9617574; const int64u moov_meta___con=0xA963696E; 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___lyr=0xA96C7972; const int64u moov_meta___mak=0xA96D616B; const int64u moov_meta___mod=0xA96D6F64; const int64u moov_meta___nam=0xA96E616D; const int64u moov_meta___ope=0xA96F7065; 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___sne=0xA9736E65; const int64u moov_meta___sol=0xA9736F6C; const int64u moov_meta___src=0xA9737263; const int64u moov_meta___st3=0xA9737403; const int64u moov_meta___swr=0xA9737772; const int64u moov_meta___too=0xA9746F6F; const int64u moov_meta___url=0xA975726C; const int64u moov_meta___wrn=0xA977726E; const int64u moov_meta___wrt=0xA9777274; const int64u moov_meta___xpd=0xA9787064; const int64u moov_meta__aART=0x61415254; const int64u moov_meta__akID=0x616B4944; const int64u moov_meta__albm=0x616C626D; const int64u moov_meta__apID=0x61704944; const int64u moov_meta__atID=0x61744944; const int64u moov_meta__auth=0x61757468; const int64u moov_meta__catg=0x63617467; const int64u moov_meta__cnID=0x636E4944; const int64u moov_meta__cpil=0x6370696C; const int64u moov_meta__cprt=0x63707274; const int64u moov_meta__covr=0x636F7672; const int64u moov_meta__desc=0x64657363; const int64u moov_meta__disk=0x6469736B; const int64u moov_meta__dscp=0x64736370; const int64u moov_meta__egid=0x65676964; const int64u moov_meta__flvr=0x666C7672; const int64u moov_meta__gnre=0x676E7265; const int64u moov_meta__geID=0x67654944; const int64u moov_meta__grup=0x67727570; const int64u moov_meta__hdvd=0x68647664; const int64u moov_meta__itnu=0x69746E75; const int64u moov_meta__keyw=0x6B657977; const int64u moov_meta__ldes=0x6C646573; const int64u moov_meta__name=0x6E616D65; const int64u moov_meta__pcst=0x70637374; const int64u moov_meta__perf=0x70657266; const int64u moov_meta__pgap=0x70676170; const int64u moov_meta__plID=0x706C4944; const int64u moov_meta__purd=0x70757264; const int64u moov_meta__purl=0x7075726C; const int64u moov_meta__rate=0x72617465; const int64u moov_meta__rndu=0x726E6475; const int64u moov_meta__rpdu=0x72706475; const int64u moov_meta__rtng=0x72746E67; const int64u moov_meta__sdes=0x73646573; const int64u moov_meta__sfID=0x73664944; const int64u moov_meta__soaa=0x736F6161; const int64u moov_meta__soal=0x736F616C; const int64u moov_meta__soar=0x736F6172; const int64u moov_meta__soco=0x736F636F; const int64u moov_meta__sonm=0x736F6E6D; const int64u moov_meta__sosn=0x736F736E; const int64u moov_meta__stik=0x7374696B; 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__tven=0x7476656E; const int64u moov_meta__tves=0x74766573; const int64u moov_meta__tvnn=0x74766E6E; const int64u moov_meta__tvsh=0x74767368; const int64u moov_meta__tvsn=0x7476736E; const int64u moov_meta__xid_=0x78696420; const int64u moov_meta__year=0x79656172; const int64u moov_meta__yyrc=0x79797263; const int64u moov_trak_mdia_hdlr_alis=0x616C6973; const int64u moov_trak_mdia_hdlr_hint=0x68696E74; 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); } } //--------------------------------------------------------------------------- extern const char* Mpeg4_chan(int16u Ordering); extern const char* Mpeg4_chan_Layout(int16u Ordering); //*************************************************************************** // 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; moov_mvhd_TimeScale=1; Vendor=0x00000000; FirstMdatPos=(int64u)-1; LastMdatPos=0; FirstMoovPos=(int64u)-1; MajorBrand=0x00000000; IsSecondPass=false; IsParsing_mdat=false; IsFragmented=false; StreamOrder=0; moov_trak_tkhd_TrackID=(int32u)-1; #if defined(MEDIAINFO_REFERENCES_YES) ReferenceFiles=NULL; #endif //defined(MEDIAINFO_REFERENCES_YES) mdat_Pos_NormalParsing=false; moof_traf_base_data_offset=(int64u)-1; data_offset_present=true; #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) { /*bool IsDashMpd=false; for (size_t Pos=0; posFile_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()); } //Configuration Buffer_MaximumSize=64*1024*1024; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p) File_Buffer_Size_Hint_Pointer=Config->File_Buffer_Size_Hint_Pointer_Get(); } //--------------------------------------------------------------------------- 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) for (size_t Pos=0; Possecond.Parsers[Pos]->Finish(); if (Stream->second.Parsers[Pos]->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.Parsers[Pos], Stream_Text, 0, StreamPos_Last); } //Law rating Ztring LawRating=Stream->second.Parsers[Pos]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Stream->second.Parsers[Pos]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } 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 (StreamKind_Last==Stream_Max && Temp->second.hdlr_SubType) { Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_Type, Ztring().From_CC4(Temp->second.hdlr_SubType)); } //if (Temp->second.stsz_StreamSize) // Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), Temp->second.stsz_StreamSize); //flags and references if (StreamKind_Last != Stream_Menu) { Ztring TempString; std::vector::iterator TrackID; if (StreamKind_Last == Stream_Text) { std::vector TrackIDs = Temp->second.SubtitleFor; for (TrackID = Temp->second.Forced.begin(); TrackID != Temp->second.Forced.end(); ++TrackID) { for (std::vector::iterator TrackID2 = Streams[*TrackID].SubtitleFor.begin(); TrackID2 != Streams[*TrackID].SubtitleFor.end(); ++TrackID2) { TrackIDs.push_back(*TrackID2); } } for (TrackID = Temp->second.ForcedFor.begin(); TrackID != Temp->second.ForcedFor.end(); ++TrackID) { for (std::vector::iterator TrackID2 = Streams[*TrackID].SubtitleFor.begin(); TrackID2 != Streams[*TrackID].SubtitleFor.end(); ++TrackID2) { TrackIDs.push_back(*TrackID2); } } sort (TrackIDs.begin(), TrackIDs.end()); TrackIDs.erase( unique(TrackIDs.begin(), TrackIDs.end()), TrackIDs.end()); for (std::vector::iterator TrackID = TrackIDs.begin(); TrackID != TrackIDs.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Subtitles For", TempString.To_Local().c_str()); TempString.clear(); } } if (Temp->second.IsExcluded) Fill(StreamKind_Last, StreamPos_Last, "Default", "Excluded"); else { if (Temp->second.IsEnabled) { if (!Retrieve(StreamKind_Last, StreamPos_Last, "AlternateGroup").empty()) // Redundant information if there is not alternate group Fill(StreamKind_Last, StreamPos_Last, "Default", "Yes"); } else { for (TrackID = Temp->second.FallBackTo.begin(); TrackID != Temp->second.FallBackTo.end(); ++TrackID) { if (Streams[*TrackID].IsEnabled) { if (TempString.size()) TempString.append(__T(" ,")); else TempString=__T("Inherited From: "); TempString.append(Ztring().From_Number(*TrackID)); } } for (TrackID = Temp->second.FallBackFrom.begin(); TrackID != Temp->second.FallBackFrom.end(); ++TrackID) { if (Streams[*TrackID].IsEnabled) { if (TempString.size()) TempString.append(__T(" ,")); else TempString=__T("Inherited From: "); TempString.append(Ztring().From_Number(*TrackID)); } } Fill(StreamKind_Last, StreamPos_Last, "Default", TempString.size()?TempString.To_Local().c_str():"No"); TempString.clear(); } } if (StreamKind_Last == Stream_Text) { if (Temp->second.HasForcedSamples) { if (Temp->second.AllForcedSamples) Fill(StreamKind_Last, StreamPos_Last, "Forced", "Yes"); else Fill(StreamKind_Last, StreamPos_Last, "Forced", "Mixed"); if (Temp->second.ForcedFor.size()) { for (TrackID = Temp->second.ForcedFor.begin(); TrackID != Temp->second.ForcedFor.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } Fill(StreamKind_Last, StreamPos_Last, "Full Alternative", TempString.To_Local().c_str()); TempString.clear(); } } else Fill(StreamKind_Last, StreamPos_Last, "Forced", "No"); if (Temp->second.Forced.size()) { for (TrackID = Temp->second.Forced.begin(); TrackID != Temp->second.Forced.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) Fill(StreamKind_Last, StreamPos_Last, "Forced Alternative", TempString.To_Local().c_str()); TempString.clear(); } } if (StreamKind_Last == Stream_Audio) { if (Temp->second.FallBackTo.size()) { for (TrackID = Temp->second.FallBackTo.begin(); TrackID != Temp->second.FallBackTo.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Fallback To", TempString.To_Local().c_str()); TempString.clear(); } } if (Temp->second.FallBackFrom.size()) { for (TrackID = Temp->second.FallBackFrom.begin(); TrackID != Temp->second.FallBackFrom.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Fallback From", TempString.To_Local().c_str()); TempString.clear(); } } if (Temp->second.Subtitle.size()) { std::vector TrackIDs = Temp->second.Subtitle; for (TrackID = Temp->second.Subtitle.begin(); TrackID != Temp->second.Subtitle.end(); ++TrackID) { std::vector::iterator TrackID2; for (TrackID2 = Streams[*TrackID].Forced.begin(); TrackID2 != Streams[*TrackID].Forced.end(); ++TrackID2) { TrackIDs.push_back(*TrackID2); } for (TrackID2 = Streams[*TrackID].ForcedFor.begin(); TrackID2 != Streams[*TrackID].ForcedFor.end(); ++TrackID2) { TrackIDs.push_back(*TrackID2); } } sort (TrackIDs.begin(), TrackIDs.end()); TrackIDs.erase( unique(TrackIDs.begin(), TrackIDs.end()), TrackIDs.end()); for (std::vector::iterator TrackID = TrackIDs.begin(); TrackID != TrackIDs.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Subtitles", TempString.To_Local().c_str()); TempString.clear(); } } } if (Temp->second.CC.size()) { for (TrackID = Temp->second.CC.begin(); TrackID != Temp->second.CC.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Closed Captions", TempString.To_Local().c_str()); TempString.clear(); } } else if (Temp->second.CCFor.size()) { for (TrackID = Temp->second.CCFor.begin(); TrackID != Temp->second.CCFor.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Closed Captions For", TempString.To_Local().c_str()); TempString.clear(); } } if (Temp->second.Chapters.size()) { for (TrackID = Temp->second.Chapters.begin(); TrackID != Temp->second.Chapters.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Menus", TempString.To_Local().c_str()); TempString.clear(); } } } if (Temp->second.ChaptersFor.size()) { Ztring TempString; std::vector::iterator TrackID; for (TrackID = Temp->second.ChaptersFor.begin(); TrackID != Temp->second.ChaptersFor.end(); ++TrackID) { if (TempString.size()) TempString.append(__T(",")); TempString.append(Ztring().From_Number(*TrackID)); } if (TempString.size()) { Fill(StreamKind_Last, StreamPos_Last, "Menu For", TempString.To_Local().c_str()); TempString.clear(); } } //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; Possecond.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); } //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 (moov_mvhd_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))/moov_mvhd_TimeScale; float32 Duration_tkhd_L=((float32)(Temp->second.tkhd_Duration-1))/moov_mvhd_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)/moov_mvhd_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)/moov_mvhd_TimeScale*Temp->second.mdhd_TimeScale/Temp->second.stts_Min); else { FrameCount=0; int64u Ticks_Max=float64_int64s(((float64)Temp->second.tkhd_Duration)/moov_mvhd_TimeScale*Temp->second.mdhd_TimeScale); int64u Ticks=0; for (size_t stts_Pos=0; stts_Possecond.stts.size(); stts_Pos++) { int64u Ticks_Complete = (int64u)Temp->second.stts[stts_Pos].SampleCount * (int64u)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_Possecond.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.Parsers.size()==1 && !Temp->second.Parsers[0]->Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Encoded").empty()) || (Temp->second.Parsers.size()==1 && Temp->second.Parsers[0]->Buffer_TotalBytes && ((float32)Temp->second.Parsers[0]->Buffer_PaddingBytes)/Temp->second.Parsers[0]->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); } } //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 && moov_mvhd_TimeScale) { Delay=Temp->second.edts[0].Delay; Delay=-Delay; if (Temp->second.mdhd_TimeScale) Delay/=Temp->second.mdhd_TimeScale; //In seconds } 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 && moov_mvhd_TimeScale) { Delay=Temp->second.edts[0].Duration; Temp->second.tkhd_Duration-=float64_int64s(Delay); Delay/=moov_mvhd_TimeScale; //In seconds } break; default: break; //TODO: handle more complex Edit Lists } if (Delay && !Retrieve(StreamKind_Last, StreamPos_Last, "Source_Duration").empty()) { 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, "Source_Delay", Delay*1000, 0, true); Fill(StreamKind_Last, StreamPos_Last, "Source_Delay_Source", "Container", Unlimited, true, true); (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("Source_Delay"), Info_Options)=__T("N NT"); (*Stream_More)[StreamKind_Last][StreamPos_Last](Ztring().From_Local("Source_Delay_Source"), Info_Options)=__T("N NT"); } 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); } //When there are few frames, difficult to detect PCM if (Temp->second.IsPcm && !Temp->second.Parsers.empty() && !Temp->second.Parsers[0]->Status[IsAccepted]) { for (size_t Pos=0; Possecond.Parsers.size()-1; Pos++) delete Temp->second.Parsers[Pos]; Temp->second.Parsers.erase(Temp->second.Parsers.begin(), Temp->second.Parsers.begin()+Temp->second.Parsers.size()-1); Temp->second.Parsers[0]->Accept(); } //Parser specific if (Temp->second.Parsers.size()==1) { if (Config->ParseSpeed<=1.0) { Fill(Temp->second.Parsers[0]); Temp->second.Parsers[0]->Open_Buffer_Unsynch(); } //Finalizing and Merging Finish(Temp->second.Parsers[0]); if (StreamKind_Last==Stream_General) { //Special case for TimeCode without link for (std::map::iterator Target=Streams.begin(); Target!=Streams.end(); ++Target) if (Target->second.StreamKind!=Stream_General) Merge(*Temp->second.Parsers[0], 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.Parsers[0] && Retrieve(Stream_Video, 0, Video_CodecID_Hint)==__T("DVCPRO HD")) { Temp->second.Parsers[0]->Clear(Stream_Video, 0, Video_FrameRate); Temp->second.Parsers[0]->Clear(Stream_Video, 0, Video_Width); Temp->second.Parsers[0]->Clear(Stream_Video, 0, Video_Height); Temp->second.Parsers[0]->Clear(Stream_Video, 0, Video_DisplayAspectRatio); Temp->second.Parsers[0]->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.Parsers[0]->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.Parsers[0]->Retrieve(Stream_General, 0, General_Format)==__T("ChannelGrouping") && Temp->second.Parsers[0]->Count_Get(Stream_Audio)) || Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_Format)==__T("Final Cut EIA-608") || Temp->second.Parsers[0]->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; ZtringListList StreamMoreSave; if (StreamKind_Last!=Stream_Max) { StreamSave.Write((*File__Analyze::Stream)[StreamKind_Last][StreamPos_Last].Read()); 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.Parsers[0]->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.Parsers[0]->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.Parsers[0]->Count_Get(NewKind); for (size_t StreamPos=0; StreamPossecond.Parsers[0], 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; Possecond.Parsers[0]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } else { //Temp->second.Parsers[0]->Clear(StreamKind_Last, StreamPos_Last, "Delay"); //DV TimeCode is removed Temp->second.Parsers[0]->Clear(StreamKind_Last, StreamPos_Last, "FrameCount"); Merge(*Temp->second.Parsers[0], StreamKind_Last, 0, StreamPos_Last); //Law rating Ztring LawRating=Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_LawRating); if (!LawRating.empty()) Fill(Stream_General, 0, General_LawRating, LawRating, true); Ztring Title=Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_Title); if (!Title.empty() && Retrieve(Stream_General, 0, General_Title).empty()) Fill(Stream_General, 0, General_Title, Title); } //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; Possecond.Parsers[0] && (Temp->second.Parsers[0]->Count_Get(Stream_Audio) || Temp->second.Parsers[0]->Count_Get(Stream_Text))) { //Video and Audio are together size_t Audio_Count=Temp->second.Parsers[0]->Count_Get(Stream_Audio); for (size_t Audio_Pos=0; Audio_Possecond.Parsers[0], Stream_Audio, Audio_Pos, StreamPos_Last); Fill(Stream_Audio, Pos, Audio_MuxingMode, Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_Format)); 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.Parsers[0]->Count_Get(Stream_Text); for (size_t Text_Pos=0; Text_Possecond.Parsers[0], Stream_Text, Text_Pos, StreamPos_Last); Fill(Stream_Text, Pos, Text_MuxingMode, Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_Format)); 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; } } } //ScanOrder_StoredDisplayedInverted // Priorizing https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG10-THE__FIEL__IMAGEDESCRIPTION_EXTENSION__FIELD_FRAME_INFORMATION /* switch (Temp->second.fiel_detail) { case 1 : // Separated fields, TFF case 6 : // Separated fields, BFF Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, "TFF", Unlimited, true, true); break; case 9 : // Interleaved fields, TFF case 14 : // Interleaved fields, BFF Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, "BFF", Unlimited, true, true); break; default : ; } */ //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); } if (StreamKind_Last==Stream_Audio && Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)!=__T("PCM") && !Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s__Original).empty()) { Clear(Stream_Audio, StreamPos_Last, Audio_Channel_s__Original); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 6, 10, true); //The PCM channel count is fake } //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_Possecond.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_Possecond.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) { Fill(Stream_Video, StreamPos_Last, "Width_CleanAperture", Temp->second.CleanAperture_Width, 0, true); Fill(Stream_Video, StreamPos_Last, "Height_CleanAperture", Temp->second.CleanAperture_Height, 0, true); Fill(Stream_Video, StreamPos_Last, "PixelAspectRatio_CleanAperture", Temp->second.CleanAperture_PixelAspectRatio, 3, true); } //Special case: QuickTime files and Stereo streams, there is a default value in QuickTime player, a QuickTime "standard"? if (StreamKind_Last==Stream_Audio && Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s_)==__T("2") && Retrieve(Stream_Audio, StreamPos_Last, Audio_ChannelLayout).empty() && Retrieve(Stream_Audio, StreamPos_Last, Audio_ChannelPositions).empty() && Retrieve(Stream_General, 0, General_Format_Profile)==__T("QuickTime")) { Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, Mpeg4_chan(101)); Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, Mpeg4_chan_Layout(101)); } //Bitrate Mode if (Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Mode").empty()) { if (Temp->second.stss.empty() && Temp->second.stss.size()!=Temp->second.stsz_Total.size() && !IsFragmented) { int64u Size_Min=(int64u)-1, Size_Max=0; for (size_t Pos=0; Possecond.stsz_Total.size(); Pos++) { if (Temp->second.stsz_Total[Pos]second.stsz_Total[Pos]; if (Temp->second.stsz_Total[Pos]>Size_Max) Size_Max=Temp->second.stsz_Total[Pos]; } if (Size_Min*(1.005+0.005)::iterator Info=Temp->second.Infos.begin(); Info!=Temp->second.Infos.end(); ++Info) Fill(StreamKind_Last, StreamPos_Last, Info->first.c_str(), Info->second); ++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 sequence 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); sequence* Sequence=new sequence; Sequence->AddFileName(Stream->second.File_Name); Sequence->StreamKind=Stream->second.StreamKind; Sequence->StreamPos=Stream->second.StreamPos; Sequence->StreamID=Retrieve(Stream->second.StreamKind, Stream->second.StreamPos, General_ID).To_int64u(); if (Stream->second.StreamKind==Stream_Video) { Sequence->FrameRate_Set(Retrieve(Stream_Video, Stream->second.StreamPos, Video_FrameRate).To_float64()); #if MEDIAINFO_IBIUSAGE for (size_t stss_Pos=0; stss_Possecond.stss.size(); stss_Pos++) { int64u Value=Stream->second.stss[stss_Pos]; //Searching the corresponding stco std::vector::iterator Stsc=Stream->second.stsc.begin(); int64u SamplePos=0; for (; Stsc!=Stream->second.stsc.end(); ++Stsc) { std::vector::iterator Stsc_Next=Stsc; ++Stsc_Next; int64u CountOfSamples = ((Stsc_Next == Stream->second.stsc.end() ? ((int64u)Stream->second.stco.size()) : ((int64u)Stsc_Next->FirstChunk)) - (int64u)Stsc->FirstChunk) * (int64u)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_Possecond.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; Sequence->IbiStream.Add(IbiInfo); } } } } #endif //MEDIAINFO_IBIUSAGE } ReferenceFiles->AddSequence(Sequence); } if (ReferenceFiles) { ReferenceFiles->ParseReferences(); #if MEDIAINFO_NEXTPACKET if (Config->NextPacket_Get() && ReferenceFiles && ReferenceFiles->Sequences_Size()) { 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(); if (mdat_Pos.empty()) { IsParsing_mdat=false; return; } mdat_Pos_Temp=&mdat_Pos[0]; while (mdat_Pos_Temp!=mdat_Pos_Max && mdat_Pos_Temp->OffsetOffset>File_GoTo) mdat_Pos_Temp--; //Previous frame if (mdat_Pos_Temp==mdat_Pos_Max) { IsParsing_mdat=false; return; } IsParsing_mdat=true; #if MEDIAINFO_SEEK //Searching the ID of the first stream to be demuxed std::map::iterator Next_Stream=Streams.end(); #if MEDIAINFO_DEMUX size_t Next_Stream_Stco=(size_t)-1; #endif //MEDIAINFO_DEMUX for (std::map::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { for (size_t Stco_Pos=0; Stco_Possecond.stco.size(); Stco_Pos++) if (Stream->second.stco[Stco_Pos]==mdat_Pos_Temp->Offset) { Next_Stream=Stream; #if MEDIAINFO_DEMUX Next_Stream_Stco=Stco_Pos; #endif //MEDIAINFO_DEMUX break; } if (Next_Stream!=Streams.end()) break; } #endif //MEDIAINFO_SEEK for (std::map::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { for (size_t Pos=0; Possecond.Parsers.size(); Pos++) Stream->second.Parsers[Pos]->Open_Buffer_Unsynch(); #if MEDIAINFO_SEEK && MEDIAINFO_DEMUX //Searching the next position for this stream int64u StreamOffset=(int64u)-1; if (StreamOffset_Jump.empty() || File_GoTo==mdat_Pos[0].Offset) StreamOffset=mdat_Pos_Temp->Offset; else if (Next_Stream_Stco!=(size_t)-1) { //Searching the right place for this stream int64u StreamOffset_Temp=Next_Stream->second.stco[Next_Stream_Stco]; std::map::iterator StreamOffset_Jump_Temp; for (;;) { StreamOffset_Jump_Temp=StreamOffset_Jump.find(StreamOffset_Temp); if (StreamOffset_Jump_Temp==StreamOffset_Jump.end()) break; if (Stream==Next_Stream) StreamOffset_Temp=StreamOffset_Jump_Temp->first; else { ++StreamOffset_Jump_Temp; if (StreamOffset_Jump_Temp==StreamOffset_Jump.end()) break; StreamOffset_Temp=StreamOffset_Jump_Temp->second; } if (!Stream->second.stco.empty() && StreamOffset_Temp>=Stream->second.stco[0] && StreamOffset_Temp<=Stream->second.stco[Stream->second.stco.size()-1]) for (size_t Stco_Pos=0; Stco_Possecond.stco.size(); Stco_Pos++) if (StreamOffset_Temp==Stream->second.stco[Stco_Pos]) { StreamOffset=Stream->second.stco[Stco_Pos]; break; } if (StreamOffset!=(int64u)-1) break; } } if (StreamOffset!=(int64u)-1) for (size_t stco_Pos=0; stco_Possecond.stco.size(); stco_Pos++) if (Stream->second.stco[stco_Pos]>=StreamOffset) { //Searching the corresponding frame position std::vector::iterator Stsc=Stream->second.stsc.begin(); int64u SamplePos=0; for (; Stsc!=Stream->second.stsc.end(); ++Stsc) { std::vector::iterator Stsc_Next=Stsc; ++Stsc_Next; if (Stsc_Next!=Stream->second.stsc.end() && stco_Pos+1>=Stsc_Next->FirstChunk) { int64u CountOfSamples = ((int64u)Stsc_Next->FirstChunk - (int64u)Stsc->FirstChunk) * (int64u)Stsc->SamplesPerChunk; SamplePos+=CountOfSamples; } else { int64u CountOfSamples = ((int64u)stco_Pos + 1 - (int64u)Stsc->FirstChunk) * (int64u)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 && SamplePosPos_End) { Stream->second.stts_Durations_Pos=Stts_Duration-Stream->second.stts_Durations.begin(); break; } break; } } break; } #endif //MEDIAINFO_SEEK && MEDIAINFO_DEMUX } } //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_Mpeg4::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { #if defined(MEDIAINFO_REFERENCES_YES) if (ReferenceFiles) return ReferenceFiles->Seek(Method, Value, ID); #endif //defined(MEDIAINFO_REFERENCES_YES) 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 the minimal stream offset, for every video/audio/text stream int64u JumpTo=File_Size; for (std::map::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) switch (Stream->second.StreamKind) { case Stream_Video : case Stream_Audio : case Stream_Text : { //Searching the corresponding chunk offset std::vector::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::iterator Stco_Next=Stco; ++Stco_Next; if (Stco_Next!=Stream->second.stco.end() && Value>=*Stco && Value<*Stco_Next) { if (JumpTo>*Stco) JumpTo=*Stco; break; } } } break; default : ; } GoTo(JumpTo); 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 #if MEDIAINFO_DEMUX { //Searching time stamp offset due to Time code offset for (std::map::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) if (Stream->second.StreamKind==Stream_Video) { if (Value>TimeCode_DtsOffset) //Removing Time Code offset Value-=TimeCode_DtsOffset; else Value=0; //Sooner break; } //Looking for the minimal stream offset, for every video/audio/text stream int64u JumpTo=File_Size; for (std::map::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) switch (Stream->second.StreamKind) { case Stream_Video : case Stream_Audio : case Stream_Text : { int64u Value2=float64_int64s(((float64)Value)*Stream->second.mdhd_TimeScale/1000000000); //Transformed in mpeg4 ticks (per track) //Searching the corresponding frame for (stream::stts_durations::iterator stts_Duration=Stream->second.stts_Durations.begin(); stts_Duration!=Stream->second.stts_Durations.end(); ++stts_Duration) { if (Value2>=stts_Duration->DTS_Begin && Value2DTS_End) { int64u FrameNumber=stts_Duration->Pos_Begin+(Value2-stts_Duration->DTS_Begin)/stts_Duration->SampleDuration; //Searching the I-Frame if (!Stream->second.stss.empty()) { for (size_t Pos=0; Possecond.stss.size(); Pos++) if (FrameNumber<=Stream->second.stss[Pos]) { if (Pos && FrameNumbersecond.stss[Pos]) FrameNumber=Stream->second.stss[Pos-1]; break; } } //Searching the corresponding stco std::vector::iterator Stsc=Stream->second.stsc.begin(); int64u SamplePos=0; for (; Stsc!=Stream->second.stsc.end(); ++Stsc) { std::vector::iterator Stsc_Next=Stsc; ++Stsc_Next; int64u CountOfSamples = ((Stsc_Next == Stream->second.stsc.end() ? (int64u)Stream->second.stco.size() : (int64u)Stsc_Next->FirstChunk) - (int64u)Stsc->FirstChunk) * (int64u)Stsc->SamplesPerChunk; if (Stsc_Next!=Stream->second.stsc.end() && FrameNumber>=SamplePos+CountOfSamples) SamplePos+=CountOfSamples; else { int64u CountOfChunks=(FrameNumber-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 FrameNumber if (JumpTo>Stream->second.stco[stco_Pos]) JumpTo=Stream->second.stco[stco_Pos]; break; } } } } } break; default : ; } if (!StreamOffset_Jump.empty()) { std::map::iterator StreamOffset_Current=StreamOffset_Jump.end(); do --StreamOffset_Current; while (StreamOffset_Current->second>JumpTo && StreamOffset_Current!=StreamOffset_Jump.begin()); JumpTo=StreamOffset_Current->second; } GoTo(JumpTo); Open_Buffer_Unsynch(); return 1; } #else //MEDIAINFO_DEMUX return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX case 3 : //FrameNumber #if MEDIAINFO_DEMUX { //Looking for video stream std::map::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()) for (Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) if (Stream->second.StreamKind==Stream_Text) break; if (Stream==Streams.end()) return 0; //Not supported //Searching the I-Frame if (!Stream->second.stss.empty()) { for (size_t Pos=0; Possecond.stss.size(); Pos++) if (Value<=Stream->second.stss[Pos]) { if (Pos && Valuesecond.stss[Pos]) Value=Stream->second.stss[Pos-1]; break; } } //Searching the corresponding stco std::vector::iterator Stsc=Stream->second.stsc.begin(); int64u SamplePos=0; for (; Stsc!=Stream->second.stsc.end(); ++Stsc) { std::vector::iterator Stsc_Next=Stsc; ++Stsc_Next; int64u CountOfSamples = ((Stsc_Next == Stream->second.stsc.end() ? ((int64u)Stream->second.stco.size()) : ((int64u)Stsc_Next->FirstChunk)) - (int64u)Stsc->FirstChunk) * (int64u)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]; //Seeking back to audio/text frames before this video frame if (!StreamOffset_Jump.empty()) { if (stco_Pos==0) //The first Stco is considered as the last byte of previous stram { if (!mdat_Pos.empty()) Offset=mdat_Pos[0].Offset; } else { std::map::iterator StreamOffset_Jump_Temp=StreamOffset_Jump.find(Stream->second.stco[stco_Pos]); if (StreamOffset_Jump_Temp!=StreamOffset_Jump.end()) Offset=StreamOffset_Jump_Temp->second; } } else { //TODO } GoTo(Offset); Open_Buffer_Unsynch(); return 1; } } return 2; //Invalid value } #else //MEDIAINFO_DEMUX return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX default : return 0; } } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- void File_Mpeg4::Read_Buffer_Init() { if (MediaInfoLib::Config.ParseSpeed_Get()==1.00) FrameCount_MaxPerStream=(int32u)-1; else if (MediaInfoLib::Config.ParseSpeed_Get()<=0.3) FrameCount_MaxPerStream=128; else FrameCount_MaxPerStream=512; } //*************************************************************************** // Buffer //*************************************************************************** //--------------------------------------------------------------------------- bool File_Mpeg4::Header_Begin() { #if MEDIAINFO_DEMUX //Handling of multiple frames in one block if (IsParsing_mdat && Config->Demux_Unpacketize_Get()) { stream &Stream_Temp=Streams[(int32u)Element_Code]; if (Stream_Temp.Demux_EventWasSent) { Open_Buffer_Continue(Stream_Temp.Parsers[0], Buffer+Buffer_Offset, 0); if (Config->Demux_EventWasSent) return false; Stream_Temp.Demux_EventWasSent=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 (mdat_Pos_Temp==mdat_Pos_Max || File_Offset+Buffer_OffsetOffset) { Header_Fill_Code(0, "(Junk)"); int64u Size=mdat_Pos_Temp==mdat_Pos_Max?Element_TotalSize_Get():(mdat_Pos_Temp->Offset-(File_Offset+Buffer_Offset)); if (Size>1 && Size>=Buffer_MaximumSize/2) Size=Buffer_MaximumSize; if (Size==Element_TotalSize_Get()) IsParsing_mdat=false; Header_Fill_Size(Size); return; } //Filling Header_Fill_Code2(mdat_Pos_Temp->StreamID, Ztring::ToZtring(mdat_Pos_Temp->StreamID)); Header_Fill_Size(mdat_Pos_Temp->Size); if (Buffer_Offset+mdat_Pos_Temp->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_Max) { if (mdat_Pos_NormalParsing && !Streams[mdat_Pos_Temp->StreamID].IsPriorityStream) break; if (!mdat_Pos_NormalParsing && Streams[mdat_Pos_Temp->StreamID].IsPriorityStream) break; mdat_Pos_Temp++; } } else Element_WaitForMoreData(); //Hints if (File_Buffer_Size_Hint_Pointer && mdat_Pos_Temp!=mdat_Pos_Max && mdat_Pos_Temp->Offset+mdat_Pos_Temp->Size>File_Offset+Buffer_Size && mdat_Pos_Temp->OffsetOffset+mdat_Pos_Temp->Size-(File_Offset+Buffer_Size)); if (Buffer_Size_Target<128*1024) Buffer_Size_Target=128*1024; (*File_Buffer_Size_Hint_Pointer)=Buffer_Size_Target; } return; } //Parsing int64u Size; int32u Size_32, Name; if (Element_Size==2) { if (!Element_IsComplete_Get()) { Element_WaitForMoreData(); return; } int16u Size_16; Peek_B2(Size_16); if (!Size_16) { Skip_B2( "Size"); //Filling Header_Fill_Code(0, "Junk"); Header_Fill_Size(2); return; } } Get_B4 (Size_32, "Size"); if (Size_32==0 && (Element_Size==4 || Element_Size==8)) { if (!Element_IsComplete_Get()) { Element_WaitForMoreData(); return; } //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); if (Name==0x6D6F6F76 && Buffer_Offset+Size>Buffer_Size-Buffer_Offset) //moov { File_Buffer_Size_Hint_Pointer=Config->File_Buffer_Size_Hint_Pointer_Get(); //Hints if (File_Buffer_Size_Hint_Pointer && Size>128*1024) { size_t Buffer_Size_Target=(size_t)(Buffer_Offset+Size-(Buffer_Size-Buffer_Offset)); if (Buffer_Size_Target<128*1024) Buffer_Size_Target=128*1024; (*File_Buffer_Size_Hint_Pointer)=Buffer_Size_Target; } } //Incoherencies if (Element_Level<=2 && File_Offset+Buffer_Offset+Size>File_Size) Fill(Stream_General, 0, "IsTruncated", "Yes"); } //--------------------------------------------------------------------------- struct Mpeg4_muxing { int64u MinimalOffset; int64u MaximalOffset; Mpeg4_muxing() { MinimalOffset=(int64u)-1; MaximalOffset=0; } }; bool File_Mpeg4::BookMark_Needed() { #if MEDIAINFO_HASH if (!mdat_MustParse && !mdat_Pos_NormalParsing && Config->File_Hash_Get().to_ulong() && FirstMdatPos0) Element_End0(); mdat_Pos_NormalParsing=true; GoTo(0); IsSecondPass=true; return false; } #endif //MEDIAINFO_HASH if (!mdat_MustParse) return false; //Handling of some wrong stsz and stsc atoms (ADPCM) if (!IsSecondPass) for (std::map::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; Possecond.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()) { #if MEDIAINFO_DEMUX std::map Muxing; //key is StreamID #endif //MEDIAINFO_DEMUX size_t stco_Count=(size_t)-1; bool stco_IsDifferent=false; //For each stream for (std::map::iterator Temp=Streams.begin(); Temp!=Streams.end(); ++Temp) if (!Temp->second.Parsers.empty()) { if (!Temp->second.File_Name.empty()) { #if MEDIAINFO_DEMUX if (Config_Demux && Config->File_Demux_Interleave_Get() && Temp->second.StreamKind!=Stream_Other) // e.g. a time code, we can live without demuxing the time code { //Remark: supporting both embedded and referenced streams is currently not supported mdat_Pos.clear(); return false; } else #endif // MEDIAINFO_DEMUX continue; } if (!Temp->second.stsz.empty() || Temp->second.stsz_Sample_Size) { if (!stco_IsDifferent) { if (stco_Count==(size_t)-1) stco_Count=Temp->second.stco.size(); else if (stco_Count!=Temp->second.stco.size()) stco_IsDifferent=true; } 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 if (!Temp->second.stco.empty() && !Temp->second.stsc.empty()) { int64u* stco_Current = &Temp->second.stco[0]; int64u* stco_Max = stco_Current + Temp->second.stco.size(); int64u* stsz_Current = Temp->second.stsz.empty()?NULL:&Temp->second.stsz[0]; int64u* stsz_Max = stsz_Current + Temp->second.stsz.size(); stream::stsc_struct* stsc_Current = &Temp->second.stsc[0]; stream::stsc_struct* stsc_Max = stsc_Current + Temp->second.stsc.size(); #if MEDIAINFO_DEMUX int64u MinimalOffset = (int64u)-1; int64u MaximalOffset = 0; #endif //MEDIAINFO_DEMUX for (; stco_Current*stco_Current) MinimalOffset = *stco_Current; if (MaximalOffset < *stco_Current) MaximalOffset = *stco_Current; #endif //MEDIAINFO_DEMUX while (stsc_Current + 1 < stsc_Max && Chunk_Number >= (stsc_Current + 1)->FirstChunk) stsc_Current++; if (Temp->second.stsz_Sample_Size == 0 && stsc_Current && !Temp->second.stsz.empty()) { //Each sample has its own size int64u Chunk_Offset = 0; for (size_t Pos = 0; Pos < stsc_Current->SamplesPerChunk; Pos++) if (*stsz_Current) { mdat_Pos_Type mdat_Pos_Temp2; mdat_Pos_Temp2.Offset = *stco_Current + Chunk_Offset; mdat_Pos_Temp2.StreamID = Temp->first; mdat_Pos_Temp2.Size = *stsz_Current; mdat_Pos.push_back(mdat_Pos_Temp2); Chunk_Offset += *stsz_Current; stsz_Current++; if (stsz_Current >= stsz_Max) break; } if (stsz_Current >= stsz_Max) break; } else if (Temp->second.IsPcm && (!Sample_ByteSize || Temp->second.stsz_Sample_Size <= Sample_ByteSize) && stsc_Current && stsc_Current->SamplesPerChunk*Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier < 0x1000000) { //Same size per sample, but granularity is too small mdat_Pos_Type mdat_Pos_Temp2; mdat_Pos_Temp2.Offset = *stco_Current; mdat_Pos_Temp2.StreamID = Temp->first; mdat_Pos_Temp2.Size = stsc_Current->SamplesPerChunk*Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier; mdat_Pos.push_back(mdat_Pos_Temp2); #if MEDIAINFO_DEMUX if (Temp_stts_Durations.empty() || stsc_Current->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 = stsc_Current->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 if (stsc_Current < stsc_Max) { //Same size per sample int64u Chunk_Offset = 0; for (size_t Pos = 0; Pos < stsc_Current->SamplesPerChunk; Pos++) if (Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier) { int64u Size = Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier; mdat_Pos_Type mdat_Pos_Temp2; mdat_Pos_Temp2.Offset = *stco_Current + Chunk_Offset; mdat_Pos_Temp2.StreamID = Temp->first; mdat_Pos_Temp2.Size = Size; mdat_Pos.push_back(mdat_Pos_Temp2); Chunk_Offset += Size; Chunk_FrameCount++; } if (Chunk_FrameCount >= FrameCount_MaxPerStream) break; } Chunk_Number++; } #if MEDIAINFO_DEMUX Muxing[Temp->first].MinimalOffset=MinimalOffset; Muxing[Temp->first].MaximalOffset=MaximalOffset; #endif //MEDIAINFO_DEMUX for (size_t Pos=0; Possecond.Parsers.size(); Pos++) Temp->second.Parsers[Pos]->Stream_BitRateFromContainer=Temp->second.stsz_StreamSize*8/(((float64)Temp->second.stts_Duration)/Temp->second.mdhd_TimeScale); #if MEDIAINFO_DEMUX if (FrameCount_MaxPerStream==(int32u)-1 && !Temp_stts_Durations.empty()) { Temp->second.stts_Durations=Temp_stts_Durations; for (stsc_Current=&Temp->second.stsc[0]; stsc_CurrentSamplesPerChunk=1; Temp->second.stts_FrameCount=Temp_stts_Durations[Temp_stts_Durations.size()-1].Pos_End; } #endif //MEDIAINFO_DEMUX } } //special cases #if MEDIAINFO_DEMUX if (Temp->second.stsz.empty() && Temp->second.StreamKind==Stream_Video && Retrieve(Stream_Video, Temp->second.StreamPos, Video_CodecID)==__T("AV1x")) { //Found unknown data before the raw content 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 && Height && Temp->second.stsz_Sample_Size>(Width*Height*2)) Temp->second.Demux_Offset=Temp->second.stsz_Sample_Size-(Width*Height*2); // YUV 4:2:2 8 bit = 2 bytes per pixel } #endif //MEDIAINFO_DEMUX } std::sort(mdat_Pos.begin(), mdat_Pos.end(), &mdat_pos_sort); mdat_Pos_Temp=mdat_Pos.empty()?NULL:&mdat_Pos[0]; mdat_Pos_Max=mdat_Pos_Temp+mdat_Pos.size(); #if MEDIAINFO_DEMUX if (!stco_IsDifferent && Muxing.size()==2) { std::map::iterator Muxing_1=Muxing.begin(); std::map::iterator Muxing_2=Muxing.begin(); ++Muxing_2; if (Muxing_1->second.MaximalOffset>Muxing_2->second.MinimalOffset) swap(Muxing_1, Muxing_2); if (Muxing_1->second.MaximalOffset<=Muxing_2->second.MinimalOffset) { for (size_t stco_Pos=1; stco_Posfirst].stco[stco_Pos]]=Streams[Muxing_2->first].stco[stco_Pos-1]; StreamOffset_Jump[Streams[Muxing_2->first].stco[stco_Pos]]=Streams[Muxing_1->first].stco[stco_Pos]; } StreamOffset_Jump[Streams[Muxing_2->first].stco[0]]=Streams[Muxing_2->first].stco[stco_Count-1]; } } #endif //MEDIAINFO_DEMUX } 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_Type* Temp=&mdat_Pos[0]; int64u stco_ToFind=Streams[mdat_Pos_ToParseInPriority_StreamIDs[0]].stco[0]; while (TempOffset!=stco_ToFind) Temp++; if (TempOffset0) Element_End0(); Element_Begin1("Priority streams"); mdat_Pos_Temp=Temp; GoTo(Temp->Offset); IsParsing_mdat=true; } } mdat_Pos_ToParseInPriority_StreamIDs.erase(mdat_Pos_ToParseInPriority_StreamIDs.begin()); } if (File_GoTo==(int64u)-1 && !mdat_Pos_NormalParsing && !mdat_Pos.empty() && mdat_Pos.begin()->Offset0) Element_End0(); Element_Begin1("Second pass"); Element_ThisIsAList(); mdat_Pos_Temp=&mdat_Pos[0]; #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong()) { GoTo(0); Hash_ParseUpTo=mdat_Pos_Temp->Offset; } else #endif //MEDIAINFO_HASH GoTo(mdat_Pos_Temp->Offset); 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 //http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/QuickTime.html#ItemList case Elements::moov_meta___alb : Parameter="Album"; Method=Method_String; break; case Elements::moov_meta___ard : Parameter="Director"; Method=Method_String; break; case Elements::moov_meta___arg : Parameter="Arranger"; Method=Method_String; break; case Elements::moov_meta___ART : Parameter="Performer"; Method=Method_String; break; case Elements::moov_meta___aut : Parameter="Performer"; Method=Method_String; break; case Elements::moov_meta___con : Parameter="Conductor"; 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___lyr : Parameter="Lyrics"; 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___ope : Parameter="Original/Performer"; Method=Method_String; 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___sne : Parameter="SoundEngineer"; Method=Method_String; break; case Elements::moov_meta___sol : Parameter="Conductor"; Method=Method_String; break; case Elements::moov_meta___src : Parameter="DistributedBy"; Method=Method_String; break; case Elements::moov_meta___st3 : Parameter="Subtitle"; 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___url : Parameter="Track/Url"; 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___xpd : Parameter="ExecutiveProducer"; Method=Method_String; break; case Elements::moov_meta__aART : Parameter="Album/Performer"; Method=Method_String2; break; case Elements::moov_meta__akID : Parameter="AppleStoreAccountType"; Method=Method_Binary; 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__apID : Parameter="AppleStoreAccount"; Method=Method_String; break; case Elements::moov_meta__atID : Parameter="AlbumTitleID"; Method=Method_Binary; break; case Elements::moov_meta__auth : Parameter="Performer"; Method=Method_String2; break; case Elements::moov_meta__catg : Parameter="Category"; Method=Method_String; break; case Elements::moov_meta__cnID : Parameter="AppleStoreCatalogID"; Method=Method_String; 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__desc : Parameter="Description"; Method=Method_String; 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__egid : Parameter="EpisodeGlobalUniqueID"; Method=Method_Binary; break; case Elements::moov_meta__flvr : Parameter="Flavour"; Method=Method_Binary; break; case Elements::moov_meta__gnre : Parameter="Genre"; Method=Method_String2; break; case Elements::moov_meta__geID : Parameter="GenreID"; Method=Method_Binary; break; case Elements::moov_meta__grup : Parameter="Grouping"; Method=Method_String; break; case Elements::moov_meta__hdvd : Parameter="HDVideo"; Method=Method_Binary; break; case Elements::moov_meta__itnu : Parameter="iTunesU"; Method=Method_Binary; break; case Elements::moov_meta__keyw : Parameter="Keyword"; Method=Method_String; break; case Elements::moov_meta__ldes : Parameter="LongDescription"; Method=Method_String; break; case Elements::moov_meta__name : Parameter="Title"; Method=Method_String; break; case Elements::moov_meta__pcst : Parameter="Podcast"; Method=Method_Binary; 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__plID : Parameter="PlayListID"; Method=Method_Binary; break; case Elements::moov_meta__purd : Parameter="PurchaseDate"; Method=Method_String; break; case Elements::moov_meta__purl : Parameter="PodcastURL"; Method=Method_String; break; case Elements::moov_meta__rate : Parameter="Rating"; Method=Method_Binary; break; case Elements::moov_meta__rtng : Parameter="Rating"; Method=Method_Binary; break; case Elements::moov_meta__sdes : Parameter="Description"; Method=Method_String; break; case Elements::moov_meta__sfID : Parameter="AppleStoreCountry"; Method=Method_Binary; break; case Elements::moov_meta__soaa : Parameter="Album/Performer/Sort"; Method=Method_String; break; //SortAlbumArtist case Elements::moov_meta__soal : Parameter="Album/Sort"; Method=Method_String2; break; //SortAlbum case Elements::moov_meta__soar : Parameter="Performer/Sort"; Method=Method_String; break; //SortArtist case Elements::moov_meta__soco : Parameter="Composer/Sort"; Method=Method_String; break; //SortComposer case Elements::moov_meta__sonm : Parameter="Title/Sort"; Method=Method_String; break; //SortName case Elements::moov_meta__sosn : Parameter="Title/Sort"; Method=Method_String; break; //SortShow case Elements::moov_meta__stik : Parameter="ContentType"; Method=Method_Binary; 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__tmpo : Parameter="BPM"; Method=Method_Binary; break; case Elements::moov_meta__trkn : Parameter="Track"; Method=Method_Binary; break; case Elements::moov_meta__tven : Parameter="Part_ID"; Method=Method_Binary; break; //TVEpisodeID case Elements::moov_meta__tves : Parameter="Part"; Method=Method_String; break; //TVEpisode case Elements::moov_meta__tvnn : Parameter="TVNetworkName"; Method=Method_String; break; case Elements::moov_meta__tvsh : Parameter="Collection"; Method=Method_String; break; //TVShow case Elements::moov_meta__tvsn : Parameter="Season"; Method=Method_String; break; //TVSeason case Elements::moov_meta__xid_ : Parameter="Vendor"; Method=Method_String; break; case Elements::moov_meta__year : Parameter="Recorded_Date"; Method=Method_String2; break; case Elements::moov_meta__yyrc : Parameter="Recorded_Date"; Method=Method_String2; 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=="iTunEXTC") Parameter="ContentRating"; else if (Meta=="iTunMOVI") Parameter="iTunMOVI"; 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.PosOfStream=StreamPos_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) { for (size_t Pos=0; Pos::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::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::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::iterator Strea=Streams.begin(); Strea!=Streams.end(); ++Strea) if (!Streams[TrackID].Parsers.empty() && (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"))); } if (Strea->second.StreamKind!=Stream_Other) { Fill(Strea->second.StreamKind, Strea->second.StreamPos, "Delay", Streams[TrackID].Parsers[0]->Get(Stream_General, 0, "Delay")); Fill(Strea->second.StreamKind, Strea->second.StreamPos, "Delay_DropFrame", Streams[TrackID].TimeCode->DropFrame?__T("Yes"):__T("No")); Fill(Strea->second.StreamKind, Strea->second.StreamPos, "Delay_Source", "Container"); } //Fill(Strea->second.StreamKind, Strea->second.StreamPos, "TimeCode_FirstFrame", Streams[TrackID].Parsers[0]->Get(Stream_General, 0, "TimeCode_FirstFrame")); //Fill(Strea->second.StreamKind, Strea->second.StreamPos, "TimeCode_Source", Streams[TrackID].Parsers[0]->Get(Stream_General, 0, "TimeCode_Source")); } } //*************************************************************************** // C++ //*************************************************************************** } //NameSpace #endif //MEDIAINFO_MPEG4_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Mpeg_Psi.h0000664000000000000000000001416012652076434021554 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about MPEG files, Program Map Section // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Mpeg_PsiH #define MediaInfo_Mpeg_PsiH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Mpeg_Descriptors.h" //--------------------------------------------------------------------------- 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Ptx.cpp0000664000000000000000000007365412652076434021174 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_PTX_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_Ptx.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_Ptx::File_Ptx() :File__Analyze() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_Ptx; StreamIDs_Width[0]=sizeof(size_t); #endif //MEDIAINFO_EVENTS //Temp ReferenceFiles=NULL; } //--------------------------------------------------------------------------- File_Ptx::~File_Ptx() { delete ReferenceFiles; //ReferenceFiles=NULL; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_Ptx::Streams_Finish() { ReferenceFiles->ParseReferences(); } //*************************************************************************** // Buffer - Global //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_SEEK size_t File_Ptx::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { return ReferenceFiles->Seek(Method, Value, ID); } #endif //MEDIAINFO_SEEK //*************************************************************************** // Buffer - File header //*************************************************************************** //--------------------------------------------------------------------------- bool File_Ptx::FileHeader_Begin() { if (File_Size<0x100) { Reject("Ptx"); return false; } //Element_Size if (11>Buffer_Size) return false; //Must wait for more data if (Buffer[ 0x0]!=0x03 || Buffer[ 0x1]!=0x30 || Buffer[ 0x2]!=0x30 || Buffer[ 0x3]!=0x31 || Buffer[ 0x4]!=0x30 || Buffer[ 0x5]!=0x31 || Buffer[ 0x6]!=0x31 || Buffer[ 0x7]!=0x31 || Buffer[ 0x8]!=0x31 || Buffer[ 0x9]!=0x30 || Buffer[ 0xA]!=0x30 || Buffer[ 0xB]!=0x31 || Buffer[ 0xC]!=0x30 || Buffer[ 0xD]!=0x31 || Buffer[ 0xE]!=0x30 || Buffer[ 0xF]!=0x31 || Buffer[0x10]!=0x31) { Reject("Ptx"); return false; } //Element_Size if (Buffer_SizeElement_Size) { Element_End(); Reject(); return; } for (int32u Pos=0; PosElement_Size) { Element_End(); Reject(); return; } for (int16u Pos=0; Pos<1+Names_Count; Pos++) { Element_Begin1("Name"); Get_L4 (Name_Length, "Name length"); if (Name_Length) { Info_UTF8(Name_Length, Name, "Name"); Element_Name(Name); } Element_End(); } Element_End(); Skip_L4( "0x00000000"); Skip_L4( "0x00000000 or 0x0000002A"); Skip_L4( "Unknown [7]"); Skip_L4( "Unknown [8]"); Element_Begin1("Names list 2"); Get_L4 (Names_Count, "Names count"); if (4*Names_Count>Element_Size) { Element_End(); Reject(); return; } for (int16u Pos=0; Pos8) Skip_XX(Opaque1_Length-8, "Opaque1 - Unknown [3]"); } } Skip_L2( "0x2519"); Skip_L2( "0x0001"); Skip_L4( "0x00000000 or B5112287"); Skip_L4( "0x00000000 or 4037F9DC"); Skip_L4( "0x00000001 [1]"); Skip_L2( "0x0003"); Element_End(); Get_L4 (Audio_Count, "Audio count"); if (111*Audio_Count>Element_Size) { Reject(); return; } Element_Begin1("Audio tracks list 1"); for (int16u Pos=0; PosElement_Size) { Reject(); return; } Element_Begin1("Audio tracks list 3"); for (int16u Pos=0; Pos0x10000) { Element_End(); Element_End(); Reject(); return; } Skip_L4( "(Same 2/3) 0x0000251A"); Get_L4 (Name_Length, "(Same 1/2/3) Name length"); Info_UTF8(Name_Length, Name, "(Same 1/2/3) Name"); Skip_L2( "(Same 1/2/3) 0x0000 "); Skip_L4( "(Same 1/2/3) 0x00000000"); Skip_L4( "(Same 1/2/3) 0x0000002A"); Skip_L4( "(Same 1/2/3) Unknown"); Skip_L4( "(Same 1/2/3) Unknown"); Info_L3(Number, "(Same 1/2/3) Ordered number"); Element_Info1(Number); Skip_L2( "(Same 2/3) 0x0000"); Element_Info1(Name); if (Name_Length+31!=Size) { Element_End(); Element_End(); Reject(); return; } Element_End(); } Element_End(); Skip_L2( "0x0000 [4]"); Skip_L2( "0x0018"); Skip_L4( "0x00000001 [2]"); Skip_L2( "0x0018"); Skip_L4( "0x00000001 [2]"); Skip_L2( "0x0001 [3]"); Skip_L3( "0x00095A"); Get_L4 (Opaque2_Length, "Opaque2 length"); Skip_XX(Opaque2_Length, "Opaque2"); Skip_L1( "0x5A [2]"); Skip_L2( "0x0003 (10.0) or 0x0004 (10.2+)"); Get_L4 (Opaque2_Length, "Opaque3 length"); //0x0012 (10.0) or 0x0016 (10.2+) if (Opaque2_Length<0x12) Skip_XX(Opaque2_Length, "Opaque3"); else { Skip_L4( "Opaque3 - 0x06002026"); Skip_L4( "Opaque3 - 0x00000000 [1]"); Skip_L2( "Opaque3 - 0x0000"); Skip_L4( "Opaque3 - Unknown [1]"); Skip_L4( "Opaque3 - Unknown [2]"); if (Opaque2_Length<0x16) { if (Opaque2_Length-0x12) Skip_XX(Opaque2_Length-0x12, "Opaque3 - Unknown [3]"); } else { Skip_L4( "Opaque3 - 0x00000000 [2]"); if (Opaque2_Length>0x16) Skip_XX(Opaque2_Length-0x16, "Opaque3 - Unknown [4]"); } } Skip_L3( "0x00025A [3]"); Get_L4 (Opaque2_Length, "0x00000015 (Opaque4 length?) or something else"); if (Opaque2_Length==0x00000015) { Skip_L4( "0x075A2032"); Skip_L4( "0x00000C00"); Skip_L4( "0x01204200"); Skip_L4( "0x00000000 or 0x01000000"); Skip_L4( "Unknown [13]"); Skip_L1( "0x00 [3]"); Skip_L3( "0x00025A [4]"); Skip_L4( "Unknown [14]"); } Skip_L4( "Unknown [15]"); Skip_L4( "0x015A0000"); Skip_L4( "Unknown [16]"); Skip_L4( "Unknown [17]"); Skip_L4( "0x01000000"); Get_L4 (FileName_Count, "File name count"); if (13*FileName_Count>Element_Size) { Reject(); return; } Get_L4 (Directory_Length, "Directory length"); Get_UTF8(Directory_Length, Directory, "Directory"); Skip_L4( "0x00000000 [11]"); Element_Begin1("File names"); vector Roles; vector FileNames; vector FileNamesLowerCase; vector Purposes; for (int32u Pos=0; Pos1 || FileNames.size()==1) { size_t Pos_Offset=0; for (int32u Pos=0; PosStreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } else if (!ReferenceFiles->Sequences_Size()) Pos_Offset++; } if (Names.size()!=ReferenceFiles->Sequences_Size()) ReferenceFiles->Clear(); //Failed to detect correctly } // Role==2 + listed if (!ReferenceFiles->Sequences_Size() && (Names.size()>1 || FileNames.size()==1)) { size_t Pos_Offset=0; for (int32u Pos=0; PosStreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } else if (!ReferenceFiles->Sequences_Size()) Pos_Offset++; } else if (!ReferenceFiles->Sequences_Size()) Pos_Offset++; } if (Names.size()!=ReferenceFiles->Sequences_Size()) ReferenceFiles->Clear(); //Failed to detect correctly } // Role==2 + Purpose==EWAV + listed, special case with specific file names if (!ReferenceFiles->Sequences_Size() && (Names.size()>1 || FileNames.size()==1)) { for (int32u Pos=0; PosStreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); break; } } } } // Role==2 + Purpose==EWAV if (!ReferenceFiles->Sequences_Size()) { for (int32u Pos=0; PosStreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } } } // Role==2 if (!ReferenceFiles->Sequences_Size()) { for (int32u Pos=0; PosStreamKind=Stream_Audio; Sequence->AddFileName(Directory+PathSeparator+FileNames[Pos]); ReferenceFiles->AddSequence(Sequence); } } } FILLING_END(); } } //NameSpace #endif //MEDIAINFO_PTX_YES MediaInfoLib/Source/MediaInfo/Multiple/File_Ivf.h0000664000000000000000000000242112652076434020572 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Contributor: Lionel Duchateau, kurtnoise@free.fr // // 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 MediaInfoLib/Source/MediaInfo/Multiple/File_Ptx.h0000664000000000000000000000344512652076434020630 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Information about Pro Tools session 10 files // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_File_PtxH #define MediaInfo_File_PtxH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/File__Analyze.h" #include //--------------------------------------------------------------------------- namespace MediaInfoLib { class File__ReferenceFilesHelper; //*************************************************************************** // Class File_Ptx //*************************************************************************** class File_Ptx : public File__Analyze { public : //Constructor/Destructor File_Ptx(); ~File_Ptx(); 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 void Read_Buffer_Continue (); //Buffer - File header bool FileHeader_Begin(); //Temp File__ReferenceFilesHelper* ReferenceFiles; bool HasCpl; friend class File_DpcCpl; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File__Analyze.cpp0000664000000000000000000051224412652076434020361 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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" #include "MediaInfo/MediaInfo_Internal.h" //Only for XML escape. TODO: move XML escape function somewhere more generic #if MEDIAINFO_IBIUSAGE && MEDIAINFO_SEEK #include "MediaInfo/Multiple/File_Ibi.h" #endif //MEDIAINFO_IBIUSAGE && MEDIAINFO_SEEK #if MEDIAINFO_IBIUSAGE #include "MediaInfo/Multiple/File_Ibi_Creation.h" #endif //MEDIAINFO_IBIUSAGE #include using namespace std; using namespace tinyxml2; #if MEDIAINFO_EVENTS #include "MediaInfo/MediaInfo_Events_Internal.h" #endif //MEDIAINFO_EVENTS #ifdef MEDIAINFO_SSE2_YES #ifndef ZENLIB_MEMUTILS_SSE2 #define ZENLIB_MEMUTILS_SSE2 #endif //ZENLIB_MEMUTILS_SSE2 #include "ZenLib/MemoryUtils.h" #else //MEDIAINFO_SSE2_YES #define memcpy_Unaligned_Unaligned std::memcpy #define memcpy_Unaligned_Unaligned_Once1024 std::memcpy #endif //MEDIAINFO_SSE2_YES //--------------------------------------------------------------------------- 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_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_CurrentParser=NULL; Demux_EventWasSent_Accept_Specific=false; #endif //MEDIAINFO_DEMUX PTS_DTS_Needed=false; PTS_Begin=(int64u)-1; #if MEDIAINFO_ADVANCED2 PTS_Begin_Segment=(int64u)-1; #endif //MEDIAINFO_ADVANCED2 PTS_End=0; DTS_Begin=(int64u)-1; DTS_End=0; Frequency_c=0; Frequency_b=0; #if MEDIAINFO_ADVANCED2 PTSb=NoTs; DTSb=NoTs; #endif //MEDIAINFO_ADVANCED2 Offsets_Pos=(size_t)-1; OriginalBuffer=NULL; OriginalBuffer_Size=0; OriginalBuffer_Capacity=0; #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) ServiceDescriptors=NULL; #endif //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; FrameNumber_PresentationOrder=(int64u)-1; //Configuration DataMustAlwaysBeComplete=true; MustUseAlternativeParser=false; MustSynchronize=false; CA_system_ID_MustSkipSlices=false; FillAllMergedStreams=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=16*1024*1024; Buffer_TotalBytes_FirstSynched=0; Buffer_TotalBytes_LastSynched=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; Buffer_JunkBytes=0; Stream_BitRateFromContainer=0; //EOF EOF_AlreadyDetected=(MediaInfoLib::Config.ParseSpeed_Get()==1.0)?true:false; //Synchro MustParseTheHeaderFile=true; Synched=false; UnSynched_IsNotJunk=false; MustExtendParsingDuration=false; Trusted=Error; Trusted_Multiplier=1; //Header Header_Size=0; //Elements Element_WantNextLevel=false; //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.Value.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; //AES #if MEDIAINFO_AES AES=NULL; AES_IV=NULL; AES_Decrypted=NULL; AES_Decrypted_Size=0; #endif //MEDIAINFO_AES //Hash #if MEDIAINFO_HASH Hash=NULL; Hash_ParseUpTo=0; #endif //MEDIAINFO_HASH Unsynch_Frame_Count=(int64u)-1; #if MEDIAINFO_IBIUSAGE Ibi_SynchronizationOffset_Current=0; Ibi_SynchronizationOffset_BeginOfFrame=0; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE Config_Ibi_Create=false; IbiStream=NULL; #endif //MEDIAINFO_IBIUSAGE } //--------------------------------------------------------------------------- File__Analyze::~File__Analyze () { //Buffer delete[] Buffer_Temp; //Buffer_Temp=NULL; delete[] OriginalBuffer; //BitStream delete BS; //BS=NULL; delete BT; //BS=NULL; //AES #if MEDIAINFO_AES delete AES; //AES=NULL; delete AES_IV; //AES_IV=NULL; delete AES_Decrypted; //AES_Decrypted=NULL; #endif //MEDIAINFO_AES //Hash #if MEDIAINFO_HASH delete Hash; //Hash=NULL; #endif //MEDIAINFO_HASH #if MEDIAINFO_IBIUSAGE if (!IsSub) delete IbiStream; //IbiStream=NULL; #endif //MEDIAINFO_IBIUSAGE } //*************************************************************************** // 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(); Config->ParseSpeed=MediaInfoLib::Config.ParseSpeed_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; PosIbi_Create_Get() && Config->ParseSpeed==1.0; if (Config_Ibi_Create && !IsSub && IbiStream==NULL) IbiStream=new ibi::stream; #endif //MEDIAINFO_IBIUSAGE } 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 #if MEDIAINFO_EVENTS || StreamIDs_Size==0 #endif ) 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; PosParserIDs[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_OutOfBand (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 #if MEDIAINFO_DEMUX bool Demux_EventWasSent_Save=Config->Demux_EventWasSent; Config->Demux_EventWasSent=false; #endif //MEDIAINFO_DEMUX Sub->Open_Buffer_OutOfBand(ToAdd, ToAdd_Size); #if MEDIAINFO_DEMUX if (Demux_EventWasSent_Save) Config->Demux_EventWasSent=true; #endif //MEDIAINFO_DEMUX #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; Element[Element_Level].ToShow.Value=Sub->Element[0].ToShow.Value; Sub->Element[0].ToShow.Details.clear(); Sub->Element[0].ToShow.Value.clear(); } else Element[Element_Level].ToShow.NoShow=true; //We don't want to show this item because there is no info in it } #endif } //--------------------------------------------------------------------------- void File__Analyze::Open_Buffer_Continue (const int8u* ToAdd, size_t ToAdd_Size) { //Deleyed events #if MEDIAINFO_DEMUX if (Config->Events_Delayed_CurrentSource) { File__Analyze* Temp=Config->Events_Delayed_CurrentSource; Config->Events_Delayed_CurrentSource=NULL; Config->Event_Accepted(Temp); if (Config->Events_Delayed_CurrentSource) return; } #endif //MEDIAINFO_DEMUX if (ToAdd_Size) { Frame_Count_InThisBlock=0; Field_Count_InThisBlock=0; } //Hash #if MEDIAINFO_HASH if (ToAdd_Size) { if (!IsSub && !Buffer_Temp_Size && File_Offset==Config->File_Current_Offset && Config->File_Hash_Get().to_ulong()) { delete Hash; Hash=new HashWrapper(Config->File_Hash_Get().to_ulong()); } if (Hash) Hash->Update(ToAdd, ToAdd_Size); } #endif //MEDIAINFO_HASH //AES #if MEDIAINFO_AES if (ToAdd_Size) { if (!IsSub && !Buffer_Temp_Size && File_Offset==Config->File_Current_Offset && Config->Encryption_Format_Get()==Encryption_Format_Aes && Config->Encryption_Key_Get().size()==16 && Config->Encryption_Method_Get()==Encryption_Method_Segment && Config->Encryption_Mode_Get()==Encryption_Mode_Cbc && Config->Encryption_Padding_Get()==Encryption_Padding_Pkcs7 && Config->Encryption_InitializationVector_Get()=="Sequence number") { delete AES; AES=new AESdecrypt; AES->key128((const unsigned char*)Config->Encryption_Key_Get().c_str()); AES_IV=new int8u[16]; int128u2BigEndian(AES_IV, int128u((int64u)Config->File_Names_Pos-1)); } if (AES) { if (AES_Decrypted_Sizecbc_decrypt(ToAdd, AES_Decrypted, (int)ToAdd_Size, AES_IV); //TODO: handle the case where ToAdd_Size is more than 2GB if (File_Offset+Buffer_Size+ToAdd_Size>=Config->File_Current_Size && ToAdd_Size) { int8u LastByte=AES_Decrypted[ToAdd_Size-1]; ToAdd_Size-=LastByte; if (Config->File_Names_Pos && Config->File_Names_Pos-1File_Sizes.size()) Config->File_Sizes[Config->File_Names_Pos-1]-=LastByte; Config->File_Current_Size-=LastByte; } ToAdd=AES_Decrypted; } } #endif //MEDIAINFO_AES //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+ToAdd_Size) { File_Offset+=ToAdd_Size; return; //No need of this piece of data } } #if MEDIAINFO_HASH //Hash parsing only if (Hash_ParseUpTo>File_Offset+Buffer_Size+ToAdd_Size) { File_Offset+=ToAdd_Size; return; //No need of this piece of data } if (Hash_ParseUpTo>File_Offset && Hash_ParseUpTo<=File_Offset+ToAdd_Size) { Buffer_Offset+=(size_t)(Hash_ParseUpTo-File_Offset); Hash_ParseUpTo=0; } #endif //MEDIAINFO_HASH 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_ToAdd0) { memcpy_Unaligned_Unaligned(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 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) { if (Config->File_Size && Config->File_Size!=(int64u)-1) Config->State_Set(((float)Buffer_TotalBytes)/Config->File_Size); else if (Config->File_Names.size()>1) Config->State_Set(((float)Config->File_Names_Pos)/Config->File_Names.size()); } if (Buffer_Size>=Buffer_MinimumSize || File_Offset+Buffer_Size==File_Size) //Parsing only if we have enough buffer while (Open_Buffer_Continue_Loop()); //Hash #if MEDIAINFO_HASH if (Hash_ParseUpTo>File_Size) Hash_ParseUpTo=File_Size; if (Hash && File_Offset+Buffer_Size>=Config->File_Current_Size && Status[IsAccepted]) { for (size_t Hash_Pos=0; Hash_PosGenerate((HashWrapper::HashFunction)Hash_Pos)); string HashPos=Config->File_Names.size()>1?("Source_List_"+Hash_Name+"_Generated"):(Hash_Name+"_Generated"); if (Config->File_Names_Pos<=1 && !Retrieve(Stream_General, 0, HashPos.c_str()).empty() && Retrieve(Stream_General, 0, HashPos.c_str())==Temp) Clear(Stream_General, 0, HashPos.c_str()); Fill(Stream_General, 0, HashPos.c_str(), Temp); if (Config->File_Names_Pos<=1) (*Stream_More)[Stream_General][0](Ztring().From_Local(HashPos), Info_Options)=__T("N NT"); } delete Hash; Hash=NULL; } if (Hash && File_GoTo!=(int64u)-1) { delete Hash; Hash=NULL; //Hash not possible with a seek } if (Hash && Buffer_Offset>Buffer_Size) { //We need the next data Hash_ParseUpTo=File_Offset+Buffer_Offset; Buffer_Offset=Buffer_Size; } #endif //MEDIAINFO_HASH //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 ) { 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; if (!IsSub && !Config->File_Names.empty()) { if (Config->File_Sizes.size()>=Config->File_Names.size()) Config->File_Current_Size=Config->File_Sizes[Config->File_Names.size()-1]; Config->File_Current_Offset=Config->File_Current_Size; Config->File_Names_Pos=Config->File_Names.size()-1; } 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 MEDIAINFO_HASH if (Hash_ParseUpTo) { Buffer_Clear(); return; } #endif //MEDIAINFO_HASH if (Buffer_Offset>=Buffer_Size #if MEDIAINFO_HASH && Hash==NULL #endif //MEDIAINFO_HASH ) { if (Buffer_Offset>Buffer_Size) File_GoTo=File_Offset+Buffer_Offset; Buffer_Clear(); return; } //Buffer handling if (Buffer_Size && 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 ) { ForceFinish(); #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent) return; #endif //MEDIAINFO_DEMUX } 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_Max32768?ToAdd_Size-Buffer_Offset:32768; if (Buffer_Temp_Size_Max_ToAdd=FrameInfo.Buffer_Offset_End && FrameInfo_Next.DTS!=(int64u)-1) { FrameInfo=FrameInfo_Next; FrameInfo_Next=frame_info(); } float64 Ratio=1; if (OriginalBuffer) { Ratio=((float64)OriginalBuffer_Size)/Buffer_Size; size_t Temp_Size=(size_t)float64_int64s(((float64)Buffer_Offset)*Ratio); OriginalBuffer_Size-=Temp_Size; memmove(OriginalBuffer, OriginalBuffer+Buffer_Offset, OriginalBuffer_Size); } Buffer_Size-=Buffer_Offset; File_Offset+=Buffer_Offset; if (Buffer_Offset_Temp>=Buffer_Offset) Buffer_Offset_Temp-=Buffer_Offset; if (FrameInfo.Buffer_Offset_End!=(int64u)-1 && FrameInfo.Buffer_Offset_End>=Buffer_Offset) FrameInfo.Buffer_Offset_End-=Buffer_Offset; if (FrameInfo_Next.Buffer_Offset_End!=(int64u)-1 && FrameInfo_Next.Buffer_Offset_End>=Buffer_Offset) FrameInfo_Next.Buffer_Offset_End-=Buffer_Offset; if (!Offsets_Buffer.empty()) { if (Offsets_Buffer.size()>=2 && Offsets_Buffer.size()%2==0 && Offsets_Buffer[0]==Offsets_Buffer[1]) { size_t Pos=Offsets_Buffer.size()-2; do { if (Offsets_Buffer[Pos]>Buffer_Offset) { Offsets_Buffer[Pos]-=Buffer_Offset; Offsets_Buffer[Pos+1]-=Buffer_Offset; } else { Offsets_Stream[Pos]+=float64_int64s(Buffer_Offset*Ratio/2)-Offsets_Buffer[Pos]; Offsets_Stream[Pos+1]+=float64_int64s(Buffer_Offset*Ratio/2)-Offsets_Buffer[Pos+1]; Offsets_Buffer[Pos]=0; Offsets_Buffer[Pos+1]=0; Offsets_Buffer.erase(Offsets_Buffer.begin(), Offsets_Buffer.begin()+Pos); Offsets_Stream.erase(Offsets_Stream.begin(), Offsets_Stream.begin()+Pos); if (Offsets_Pos!=(size_t)-1 && Pos) { if (PosBuffer_Offset*Ratio) Offsets_Buffer[Pos]-=float64_int64s(Buffer_Offset*Ratio); else { Offsets_Stream[Pos]+=float64_int64s(Buffer_Offset*Ratio)-Offsets_Buffer[Pos]; Offsets_Buffer[Pos]=0; Offsets_Buffer.erase(Offsets_Buffer.begin(), Offsets_Buffer.begin()+Pos); Offsets_Stream.erase(Offsets_Stream.begin(), Offsets_Stream.begin()+Pos); if (Offsets_Pos!=(size_t)-1 && Pos) { if (PosBuffer_MaximumSize) { #if MEDIAINFO_HASH if (Config->File_Hash_Get().to_ulong() && Hash && Status[IsAccepted]) { Buffer_Clear(); Hash_ParseUpTo=File_Size; } else #endif //MEDIAINFO_HASH ForceFinish(); return; } } void File__Analyze::Open_Buffer_Continue (File__Analyze* Sub, const int8u* ToAdd, size_t ToAdd_Size, bool IsNewPacket, float64 Ratio) { 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 (IsNewPacket && ToAdd_Size) { if (Offsets_Stream.empty()) { Sub->Offsets_Stream.push_back(File_Offset+float64_int64s((Buffer_Offset+Element_Offset)*Ratio)); Sub->Offsets_Buffer.push_back(Sub->Buffer_Size); } else { if (Offsets_Buffer[0]>=Buffer_Offset-Header_Size && (Sub->Offsets_Stream.empty() || Sub->Offsets_Stream[Sub->Offsets_Stream.size()-1]+Sub->Buffer_Size-Sub->Offsets_Buffer[Sub->Offsets_Stream.size()-1]!=Offsets_Stream[0])) { if ((Buffer_Offset-Header_Size)*RatioOffsets_Stream.push_back(Offsets_Stream[0]); Sub->Offsets_Buffer.push_back((Sub->OriginalBuffer_Size?Sub->OriginalBuffer_Size:Sub->Buffer_Size)+Offsets_Buffer[0]-(Buffer_Offset+Element_Offset)); } else { Sub->Offsets_Stream.push_back(Offsets_Stream[0]+Buffer_Offset+Element_Offset-Offsets_Buffer[0]); Sub->Offsets_Buffer.push_back(Sub->OriginalBuffer_Size?Sub->OriginalBuffer_Size:Sub->Buffer_Size); } } for (size_t Pos=1; Pos=Buffer_Offset+Element_Offset && Offsets_Buffer[Pos]Offsets_Stream.push_back(Offsets_Stream[Pos]); Sub->Offsets_Buffer.push_back((Sub->OriginalBuffer_Size?Sub->OriginalBuffer_Size:Sub->Buffer_Size)+Offsets_Buffer[Pos]-(Buffer_Offset+Element_Offset)); } else { Sub->Offsets_Stream.push_back(Offsets_Stream[Pos]+Buffer_Offset+Element_Offset-Offsets_Buffer[Pos]); Sub->Offsets_Buffer.push_back(Sub->OriginalBuffer_Size?Sub->OriginalBuffer_Size:Sub->Buffer_Size); } } } } if (Ratio!=1) { if (Sub->OriginalBuffer_Size+Element_Size-Element_Offset>Sub->OriginalBuffer_Capacity) { int8u* Temp=Sub->OriginalBuffer; Sub->OriginalBuffer_Capacity=(size_t)(Sub->OriginalBuffer_Size+Element_Size-Element_Offset); Sub->OriginalBuffer=new int8u[Sub->OriginalBuffer_Capacity]; memcpy_Unaligned_Unaligned(Sub->OriginalBuffer, Temp, Sub->OriginalBuffer_Size); delete[] Temp; } memcpy_Unaligned_Unaligned(Sub->OriginalBuffer+Sub->OriginalBuffer_Size, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); Sub->OriginalBuffer_Size+=(size_t)(Element_Size-Element_Offset); } #if MEDIAINFO_ADVANCED2 if (Frequency_c) Sub->Frequency_c=Frequency_c; #endif //MEDIAINFO_ADVANCED2 if (Sub->FrameInfo.DTS!=(int64u)-1) Sub->FrameInfo.Buffer_Offset_End=Sub->Buffer_Offset+Sub->Buffer_Size+ToAdd_Size; else if (Sub->FrameInfo_Previous.DTS!=(int64u)-1) Sub->FrameInfo_Previous.Buffer_Offset_End=Sub->Buffer_Offset+Sub->Buffer_Size+ToAdd_Size; if (Sub->FrameInfo_Previous.DTS!=(int64u)-1) { 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) { //Previous item size_t Details_lt_Pos=Element[Element_Level].ToShow.Details.rfind(__T("<")); size_t Details_gt_Pos=Element[Element_Level].ToShow.Details.rfind(__T(">")); if (Details_lt_Pos!=string::npos && (Details_lt_Pos+1>=Element[Element_Level].ToShow.Details.size() || Details_gt_Pos==string::npos || (Details_lt_Pos>Details_gt_Pos && Element[Element_Level].ToShow.Details[Details_lt_Pos+1]!=__T('/')))) //else there is content like " />" Element[Element_Level].ToShow.Details+=__T(">")+Element[Element_Level].ToShow.Value+__T(""); //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; Element[Element_Level].ToShow.Value=Sub->Element[0].ToShow.Value; Sub->Element[0].ToShow.Details.clear(); Sub->Element[0].ToShow.Value.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 if (sizeof(size_t)=(int64u)(size_t)-1) GoTo(File_Offset+Buffer_Offset+Element_Offset); else 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_Offset=File_Offset && Hash_ParseUpTo=File_Offset && File_GoTo32768?Buffer_Temp_Size:32768; if (Buffer_Temp_Size_Max_ToAddDemux_EventWasSent) return false; #endif //MEDIAINFO_DEMUX return true; } #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent) return false; #endif //MEDIAINFO_DEMUX //Parsing specific Read_Buffer_AfterParsing(); //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; } //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED2 void File__Analyze::Open_Buffer_SegmentChange () { Read_Buffer_SegmentChange(); } #endif //MEDIAINFO_ADVANCED2 //--------------------------------------------------------------------------- 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; StreamPos0) 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]) { EVENT_BEGIN (General, End, 0) if (Event.StreamIDs_Size>=1) Event.StreamIDs[Event.StreamIDs_Size-1]=(int64u)-1; Event.PCR=(int64u)-1; Event.DTS=(int64u)-1; Event.PTS=(int64u)-1; Event.DUR=(int64u)-1; Event.Stream_Bytes_Analyzed=Buffer_TotalBytes; Event.Stream_Size=File_Size; Event.Stream_Bytes_Padding=Buffer_PaddingBytes; Event.Stream_Bytes_Junk=Buffer_JunkBytes; if (!IsSub && MustSynchronize && !Synched && !UnSynched_IsNotJunk) Event.Stream_Bytes_Junk+=Buffer_TotalBytes+Buffer_Offset-Buffer_TotalBytes_LastSynched; EVENT_END () } #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) { size_t ReturnValue=Ibi_Read_Buffer_Seek(Method, Value, ID); if (ReturnValue!=(size_t)-1) // If IBI file is supported return ReturnValue; } #endif //MEDIAINFO_IBI //Parsing switch (Method) { case 0 : //Default stream seek (byte offset) GoTo(Value); Open_Buffer_Unsynch(); return 1; case 1 : //Default stream seek (percentage) GoTo(File_Size*Value/10000); Open_Buffer_Unsynch(); return 1; default : 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 : { if (Value>=Config->File_Size) return 2; //Invalid value int64u Offset=0; for (size_t Pos=0; PosFile_Sizes.size(); Pos++) { Offset+=Config->File_Sizes[Pos]; if (Offset>=Value) { Offset-=Config->File_Sizes[Pos]; break; } } GoTo(Offset); Open_Buffer_Unsynch(); return 1; } case 1 : { if (Value>=10000) return 2; //Invalid value size_t FilePos=(size_t)((((float32)Value)/10000)*Config->File_Sizes.size()); int64u Offset=0; for (size_t Pos=0; PosFile_Sizes[Pos]; GoTo(Offset); Open_Buffer_Unsynch(); return 1; } case 2 : //Timestamp #if MEDIAINFO_DEMUX if (Config->Demux_Rate_Get()==0) return (size_t)-1; //Not supported Value=float64_int64s(((float64)Value)/1000000000*Config->Demux_Rate_Get()); #else //MEDIAINFO_DEMUX return (size_t)-1; //Not supported #endif //MEDIAINFO_DEMUX case 3 : //FrameNumber { if (Value>=Config->File_Names.size()) return 2; //Invalid value int64u Offset=0; if (Config->File_Sizes.size()!=Config->File_Names.size()) { Offset=Value; //File_GoTo is the frame offset in that case Config->File_GoTo_IsFrameOffset=true; } else for (size_t Pos=0; PosFile_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() { #if MEDIAINFO_ADVANCED if (Config->File_Sizes.size()!=Config->File_Names.size()) { Frame_Count_NotParsedIncluded=File_GoTo; } else #endif //MEDIAINFO_ADVANCED { int64u GoTo=File_GoTo; for (Frame_Count_NotParsedIncluded=0; Frame_Count_NotParsedIncludedFile_Sizes.size(); Frame_Count_NotParsedIncluded++) { if (GoTo>=Config->File_Sizes[(size_t)Frame_Count_NotParsedIncluded]) GoTo-=Config->File_Sizes[(size_t)Frame_Count_NotParsedIncluded]; else break; } } #if MEDIAINFO_DEMUX if (!IsSub && Config->Demux_Rate_Get()) //TODO: remove !IsSub when time code delay is removed from PTS { FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded*((float64)1000000000)/Config->Demux_Rate_Get()); FrameInfo.PTS=FrameInfo.DTS; } else FrameInfo.PTS=FrameInfo.DTS=(int64u)-1; #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 //Offsets if (Offsets_Pos==(size_t)-1 && !Offsets_Buffer.empty()) Offsets_Pos=0; if (Offsets_Pos!=(size_t)-1) { while (Offsets_PosOffsets_Buffer[Offsets_Pos]) Offsets_Pos++; if (Offsets_Pos>=Offsets_Buffer.size() || Buffer_Offset!=Offsets_Buffer[Offsets_Pos]) Offsets_Pos--; } //Header if (!Header_Manage()) return false; //Wait for more data //Data if (!Data_Manage()) return false; //Wait for more data Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset; return true; } //--------------------------------------------------------------------------- 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; if (!IsSub && !Config->File_Names.empty()) { if (Config->File_Sizes.size()>=Config->File_Names.size()) Config->File_Current_Size=Config->File_Sizes[Config->File_Names.size()-1]; Config->File_Current_Offset=Config->File_Current_Size; Config->File_Names_Pos=Config->File_Names.size()-1; } } Buffer_Size=0; Buffer_Temp_Size=0; Buffer_Offset=0; Buffer_Offset_Temp=0; Buffer_MinimumSize=0; OriginalBuffer_Size=0; Offsets_Stream.clear(); Offsets_Buffer.clear(); Offsets_Pos=(size_t)-1; //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_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 || Magic4==0x1A45DFA3) { 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 (!IsSub && (File_Size<32 || File_Size>16*1024*1024)) { Reject(); return false; //XML files are not expected to be so big } //Element_Size if (!IsSub && Buffer_SizeFrameInfo.PTS=FrameInfo.PTS; if (Type&TS_DTS && FrameInfo.DTS!=(int64u)-1) Parser->FrameInfo.DTS=FrameInfo.DTS; #if MEDIAINFO_ADVANCED2 if (Type&TS_PTS && FrameInfo.PTSc!=NoTs) Parser->FrameInfo.PTSc=FrameInfo.PTSc; if (Type&TS_DTS && FrameInfo.DTSc!=NoTs) Parser->FrameInfo.DTSc=FrameInfo.DTSc; if (!FrameInfo.Frame_Count_AfterLastTimeStamp) Parser->FrameInfo.Frame_Count_AfterLastTimeStamp=0; #endif //MEDIAINFO_ADVANCED2 } //--------------------------------------------------------------------------- void File__Analyze::TS_Ajust(int64s Ticks) { #if MEDIAINFO_ADVANCED2 if (IsRawStream) { if (PTSb==NoTs) { if (FrameInfo.DTSc!=NoTs) PTSb=FrameInfo.DTSc*Frequency_b+Ticks*FrameInfo.Frame_Count_AfterLastTimeStamp*(Frequency_c?Frequency_c:1); // Relying on DTS only, ajustment is done by the function itself else PTSb=-Ticks*FrameInfo.Frame_Count_AfterLastTimeStamp*(Frequency_c?Frequency_c:1); } if (PTSb!=NoTs) PTSb+=Ticks*(Frequency_c?Frequency_c:1); } else { if (PTSb!=NoTs) PTSb+=Ticks; } #endif //MEDIAINFO_ADVANCED2 } //--------------------------------------------------------------------------- void File__Analyze::TS_Add(int64s Ticks, ts_type Type) { if (IsRawStream) { //Coherency test if (!Frequency_b) { #if MEDIAINFO_ADVANCED2 FrameInfo.Frame_Count_AfterLastTimeStamp++; #endif //MEDIAINFO_ADVANCED2 return; } #if MEDIAINFO_ADVANCED2 //Filling first TS if not set somewhere else if (Type&TS_PTS && PTSb==NoTs) { if (FrameInfo.PTSc!=NoTs) PTSb=FrameInfo.PTSc*Frequency_b+Ticks*FrameInfo.Frame_Count_AfterLastTimeStamp*(Frequency_c?Frequency_c:1); else PTSb=-Ticks*FrameInfo.Frame_Count_AfterLastTimeStamp*(Frequency_c?Frequency_c:1); } if (Type&TS_DTS && DTSb==NoTs) { if (FrameInfo.DTSc!=NoTs) DTSb=FrameInfo.DTSc*Frequency_b+Ticks*FrameInfo.Frame_Count_AfterLastTimeStamp*(Frequency_c?Frequency_c:1); else DTSb=-Ticks*FrameInfo.Frame_Count_AfterLastTimeStamp*(Frequency_c?Frequency_c:1); } //Coherency test if (Type&TS_PTS && PTSb!=NoTs && FrameInfo.PTSc!=NoTs) { if (!FrameInfo.Frame_Count_AfterLastTimeStamp && PTSb != FrameInfo.PTSc*Frequency_b && (FrameInfo.PTSc*Frequency_b-PTSb<=-Frequency_b || FrameInfo.PTSc*Frequency_b-PTSb>=Frequency_b)) { PTSb=FrameInfo.PTSc*Frequency_b; } } if (Type&TS_DTS && DTSb!=NoTs && FrameInfo.DTSc!=NoTs) { if (!FrameInfo.Frame_Count_AfterLastTimeStamp && DTSb != FrameInfo.DTSc*Frequency_b && (FrameInfo.DTSc*Frequency_b-DTSb<=-Frequency_b || FrameInfo.DTSc*Frequency_b-DTSb>=Frequency_b)) { DTSb=FrameInfo.DTSc*Frequency_b; } } #endif //MEDIAINFO_ADVANCED2 } //Trace #if MEDIAINFO_ADVANCED2 Element_Info1(Ztring::ToZtring(Frame_Count)); Element_Info1C((DTSb!=NoTs && DTSb!=PTSb), __T("DTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)DTSb)*1000/(Frequency_c?Frequency_c:1)/Frequency_b))); Element_Info1C((PTSb!=NoTs), __T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)PTSb)*1000/(Frequency_c?Frequency_c:1)/Frequency_b))); #else //MEDIAINFO_ADVANCED2 Element_Info1C((FrameInfo.DTS!=(int64u)-1 && FrameInfo.PTS!=(int64u)-1), __T("DTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/1000000))); Element_Info1C((FrameInfo.PTS!=(int64u)-1), __T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000))); Element_Info1(Frame_Count); #endif //MEDIAINFO_ADVANCED2 //Adding timestamp FrameInfo.DUR=Ticks*1000000000/Frequency_b; if (Type&TS_PTS && FrameInfo.PTS!=(int64u)-1 && Frequency_b) FrameInfo.PTS+=FrameInfo.DUR; if (Type&TS_DTS && FrameInfo.DTS!=(int64u)-1 && Frequency_b) FrameInfo.DTS+=FrameInfo.DUR; #if MEDIAINFO_ADVANCED2 if (IsRawStream) { if (Type&TS_PTS && PTSb!=NoTs) PTSb+=Ticks*(Frequency_c?Frequency_c:1); if (Type&TS_DTS && DTSb!=NoTs) DTSb+=Ticks*(Frequency_c?Frequency_c:1); } else { if (Type&TS_PTS && PTSb!=NoTs) PTSb+=Ticks; if (Type&TS_DTS && DTSb!=NoTs) DTSb+=Ticks; } FrameInfo.Frame_Count_AfterLastTimeStamp++; #endif //MEDIAINFO_ADVANCED2 Frame_Count++; Frame_Count_InThisBlock++; if (Frame_Count_NotParsedIncluded!=(int64u)-1) Frame_Count_NotParsedIncluded++; } //*************************************************************************** // Synchro //*************************************************************************** //--------------------------------------------------------------------------- bool File__Analyze::Synchro_Manage() { //Testing if synchro is OK if (Synched) { if (!IsSub) Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset; if (!Synchro_Manage_Test()) return false; } //Trying to synchronize if (!Synched) { //Buffer_TotalBytes_Fill_Max if (!Status[IsFilled] && Buffer_TotalBytes>=Buffer_TotalBytes_Fill_Max) { Open_Buffer_Unsynch(); GoToFromEnd(0); return false; } if (!Synchronize()) { if (Status[IsFinished]) Finish(); //Finish if (!IsSub && File_Offset_FirstSynched==(int64u)-1 && Buffer_TotalBytes+Buffer_Offset>=Buffer_TotalBytes_FirstSynched_Max) { Open_Buffer_Unsynch(); GoToFromEnd(0); } return false; //Wait for more data } Synched=true; if (!IsSub) { if (!UnSynched_IsNotJunk) Buffer_JunkBytes+=Buffer_TotalBytes+Buffer_Offset-Buffer_TotalBytes_LastSynched; Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset; UnSynched_IsNotJunk=false; } 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 (Buffer_Offset>=FrameInfo.Buffer_Offset_End && FrameInfo_Next.DTS!=(int64u)-1) { FrameInfo=FrameInfo_Next; FrameInfo_Next=frame_info(); } if (Synched) { if (!IsSub) Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset; } else { Element[Element_Level].IsComplete=true; //Else the trusting algo will think it Trusted_IsNot("Synchronisation lost"); while (Element_Level) Element_End(); } } //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 (!IsSub) { if (!UnSynched_IsNotJunk) Buffer_JunkBytes+=Buffer_TotalBytes+Buffer_Offset-Buffer_TotalBytes_LastSynched; Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset; UnSynched_IsNotJunk=false; } 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 } //Positionning if ((Buffer_Size && Buffer_Offset+Element_Offset>Buffer_Size) || (sizeof(size_t)=(int64u)(size_t)-1)) { GoTo(File_Offset+Buffer_Offset+Element_Offset); return false; } else { Buffer_Offset+=(size_t)Element_Offset; Element_Offset=0; } #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent) return false; #endif //MEDIAINFO_DEMUX //From the parser Element_Size=Buffer_Size-Buffer_Offset; 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(); Element[Element_Level].ToShow.Value.clear(); #endif //MEDIAINFO_TRACE return false; } //Positionning if ((Buffer_Size && Buffer_Offset+Element_Offset>Buffer_Size) || (sizeof(size_t)=(int64u)(size_t)-1)) { GoTo(File_Offset+Buffer_Offset+Element_Offset); return false; } else { Buffer_Offset+=(size_t)Element_Offset; Element_Offset=0; } 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 { Element[Element_Level].UnTrusted=false; Header_Fill_Code(0, "Problem"); if (MustSynchronize) { //Unsynchronizing to the next byte Element_Offset=1; Header_Fill_Size(1); Synched=false; } else { //Can not synchronize anymore in this block Element_Offset=Element[Element_Level-2].Next-(File_Offset+Buffer_Offset); Header_Fill_Size(Element_Offset); } } 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("Block can't have a size of 0"); if (DataMustAlwaysBeComplete && Size>Buffer_MaximumSize) { Element[Element_Level].IsComplete=true; Element[Element_Level-1].IsComplete=true; Trusted_IsNot("Block is too big"); } if (Element[Element_Level].UnTrusted) return; //Integrity if (SizeElement[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 (Buffer_Offset+(Element_WantNextLevel?Element_Offset:Element_Size)>=FrameInfo.Buffer_Offset_End) { if (Frame_Count_Previous=FrameInfo.Buffer_Offset_End && FrameInfo_Next.DTS!=(int64u)-1) { FrameInfo=FrameInfo_Next; FrameInfo_Next=frame_info(); } //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 (!Element_WantNextLevel && DataMustAlwaysBeComplete && Element_Offset=(int64u)(size_t)-1) GoTo(File_Offset+Buffer_Offset+Element_Offset); else Buffer_Offset+=(size_t)Element_Offset; } Header_Size=0; Element_Size=0; Element_Offset=0; return false; } //Next element if (!Element_WantNextLevel #if MEDIAINFO_HASH && Hash==NULL #endif //MEDIAINFO_HASH ) { 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 (!Element_WantNextLevel && Element_Offset=(int64u)(size_t)-1) GoTo(File_Offset+Buffer_Offset+Element_Offset); else 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 if (!Element_WantNextLevel) Element_End0(); //Element 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_SizeParseSpeed==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) { Ztring Pos2; switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : break; default : if (OffsetToShow==(int64u)-1) return __T(" "); int64u Offset=OffsetToShow%0x100000000ULL; //Only 32 bits Ztring Pos1; Pos1.From_Number(Offset, 16); 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; case MediaInfo_Config::Trace_Format_XML : Pos2+=__T("")); if (Details_lt_Pos!=string::npos && (Details_lt_Pos+1>=Element[Element_Level].ToShow.Details.size() || Details_gt_Pos==string::npos || (Details_lt_Pos>Details_gt_Pos && Element[Element_Level].ToShow.Details[Details_lt_Pos+1]!=__T('/')))) //else there is content like " />" Element[Element_Level].ToShow.Details+=__T(">")+Element[Element_Level].ToShow.Value+__T(""); } Element[Element_Level].ToShow.Value.clear(); break; default : ; } } #endif //MEDIAINFO_TRACE //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.Value.clear(); Element[Element_Level].ToShow.NoShow=false; } #endif //MEDIAINFO_TRACE } //--------------------------------------------------------------------------- #if MEDIAINFO_TRACE void File__Analyze::Element_Begin(const Ztring &Name) { if (Trace_Activated) { switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : { size_t Details_lt_Pos=Element[Element_Level].ToShow.Details.rfind(__T("<")); size_t Details_gt_Pos=Element[Element_Level].ToShow.Details.rfind(__T(">")); if (Details_lt_Pos!=string::npos && (Details_lt_Pos+1>=Element[Element_Level].ToShow.Details.size() || Details_gt_Pos==string::npos || (Details_lt_Pos>Details_gt_Pos && Element[Element_Level].ToShow.Details[Details_lt_Pos+1]!=__T('/')))) //else there is content like " />" Element[Element_Level].ToShow.Details+=__T(">")+Element[Element_Level].ToShow.Value+__T(""); } Element[Element_Level].ToShow.Value.clear(); break; default : ; } } //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.Value.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; case MediaInfo_Config::Trace_Format_XML : { if (Element[Element_Level].ToShow.Info.find(__T(" info7=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info8=\""); else if (Element[Element_Level].ToShow.Info.find(__T(" info6=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info7=\""); else if (Element[Element_Level].ToShow.Info.find(__T(" info5=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info6=\""); else if (Element[Element_Level].ToShow.Info.find(__T(" info4=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info5=\""); else if (Element[Element_Level].ToShow.Info.find(__T(" info3=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info4=\""); else if (Element[Element_Level].ToShow.Info.find(__T(" info2=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info3=\""); else if (Element[Element_Level].ToShow.Info.find(__T(" info=\""))!=string::npos) Element[Element_Level].ToShow.Info+=__T(" info2=\""); else Element[Element_Level].ToShow.Info+=__T(" info=\""); } break; default : ; } size_t Modified; Element[Element_Level].ToShow.Info+=MediaInfo_Internal::Xml_Content_Escape(Parameter2, Modified); switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : Element[Element_Level].ToShow.Info+=__T("\""); break; default : ; } } #endif //MEDIAINFO_TRACE //--------------------------------------------------------------------------- #if MEDIAINFO_TRACE void File__Analyze::Element_Parser(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 switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : { Element[Element_Level].ToShow.Info+=__T(" parser=\""); size_t Modified; Element[Element_Level].ToShow.Info+=MediaInfo_Internal::Xml_Content_Escape(Parameter, Modified); Element[Element_Level].ToShow.Info+=__T("\""); } break; default : ; } } #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()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].ToShow.Value=Element[Element_Level+1].ToShow.Value; Element[Element_Level+1].ToShow.Details.clear(); Element[Element_Level+1].ToShow.Value.clear(); // switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : { size_t Details_lt_Pos=Element[Element_Level].ToShow.Details.rfind(__T("<")); size_t Details_gt_Pos=Element[Element_Level].ToShow.Details.rfind(__T(">")); if (Details_lt_Pos!=string::npos && (Details_lt_Pos+1>=Element[Element_Level].ToShow.Details.size() || Details_gt_Pos==string::npos || (Details_lt_Pos>Details_gt_Pos && Element[Element_Level].ToShow.Details[Details_lt_Pos+1]!=__T('/')))) //else there is content like " />" Element[Element_Level].ToShow.Details+=__T(">")+Element[Element_Level].ToShow.Value+__T(""); Element[Element_Level].ToShow.Value.clear(); //if (!Element_WantNextLevel) { Element[Element_Level].ToShow.Details+=Config_LineSeparator; Element[Element_Level].ToShow.Details.resize(Element[Element_Level].ToShow.Details.size()+(Element_Level_Base+Element_Level+1)*4, __T(' ')); Element[Element_Level].ToShow.Details+=__T(""); //Retrieving the beginning of the corresponding XML element Ztring ToFind=Config_LineSeparator; ToFind.resize(ToFind.size()+(Element_Level_Base+Element_Level+1)*4, __T(' ')); ToFind+=__T(""), Start); if (DataPos==(size_t)-1) Element[Element_Level].ToShow.Details.resize(Start); } break; default : ; } } } } } #endif //MEDIAINFO_TRACE #if MEDIAINFO_TRACE //--------------------------------------------------------------------------- Ztring File__Analyze::Element_End_Common_Flush_Build() { Ztring ToReturn; //Show Offset switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : ToReturn.resize((ToReturn.size()+Element_Level_Base+Element_Level+1)*4, __T(' ')); break; default : ; } 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; case MediaInfo_Config::Trace_Format_XML : ToReturn+=__T( " name=\""); break; default : ; } ToReturn+=Element[Element_Level+1].ToShow.Name; switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : ToReturn+=__T( "\""); break; default : ; } //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; case MediaInfo_Config::Trace_Format_XML : ToReturn+=__T(" size=\""); 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); } */ switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : ToReturn+=__T("\">"); break; default : 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; //Line separator if (!Element[Element_Level].ToShow.Details.empty()) { switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : { size_t Details_lt_Pos=Element[Element_Level].ToShow.Details.rfind(__T("<")); size_t Details_gt_Pos=Element[Element_Level].ToShow.Details.rfind(__T(">")); if (Details_lt_Pos!=string::npos && (Details_lt_Pos+1>=Element[Element_Level].ToShow.Details.size() || Details_gt_Pos==string::npos || (Details_lt_Pos>Details_gt_Pos && Element[Element_Level].ToShow.Details[Details_lt_Pos+1]!=__T('/')))) //else there is content like " />" Element[Element_Level].ToShow.Details+=__T(">")+Element[Element_Level].ToShow.Value+__T(""); Element[Element_Level].ToShow.Value=Value; } break; default: ; } Element[Element_Level].ToShow.Details+=Config_LineSeparator; } //Prefix switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : Element[Element_Level].ToShow.Details.resize(Element[Element_Level].ToShow.Details.size()+(Element_Level_Base+Element_Level+1)*4, __T(' ')); break; default : ; } //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 : { const size_t Padding_Value=40; //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; case MediaInfo_Config::Trace_Format_XML : Element[Element_Level].ToShow.Details+=__T(" name=\""); Element[Element_Level].ToShow.Details+=Parameter; Element[Element_Level].ToShow.Details+=__T("\""); { size_t Max = Value.find(__T(" (0x")); size_t Modified; if (Max==string::npos) Element[Element_Level].ToShow.Value=MediaInfo_Internal::Xml_Content_Escape(Value, Modified); else Element[Element_Level].ToShow.Value=MediaInfo_Internal::Xml_Content_Escape(Value.substr(0, Max), Modified); if (Modified==1 && !MediaInfoLib::Config.SkipBinaryData_Get()) //Base64 Element[Element_Level].ToShow.Details+=__T(" dt=\"binary.base64\""); if (Modified==1 && MediaInfoLib::Config.SkipBinaryData_Get()) Element[Element_Level].ToShow.Value=__T("(Binary data)"); } if (!Element_Level) //Close function will not be called. TODO: find a better method { Element_Begin(); Element_End(); } 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.Value.empty()) Element[Element_Level_Final].ToShow.Details+=Config_LineSeparator; //Preparing switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : return; default : ; } 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 size_t End=Element[Element_Level].ToShow.Details.size(); switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_Tree : case MediaInfo_Config::Trace_Format_CSV : Element[Element_Level].ToShow.Details+=__T(" - "); break; case MediaInfo_Config::Trace_Format_XML : { size_t Start=Element[Element_Level].ToShow.Details.rfind(Config_LineSeparator); if (Start==(size_t)-1) Start=0; End=Element[Element_Level].ToShow.Details.find(__T('>'), Start); if (End==(size_t)-1) End=Element[Element_Level].ToShow.Details.size(); if (Element[Element_Level].ToShow.Details.find(__T(" info7=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info8=\"")); else if (Element[Element_Level].ToShow.Details.find(__T(" info6=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info7=\"")); else if (Element[Element_Level].ToShow.Details.find(__T(" info5=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info6=\"")); else if (Element[Element_Level].ToShow.Details.find(__T(" info4=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info5=\"")); else if (Element[Element_Level].ToShow.Details.find(__T(" info3=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info4=\"")); else if (Element[Element_Level].ToShow.Details.find(__T(" info2=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info3=\"")); else if (Element[Element_Level].ToShow.Details.find(__T(" info=\""), Start)!=string::npos) Element[Element_Level].ToShow.Details.insert(End, __T(" info2=\"")); else Element[Element_Level].ToShow.Details.insert(End, __T(" info=\"")); End=Element[Element_Level].ToShow.Details.find(__T('>'), Start); if (End==(size_t)-1) End=Element[Element_Level].ToShow.Details.size(); } break; default : ; } size_t Modified; Element[Element_Level].ToShow.Details.insert(End, MediaInfo_Internal::Xml_Content_Escape(Text, Modified)); switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : { size_t Start=Element[Element_Level].ToShow.Details.rfind(Config_LineSeparator); if (Start==(size_t)-1) Start=0; End=Element[Element_Level].ToShow.Details.find(__T('>'), Start); if (End==(size_t)-1) End=Element[Element_Level].ToShow.Details.size(); Element[Element_Level].ToShow.Details.insert(End, __T("\"")); break; } break; default : ; } } #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 && !Status[IsAccepted]) 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); switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_Tree : if (!ParserName.empty()) { bool MustElementBegin=Element_Level?true:false; if (Element_Level>0) Element_End0(); //Element Info(ParserName+__T(", accepted")); if (MustElementBegin) Element_Level++; } break; default : ; } #endif //MEDIAINFO_TRACE Status[IsAccepted]=true; if (Count_Get(Stream_General)==0) { Stream_Prepare(Stream_General); Streams_Accept(); } #if MEDIAINFO_EVENTS if (!IsSub) { EVENT_BEGIN (General, Parser_Selected, 0) std::memset(Event.Name, 0, 16); if (!ParserName.empty()) strncpy(Event.Name, ParserName.To_Local().c_str(), 15); EVENT_END () #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (!Demux_EventWasSent_Accept_Specific && Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet()) Config->Demux_EventWasSent=true; #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET } Config->Event_Accepted(this); #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); switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_Tree : if (!ParserName.empty()) { bool MustElementBegin=Element_Level?true:false; if (Element_Level>0) Element_End0(); //Element Info(ParserName+__T(", filling")); if (MustElementBegin) Element_Level++; } break; default : ; } #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 switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_Tree : 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++; } break; default : ; } #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); switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_Tree : if (!ParserName.empty()) { bool MustElementBegin=Element_Level?true:false; if (Element_Level>0) Element_End0(); //Element Info(ParserName+__T(", finished")); if (MustElementBegin) Element_Level++; } break; default : ; } #endif //MEDIAINFO_TRACE if (Status[IsAccepted]) { //Total file size #if MEDIAINFO_ADVANCED if (!IsSub && !(!Config->File_IgnoreSequenceFileSize_Get() || Config->File_Names.size()<=1) && Config->ParseSpeed>=1.0 && Config->File_Names.size()>1 && Config->File_Names_Pos+1>=Config->File_Names.size()) { Fill (Stream_General, 0, General_FileSize, Config->File_Current_Size, 10, true); } #endif //MEDIAINFO_ADVANCED Fill(); #if MEDIAINFO_DEMUX if (Config->Demux_EventWasSent) return; #endif //MEDIAINFO_DEMUX Streams_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 Ibi_Stream_Finish(); } 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); } //Frame count if (Config->ParseSpeed==1 && IsRawStream && Frame_Count && Frame_Count!=(int64u)-1 && Retrieve(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_FrameCount)).empty()) Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_FrameCount), Frame_Count); } 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_Size0) 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) { 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; switch (Config_Trace_Format) { case MediaInfo_Config::Trace_Format_XML : break; default : //TODO: find a better way to display jumps, both XML and Text 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 EVENT_BEGIN (General, Move_Request, 0) Event.StreamOffset=File_GoTo; EVENT_END () #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) { 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; } if (File_Size==(int64u)-1) { #if MEDIAINFO_SEEK if ( #if MEDIAINFO_ADVANCED Config->File_IgnoreSequenceFileSize_Get() && #endif //MEDIAINFO_ADVANCED GoToFromEnd) { File_GoTo=Config->File_Names.size()-1; File_Offset=(int64u)-1; Config->File_Current_Offset=(int64u)-1; Config->File_GoTo_IsFrameOffset=true; } else #endif //MEDIAINFO_SEEK ForceFinish(); //We can not jump return; } GoTo(File_Size-GoToFromEnd, ParserName); } #else //MEDIAINFO_TRACE void File__Analyze::GoToFromEnd (int64u GoToFromEnd) { if (GoToFromEnd>File_Size) return; if (File_Size==(int64u)-1) { #if MEDIAINFO_SEEK if (Config->File_IgnoreSequenceFileSize_Get() && GoToFromEnd) { File_GoTo=Config->File_Names.size()-1; File_Offset=(int64u)-1; Config->File_Current_Offset=(int64u)-1; Config->File_GoTo_IsFrameOffset=true; } else #endif //MEDIAINFO_SEEK ForceFinish(); //We can not jump 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_SizeBufferUnderRun) Trusted_IsNot(); #endif //MEDIAINFO_TRACE return !Element[Element_Level].WaitForMoreData && !Element[Element_Level].UnTrusted; } //--------------------------------------------------------------------------- bool File__Analyze::Element_IsNotFinished () { if (BS->Remain()>0 || Element_Offset+BS->Offset_Get()0) Element_End0(); while (Element_Levelclear(); Element[0].ToShow.Details.clear(); Element[0].ToShow.Value.clear(); } #endif //MEDIAINFO_TRACE #if MEDIAINFO_EVENTS void File__Analyze::Event_Prepare(struct MediaInfo_Event_Generic* Event) { memset(Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event->StreamIDs_Size=StreamIDs_Size; memcpy_Unaligned_Unaligned_Once1024(Event->StreamIDs, StreamIDs, 128); memcpy(Event->StreamIDs_Width, StreamIDs_Width, sizeof(StreamIDs_Width)); memcpy(Event->ParserIDs, ParserIDs, sizeof(ParserIDs)); Event->StreamOffset=File_Offset+Buffer_Offset+Element_Offset; Event->FrameNumber=Frame_Count_NotParsedIncluded; Event->PCR=FrameInfo.PCR; Event->DTS=(FrameInfo.DTS==(int64u)-1?FrameInfo.PTS:FrameInfo.DTS); Event->PTS=FrameInfo.PTS; Event->DUR=FrameInfo.DUR; //Event->FrameNumber_PresentationOrder=FrameNumber_PresentationOrder; } #endif //MEDIAINFO_EVENTS //*************************************************************************** // Demux //*************************************************************************** #if MEDIAINFO_DEMUX void File__Analyze::Demux (const int8u* Buffer, size_t Buffer_Size, contenttype Content_Type, const int8u* xx, size_t xxx) { 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; EVENT_BEGIN(Global, Demux, 4) if (StreamIDs_Size) Event.EventCode|=((int32u)ParserIDs[StreamIDs_Size-1]<<24); Event.Content_Type=(int8u)Content_Type; Event.Content_Size=Buffer_Size; Event.Content=Buffer; Event.Flags=0; if (Demux_random_access) Event.Flags|=0x1; //Bit 0 Event.Offsets_Size=Offsets_Buffer.size(); std::vector Offsets_Stream_Temp; std::vector Offsets_Buffer_Temp; float64 Ratio=1; if (OriginalBuffer_Size) Ratio=((float64)File__Analyze::OriginalBuffer_Size)/File__Analyze::Buffer_Size; if (Offsets_Buffer.empty()) { Event.Offsets_Stream=NULL; Event.Offsets_Content=NULL; } else if (Buffer_Offset+Element_Offset) { Offsets_Stream_Temp=Offsets_Stream; Offsets_Buffer_Temp=Offsets_Buffer; size_t Pos=0; if (Offsets_Buffer.size()>=2 && Offsets_Buffer.size()%2==0 && Offsets_Buffer[0]==Offsets_Buffer[1]) { while (Pos+2NextPacket_Get()) Config->Demux_EventWasSent=true; #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET 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 (!IsSub && Buffer_SizeFile_Current_Size-Config->File_Current_Offset) { 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_Current_Size - Config->File_Current_Offset - Buffer_Size); return false; } float64 Demux_Rate=Config->Demux_Rate_Get(); if (!Demux_Rate) Demux_Rate=24; if (Frame_Count_NotParsedIncluded!=(int64u)-1) FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded*1000000000/Demux_Rate); else FrameInfo.DTS=(int64u)-1; FrameInfo.PTS=FrameInfo.DTS; FrameInfo.DUR=float64_int64s(1000000000/Demux_Rate); 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_IBIUSAGE void File__Analyze::Ibi_Read_Buffer_Unsynched () { Ibi_SynchronizationOffset_Current=(int64u)-1; if (IbiStream==NULL) return; IbiStream->Unsynch(); for (size_t Pos=0; PosInfos.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; } } } #if MEDIAINFO_SEEK size_t File__Analyze::Ibi_Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) { if (IbiStream==NULL) return (size_t)-1; //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 : #if MEDIAINFO_IBI { for (size_t Pos=0; PosInfos.size(); Pos++) { if (Value<=IbiStream->Infos[Pos].StreamOffset) { if (ValueInfos[Pos].StreamOffset && Pos) Pos--; //Checking continuity of Ibi if (!IbiStream->Infos[Pos].IsContinuous && Pos+1Infos.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); Open_Buffer_Unsynch(); } else if (!IbiStream->Infos[IbiStream->Infos.size()-1].IsContinuous) { GoTo(IbiStream->Infos[IbiStream->Infos.size()-1].StreamOffset); Open_Buffer_Unsynch(); } else return 2; //Invalid value return 1; } #else //MEDIAINFO_IBI return (size_t)-2; //Not supported / IBI disabled #endif //MEDIAINFO_IBI case 1 : return Ibi_Read_Buffer_Seek(0, File_Size*Value/10000, ID); 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; PosInfos.size(); Pos++) { if (Value<=IbiStream->Infos[Pos].Dts) { if (ValueInfos[Pos].Dts && Pos) Pos--; //Checking continuity of Ibi if (!IbiStream->Infos[Pos].IsContinuous && Pos+1Infos.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); Open_Buffer_Unsynch(); } else if (!IbiStream->Infos[IbiStream->Infos.size()-1].IsContinuous) { GoTo(IbiStream->Infos[IbiStream->Infos.size()-1].StreamOffset); Open_Buffer_Unsynch(); } 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; PosInfos.size(); Pos++) { if (Value<=IbiStream->Infos[Pos].FrameNumber) { if (ValueInfos[Pos].FrameNumber && Pos) Pos--; //Checking continuity of Ibi if (!IbiStream->Infos[Pos].IsContinuous && Pos+1Infos.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); Open_Buffer_Unsynch(); } else if (!IbiStream->Infos[IbiStream->Infos.size()-1].IsContinuous) { GoTo(IbiStream->Infos[IbiStream->Infos.size()-1].StreamOffset); Open_Buffer_Unsynch(); } 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 } } #endif //MEDIAINFO_SEEK #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE void File__Analyze::Ibi_Stream_Finish () { if (IsSub) return; if (!(IbiStream==NULL || IbiStream->Infos.empty()) && 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->DtsFrequencyNumerator/IbiStream->DtsFrequencyDenominator):(int64u)-1; IbiInfo.IsContinuous=true; IbiStream->Add(IbiInfo); } if (Config_Ibi_Create) { if (!(IbiStream==NULL || IbiStream->Infos.empty())) Ibi.Streams[(int64u)-1]=new ibi::stream(*IbiStream); //Inform_Data ZtringListList Content; for (size_t StreamKind=Stream_General; StreamKindDtsFrequencyNumerator==1000000000 && IbiStream->DtsFrequencyDenominator==1 && !IbiStream->Infos.empty()) { IbiStream->DtsFrequencyNumerator=Numerator; IbiStream->DtsFrequencyDenominator=Denominator; for (size_t Pos=0; PosInfos.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_IBCREATION } //NameSpace MediaInfoLib/Source/MediaInfo/MediaInfo_Config_MediaInfo.h0000664000000000000000000005432212652076434022356 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Configuration of MediaInfo (per MediaInfo block) // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo_Config_MediaInfoH #define MediaInfo_Config_MediaInfoH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Internal_Const.h" #include "MediaInfo/HashWrapper.h" //For MEDIAINFO_HASH #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/Translation.h" #include "ZenLib/InfoMap.h" using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { #if MEDIAINFO_EVENTS class File__Analyze; class MediaInfo_Config_PerPackage; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_AES enum encryption_format { Encryption_Format_None, Encryption_Format_Aes, }; enum encryption_method { Encryption_Method_None, Encryption_Method_Segment, }; enum encryption_mode { Encryption_Mode_None, Encryption_Mode_Cbc, }; enum encryption_padding { Encryption_Padding_None, Encryption_Padding_Pkcs7, }; #endif //MEDIAINFO_AES //*************************************************************************** // 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_IsDetectingDuration_Set (bool NewValue); bool File_IsDetectingDuration_Get (); void File_IsReferenced_Set (bool NewValue); bool File_IsReferenced_Get (); void File_TestContinuousFileNames_Set (bool NewValue); bool File_TestContinuousFileNames_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 (); #if MEDIAINFO_ADVANCED void File_IgnoreSequenceFileSize_Set (bool NewValue); bool File_IgnoreSequenceFileSize_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void File_IgnoreSequenceFilesCount_Set (bool NewValue); bool File_IgnoreSequenceFilesCount_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void File_SequenceFilesSkipFrames_Set (int64u NewValue); int64u File_SequenceFilesSkipFrames_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void File_DefaultFrameRate_Set (float64 NewValue); float64 File_DefaultFrameRate_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void File_Source_List_Set (bool NewValue); bool File_Source_List_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_ADVANCED void File_RiskyBitRateEstimation_Set (bool NewValue); bool File_RiskyBitRateEstimation_Get (); void File_MergeBitRateInfo_Set (bool NewValue); bool File_MergeBitRateInfo_Get (); #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED void File_Demux_Unpacketize_StreamLayoutChange_Skip_Set (bool NewValue); bool File_Demux_Unpacketize_StreamLayoutChange_Skip_Get (); #endif //MEDIAINFO_ADVANCED #endif //MEDIAINFO_DEMUX #if MEDIAINFO_HASH void File_Hash_Set (HashWrapper::HashFunctions Funtions); HashWrapper::HashFunctions File_Hash_Get (); #endif //MEDIAINFO_HASH #if MEDIAINFO_MD5 void File_Md5_Set (bool NewValue); bool File_Md5_Get (); #endif //MEDIAINFO_MD5 #if defined(MEDIAINFO_REFERENCES_YES) void File_CheckSideCarFiles_Set (bool NewValue); bool File_CheckSideCarFiles_Get (); #endif //defined(MEDIAINFO_REFERENCES_YES) 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 (); void File_Buffer_Read_Size_Set (size_t NewValue); size_t File_Buffer_Read_Size_Get (); #if MEDIAINFO_AES void Encryption_Format_Set (const Ztring &Value); void Encryption_Format_Set (encryption_format Value); string Encryption_Format_GetS (); encryption_format Encryption_Format_Get (); void Encryption_Key_Set (const Ztring &Value); void Encryption_Key_Set (const int8u* Value, size_t Value_Size); string Encryption_Key_Get (); void Encryption_Method_Set (const Ztring &Value); void Encryption_Method_Set (encryption_method Value); string Encryption_Method_GetS (); encryption_method Encryption_Method_Get (); void Encryption_Mode_Set (const Ztring &Value); void Encryption_Mode_Set (encryption_mode Value); string Encryption_Mode_GetS (); encryption_mode Encryption_Mode_Get (); void Encryption_Padding_Set (const Ztring &Value); void Encryption_Padding_Set (encryption_padding Value); string Encryption_Padding_GetS (); encryption_padding Encryption_Padding_Get (); void Encryption_InitializationVector_Set (const Ztring &Value); string Encryption_InitializationVector_Get (); #endif //MEDIAINFO_AES #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 (); void File_Filter_Audio_Set (bool NewValue); bool File_Filter_Audio_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(File__Analyze* Source, const int8u* Data_Content, size_t Data_Size, const Ztring &File_Name=Ztring()); void Event_Accepted(File__Analyze* Source); void Event_SubFile_Start(const Ztring &FileName_Absolute); #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_PCM_20bitTo24bit_Set (bool NewValue); bool Demux_PCM_20bitTo24bit_Get (); void Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Set (bool NewValue); bool Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get (); void Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Set (bool NewValue); bool Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_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_IBIUSAGE void Ibi_Set (const Ztring &NewValue); std::string Ibi_Get (); void Ibi_UseIbiInfoIfAvailable_Set (bool NewValue); bool Ibi_UseIbiInfoIfAvailable_Get (); #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE void Ibi_Create_Set (bool NewValue); bool Ibi_Create_Get (); #endif //MEDIAINFO_IBIUSAGE //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_Mxf_TimeCodeFromMaterialPackage_Set (bool NewValue); bool File_Mxf_TimeCodeFromMaterialPackage_Get (); void File_Mxf_ParseIndex_Set (bool NewValue); bool File_Mxf_ParseIndex_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 (); #if defined(MEDIAINFO_AC3_YES) void File_Ac3_IgnoreCrc_Set (bool NewValue); bool File_Ac3_IgnoreCrc_Get (); #endif //defined(MEDIAINFO_AC3_YES) //Analysis internal void State_Set (float State); float State_Get (); //Internal to MediaInfo, not thread safe ZtringList File_Names; std::vector 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; bool File_IsImageSequence; #if defined(MEDIAINFO_EIA608_YES) bool File_Scte20_IsPresent; #endif //defined(MEDIAINFO_EIA608_YES) #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) bool File_DtvccTransport_Stream_IsPresent; bool File_DtvccTransport_Descriptor_IsPresent; #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) int64u File_Current_Offset; int64u File_Current_Size; int64u File_IgnoreEditsBefore; int64u File_IgnoreEditsAfter; float64 File_EditRate; int64u File_Size; float32 ParseSpeed; #if MEDIAINFO_EVENTS MediaInfo_Config_PerPackage* Config_PerPackage; Ztring File_Names_RootDirectory; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX bool Demux_EventWasSent; int64u Demux_Offset_Frame; int64u Demux_Offset_DTS; int64u Demux_Offset_DTS_FromStream; File__Analyze* Events_Delayed_CurrentSource; #if MEDIAINFO_SEEK bool Demux_IsSeeking; #endif //MEDIAINFO_SEEK #endif //MEDIAINFO_DEMUX #if MEDIAINFO_SEEK bool File_GoTo_IsFrameOffset; #endif //MEDIAINFO_SEEK private : bool FileIsSeekable; bool FileIsSub; bool FileIsDetectingDuration; bool FileIsReferenced; bool FileTestContinuousFileNames; bool FileKeepInfo; bool FileStopAfterFilled; bool FileStopSubStreamAfterFilled; bool Audio_MergeMonoStreams; bool File_Demux_Interleave; bool File_ID_OnlyRoot; #if MEDIAINFO_ADVANCED bool File_IgnoreSequenceFileSize; bool File_IgnoreSequenceFilesCount; int64u File_SequenceFilesSkipFrames; float64 File_DefaultFrameRate; bool File_Source_List; bool File_RiskyBitRateEstimation; bool File_MergeBitRateInfo; #if MEDIAINFO_DEMUX bool File_Demux_Unpacketize_StreamLayoutChange_Skip; #endif //MEDIAINFO_DEMUX #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_HASH HashWrapper::HashFunctions Hash_Functions; #endif //MEDIAINFO_HASH #if MEDIAINFO_MD5 bool File_Md5; #endif //MEDIAINFO_MD5 #if defined(MEDIAINFO_REFERENCES_YES) bool File_CheckSideCarFiles; #endif //defined(MEDIAINFO_REFERENCES_YES) 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; size_t File_Buffer_Read_Size; //Extra #if MEDIAINFO_AES encryption_format Encryption_Format; string Encryption_Key; encryption_method Encryption_Method; encryption_mode Encryption_Mode; encryption_padding Encryption_Padding; string Encryption_InitializationVector; #endif //MEDIAINFO_AES #if MEDIAINFO_NEXTPACKET bool NextPacket; #endif //MEDIAINFO_NEXTPACKET #if MEDIAINFO_FILTER std::map File_Filter_16; bool File_Filter_Audio; bool File_Filter_HasChanged_; #endif //MEDIAINFO_FILTER #if MEDIAINFO_DUPLICATE std::vector 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) struct event_delayed { int8u* Data_Content; size_t Data_Size; Ztring File_Name; event_delayed (const int8u* Data_Content_, size_t Data_Size_, const Ztring &File_Name_) { File_Name=File_Name_; Data_Size=Data_Size_; Data_Content=new int8u[Data_Size]; std::memcpy(Data_Content, Data_Content_, Data_Size); } ~event_delayed () { delete[] Data_Content; //Data_Content=NULL; } }; typedef std::map > events_delayed; events_delayed Events_Delayed; 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_PCM_20bitTo24bit; bool Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10; bool Demux_Hevc_Transcode_Iso14496_15_to_AnnexB; bool Demux_Unpacketize; float64 Demux_Rate; int64u Demux_FirstDts; int64u Demux_FirstFrameNumber; int8u Demux_InitData; #endif //MEDIAINFO_DEMUX #if MEDIAINFO_IBIUSAGE std::string Ibi; bool Ibi_UseIbiInfoIfAvailable; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE bool Ibi_Create; #endif //MEDIAINFO_IBIUSAGE //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_Mxf_TimeCodeFromMaterialPackage; bool File_Mxf_ParseIndex; 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_ANALYZE_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; #if defined(MEDIAINFO_AC3_YES) bool File_Ac3_IgnoreCrc; #endif //defined(MEDIAINFO_AC3_YES) //Analysis internal float State; //Generic #if defined(MEDIAINFO_LIBCURL_YES) std::map Curl; #endif //defined(MEDIAINFO_LIBCURL_YES) ZenLib::CriticalSection CS; //Constructor MediaInfo_Config_MediaInfo (const MediaInfo_Config_MediaInfo&); // Prevent copy-construction MediaInfo_Config_MediaInfo& operator=(const MediaInfo_Config_MediaInfo&); // Prevent assignment }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File_Dummy.cpp0000664000000000000000000003611712652076434017712 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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://MediaArea.net/MediaInfo"); Stream_Prepare(Stream_Video); Fill(Stream_Video, 0, Video_Codec, "XVID"); Fill(Stream_Video, 0, Video_Codec_Url, "http://MediaArea.net/MediaInfo"); 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://MediaArea.net/MediaInfo"); 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://MediaArea.net/MediaInfo"); Fill(Stream_Text, 0, Text_Language, "en"); Fill(Stream_Text, 0, Text_Language_More, "Forced"); Stream_Prepare(Stream_Other); Fill(Stream_Other, 0, Chapters_Total, "16"); Fill(Stream_Other, 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://MediaArea.net/MediaInfo"); 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_Other); Fill(Stream_Other, 0, Chapters_ID, "ID"); Fill(Stream_Other, 0, Chapters_UniqueID, "UniqueID"); Fill(Stream_Other, 0, Chapters_Title, "Title"); Fill(Stream_Other, 0, Chapters_Total, "Total"); Fill(Stream_Other, 0, Chapters_Language, "de"); } } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File_Other.cpp0000664000000000000000000001737412652076434017704 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // 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) { Element_WaitForMoreData(); return; } Ztring Format; if (Buffer[0]==0xEA && Buffer[1]==0x22 && Buffer[2]<=0x03) { Accept(); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, Text_Format, "Cheetah"); Finish(); return; } if (Buffer[0]==0x4C && Buffer[1]==0x61 && Buffer[2]==0x6D && Buffer[3]==0x62 && Buffer[4]==0x64 && Buffer[5]==0x61) { Accept(); Stream_Prepare(Stream_Text); Fill(Stream_Text, 0, Text_Format, "Lambda"); Finish(); return; } 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)==0x504C5646) {Format=__T("PlayLater Video");} else if (CC4(Buffer)==CC4("")) {Format=__T("");} if (Format.empty()) { Reject(); return; } Accept(); Element_Offset=File_Size-(File_Offset+Buffer_Offset); Fill(Stream_General, 0, General_Format, Format); Finish(); } } //NameSpace #endif //MEDIAINFO_OTHER_YES MediaInfoLib/Source/MediaInfo/MediaInfo.h0000664000000000000000000003755112652076434017163 0ustar rootroot// MediaInfo - All information about media files //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfo_Internal; //*************************************************************************** /// @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) /// @retval 0 File not opened /// @retval 1 File opened 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) /// @retval 0 failed /// @retval 1 succeed 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 /// @param Reserved Reserved, do not use /// @pre You can change default presentation with Inform_Set() /// @return Text with information about the file 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 Pos 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", "Other", "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...) /// @return The count of fields for this stream kind / stream number if stream number is provided, else the count of streams for this stream kind size_t Count_Get (stream_t StreamKind, size_t StreamNumber=(size_t)-1); private : MediaInfo_Internal* Internal; //Constructor MediaInfo (const MediaInfo&); // Prevent copy-construction MediaInfo& operator=(const MediaInfo&); // Prevent assignment }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/File_Other.h0000664000000000000000000000242312652076434017336 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 MediaInfoLib/Source/MediaInfo/File__Base.h0000664000000000000000000001050212652076434017263 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Give common methods for all file types // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef MediaInfo__BaseH #define MediaInfo__BaseH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Config.h" //--------------------------------------------------------------------------- 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 > * Stream_=NULL, std::vector > * Stream_More=NULL); #else //MEDIAINFO_TRACE void Init(MediaInfo_Config_MediaInfo * Config, std::vector > * Stream_=NULL, std::vector > * 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 public : //TODO:put it as private std::vector > * Stream; //pointer to others listed streams std::vector > * 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(); private : //Constructor File__Base (const File__Base&); // Prevent copy-construction File__Base& operator=(const File__Base&); // Prevent assignment public : //A virer friend class File__Analyze; friend class File__MultipleParsing; friend class File__ReferenceFilesHelper; friend class resource; }; } //NameSpace #endif MediaInfoLib/Source/MediaInfo/Setup.h0000664000000000000000000011120412652076434016414 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 #if !defined (MEDIAINFO_READTHREAD_NO) && !defined (MEDIAINFO_READTHREAD_YES) #define MEDIAINFO_READTHREAD_NO #endif #if !defined (MEDIAINFO_MD5_NO) && !defined (MEDIAINFO_MD5_YES) #define MEDIAINFO_MD5_NO #endif #if !defined (MEDIAINFO_SHA1_NO) && !defined (MEDIAINFO_SHA1_YES) #define MEDIAINFO_SHA1_NO #endif #if !defined (MEDIAINFO_SHA2_NO) && !defined (MEDIAINFO_SHA2_YES) #define MEDIAINFO_SHA2_NO #endif #if !defined (MEDIAINFO_AES_NO) && !defined (MEDIAINFO_AES_YES) #define MEDIAINFO_AES_NO #endif #if !defined (MEDIAINFO_EXPORT_NO) && !defined (MEDIAINFO_EXPORT_YES) #define MEDIAINFO_EXPORT_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_AES) #if defined(MEDIAINFO_AES_NO) && defined(MEDIAINFO_AES_YES) #undef MEDIAINFO_AES_NO //MEDIAINFO_AES_YES has priority #endif #if defined(MEDIAINFO_AES_NO) #define MEDIAINFO_AES 0 #else #define MEDIAINFO_AES 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_ADVANCED) #if defined(MEDIAINFO_ADVANCED_NO) && defined(MEDIAINFO_ADVANCED_YES) #undef MEDIAINFO_ADVANCED_NO //MEDIAINFO_ADVANCED_YES has priority #endif #if defined(MEDIAINFO_ADVANCED_NO) #define MEDIAINFO_ADVANCED 0 #else #define MEDIAINFO_ADVANCED 1 #endif #endif #if !defined(MEDIAINFO_ADVANCED2) //ADVANCED2 is for optional build during defualt build #if defined(MEDIAINFO_ADVANCED2_NO) && defined(MEDIAINFO_ADVANCED2_YES) #undef MEDIAINFO_ADVANCED2_NO //MEDIAINFO_ADVANCED2_YES has priority #endif #if defined(MEDIAINFO_ADVANCED2_YES) #define MEDIAINFO_ADVANCED2 1 #else #define MEDIAINFO_ADVANCED2 0 #endif #endif #if !defined(MEDIAINFO_MD5) #if defined(MEDIAINFO_MD5_NO) && defined(MEDIAINFO_MD5_YES) #undef MEDIAINFO_MD5_NO //MEDIAINFO_MD5_YES has priority #endif #if defined(MEDIAINFO_MD5_NO) #define MEDIAINFO_MD5 0 #else #define MEDIAINFO_MD5 1 #endif #endif #if !defined(MEDIAINFO_SHA1) #if defined(MEDIAINFO_SHA1_NO) && defined(MEDIAINFO_SHA1_YES) #undef MEDIAINFO_SHA1_NO //MEDIAINFO_SHA1_YES has priority #endif #if defined(MEDIAINFO_SHA1_NO) #define MEDIAINFO_SHA1 0 #else #define MEDIAINFO_SHA1 1 #endif #endif #if !defined(MEDIAINFO_SHA2) #if defined(MEDIAINFO_SHA2_NO) && defined(MEDIAINFO_SHA2_YES) #undef MEDIAINFO_SHA2_NO //MEDIAINFO_SHA2_YES has priority #endif #if defined(MEDIAINFO_SHA2_NO) #define MEDIAINFO_SHA2 0 #else #define MEDIAINFO_SHA2 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 #if !defined(MEDIAINFO_IBIUSAGE) #if defined(MEDIAINFO_IBIUSAGE_NO) && defined(MEDIAINFO_IBIUSAGE_YES) #undef MEDIAINFO_IBIUSAGE_NO //MEDIAINFO_IBIUSAGE_YES has priority #endif #if defined(MEDIAINFO_IBIUSAGE_NO) #define MEDIAINFO_IBIUSAGE 0 #else #if MEDIAINFO_ADVANCED2 #define MEDIAINFO_IBIUSAGE 1 #else //MEDIAINFO_ADVANCED2 #define MEDIAINFO_IBIUSAGE 0 #endif //MEDIAINFO_ADVANCED2 #endif #endif #if !defined(MEDIAINFO_READTHREAD) #if defined(MEDIAINFO_READTHREAD_NO) && defined(MEDIAINFO_READTHREAD_YES) #undef MEDIAINFO_READTHREAD_NO //MEDIAINFO_READTHREAD_YES has priority #endif #if defined(MEDIAINFO_READTHREAD_NO) || !defined(WINDOWS) //Currently supported only on Windows TODO: add support of non Windows OS #define MEDIAINFO_READTHREAD 0 #else #define MEDIAINFO_READTHREAD 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 //--------------------------------------------------------------------------- // Export #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_TEXT_YES) #define MEDIAINFO_TEXT_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_HTML_NO) && !defined(MEDIAINFO_HTML_YES) #define MEDIAINFO_HTML_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_XML_NO) && !defined(MEDIAINFO_XML_YES) #define MEDIAINFO_XML_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_CSV_NO) && !defined(MEDIAINFO_CSV_YES) #define MEDIAINFO_CSV_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_CUSTOM_NO) && !defined(MEDIAINFO_CUSTOM_YES) #define MEDIAINFO_CUSTOM_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_EBUCORE_NO) && !defined(MEDIAINFO_EBUCORE_YES) #define MEDIAINFO_EBUCORE_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_FIMS_NO) && !defined(MEDIAINFO_FIMS_YES) #define MEDIAINFO_FIMS_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_MPEG7_NO) && !defined(MEDIAINFO_MPEG7_YES) #define MEDIAINFO_MPEG7_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_PBCORE_NO) && !defined(MEDIAINFO_PBCORE_YES) #define MEDIAINFO_PBCORE_YES #endif #if !defined(MEDIAINFO_EXPORT_NO) && !defined(MEDIAINFO_REVTMD_NO) && !defined(MEDIAINFO_REVTMD_YES) #define MEDIAINFO_REVTMD_YES #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_AAF_NO) && !defined(MEDIAINFO_AAF_YES) #define MEDIAINFO_AAF_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_DASHMPD_NO) && !defined(MEDIAINFO_DASHMPD_YES) #define MEDIAINFO_DASHMPD_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_HDSF4M_NO) && !defined(MEDIAINFO_HDSF4M_YES) #define MEDIAINFO_HDSF4M_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_PMP_NO) && !defined(MEDIAINFO_PMP_YES) #define MEDIAINFO_PMP_YES #endif #if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_PTX_NO) && !defined(MEDIAINFO_PTX_YES) #define MEDIAINFO_PTX_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_AIC_NO) && !defined(MEDIAINFO_AIC_YES) #define MEDIAINFO_AIC_YES #endif #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_CANOPUS_NO) && !defined(MEDIAINFO_CANOPUS_YES) #define MEDIAINFO_CANOPUS_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_FFV1_NO) && !defined(MEDIAINFO_FFV1_YES) #define MEDIAINFO_FFV1_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_HEVC_NO) && !defined(MEDIAINFO_HEVC_YES) #define MEDIAINFO_HEVC_YES #endif #if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_HUFFYUV_NO) && !defined(MEDIAINFO_HUFFYUV_YES) #define MEDIAINFO_HUFFYUV_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_PRORES_NO) && !defined(MEDIAINFO_PRORES_YES) #define MEDIAINFO_PRORES_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_TIMECODE_NO) && !defined(MEDIAINFO_TIMECODE_YES) #define MEDIAINFO_TIMECODE_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_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_CAF_NO) && !defined(MEDIAINFO_CAF_YES) #define MEDIAINFO_CAF_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_OPENMG_NO) && !defined(MEDIAINFO_OPENMG_YES) #define MEDIAINFO_OPENMG_YES #endif #if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_OPUS_NO) && !defined(MEDIAINFO_OPUS_YES) #define MEDIAINFO_OPUS_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_PCMM2TS_NO) && !defined(MEDIAINFO_PCMM2TS_YES) #define MEDIAINFO_PCMM2TS_YES #endif #if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_PCMVOB_NO) && !defined(MEDIAINFO_PCMVOB_YES) #define MEDIAINFO_PCMVOB_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_SMPTEST0302_NO) && !defined(MEDIAINFO_SMPTEST0302_YES) #define MEDIAINFO_SMPTEST0302_YES #endif #if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_SMPTEST0331_NO) && !defined(MEDIAINFO_SMPTEST0331_YES) #define MEDIAINFO_SMPTEST0331_YES #endif #if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_SMPTEST0337_NO) && !defined(MEDIAINFO_SMPTEST0337_YES) #define MEDIAINFO_SMPTEST0337_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_ARIBSTDB24B37_NO) && !defined(MEDIAINFO_ARIBSTDB24B37_YES) #define MEDIAINFO_ARIBSTDB24B37_YES #endif #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_PDF_NO) && !defined(MEDIAINFO_PDF_YES) #define MEDIAINFO_PDF_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_SDP_NO) && !defined(MEDIAINFO_SDP_YES) #define MEDIAINFO_SDP_YES #endif #if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_SUBRIP_NO) && !defined(MEDIAINFO_SUBRIP_YES) #define MEDIAINFO_SUBRIP_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_TIMEDTEXT_NO) && !defined(MEDIAINFO_TIMEDTEXT_YES) #define MEDIAINFO_TIMEDTEXT_YES #endif #if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_TTML_NO) && !defined(MEDIAINFO_TTML_YES) #define MEDIAINFO_TTML_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_ARRIRAW_NO) && !defined(MEDIAINFO_ARRIRAW_YES) #define MEDIAINFO_ARRIRAW_YES #endif #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_BPG_NO) && !defined(MEDIAINFO_BPG_YES) #define MEDIAINFO_BPG_YES #endif #if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_DDS_NO) && !defined(MEDIAINFO_DDS_YES) #define MEDIAINFO_DDS_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_PCX_NO) && !defined(MEDIAINFO_PCX_YES) #define MEDIAINFO_PCX_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_PSD_NO) && !defined(MEDIAINFO_PSD_YES) #define MEDIAINFO_PSD_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_PROPERTYLIST_NO) && !defined(MEDIAINFO_PROPERTYLIST_YES) #define MEDIAINFO_PROPERTYLIST_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 MediaInfoLib/Source/MediaInfo/MediaInfoList_Internal.cpp0000664000000000000000000005540712652076434022206 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfoList_Internal.h" #include "MediaInfo/MediaInfo_Config.h" #include "ZenLib/File.h" #include "ZenLib/Dir.h" #include "MediaInfo/Reader/Reader_Directory.h" #include "MediaInfo/File__Analyse_Automatic.h" using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- namespace MediaInfoLib { //--------------------------------------------------------------------------- extern MediaInfo_Config Config; extern const Char* MediaInfo_Version; //--------------------------------------------------------------------------- //*************************************************************************** // 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::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++; //Removing sequences of files from the list if (!MI->Get(Stream_General, 0, General_CompleteName_Last).empty()) { Ztring CompleteName_Begin=MI->Get(Stream_General, 0, General_CompleteName); Ztring CompleteName_Last=MI->Get(Stream_General, 0, General_CompleteName_Last); size_t Pos=0; for (; Pos=CompleteName_Last.size()) break; if (CompleteName_Begin[Pos]!=CompleteName_Last[Pos]) break; } if (PosOpen_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")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T('<'); Result+=__T("MediaArea"); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xmlns=\"https://mediaarea.net/mediaarea\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xsi:schemaLocation=\"https://mediaarea.net/mediaarea https://mediaarea.net/mediaarea/mediaarea_0_1.xsd\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" version=\"0.1\""); Result+=__T(">")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T("")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T("MediaInfoLib"); Result+=MediaInfoLib::Config.LineSeparator_Get(); for (size_t FilePos=0; FilePos")+MediaInfoLib::Config.LineSeparator_Get(); return Result; } if (MediaInfoLib::Config.Trace_Level_Get() && MediaInfoLib::Config.Trace_Format_Get()==MediaInfoLib::Config.Trace_Format_XML) { Ztring Result; Result+=__T("")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T('<'); Result+=__T("MediaTrace"); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xmlns=\"https://mediaarea.net/mediatrace\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xsi:schemaLocation=\"https://mediaarea.net/mediatrace https://mediaarea.net/mediatrace/mediatrace_0_1.xsd\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" version=\"0.1\""); Result+=__T(">")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T("MediaInfoLib"); Result+=MediaInfoLib::Config.LineSeparator_Get(); for (size_t FilePos=0; FilePosGet(Stream_General, 0, General_CompleteName), Modified)+__T("\">"); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=Inform(FilePos); if (!Result.empty() && Result[Result.size()-1]!=__T('\r') && Result[Result.size()-1]!=__T('\n')) Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(""); Result+=MediaInfoLib::Config.LineSeparator_Get(); } if (!Result.empty() && Result[Result.size()-1]!=__T('\r') && Result[Result.size()-1]!=__T('\n')) Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T("")+MediaInfoLib::Config.LineSeparator_Get(); return Result; } if (MediaInfoLib::Config.Inform_Get()==__T("MIXML")) { Ztring Result; Result+=__T("")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T('<'); Result+=__T("MediaInfo"); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xmlns=\"https://mediaarea.net/mediainfo\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" xsi:schemaLocation=\"https://mediaarea.net/mediainfo https://mediaarea.net/mediainfo/mediainfo_2_0.xsd\""); Result+=MediaInfoLib::Config.LineSeparator_Get(); Result+=__T(" version=\"2.0beta1\""); Result+=__T(">")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T("")+MediaInfoLib::Config.LineSeparator_Get(); Result+=__T("MediaInfoLib"); Result+=MediaInfoLib::Config.LineSeparator_Get(); for (size_t FilePos=0; FilePos")+MediaInfoLib::Config.LineSeparator_Get(); return Result; } 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("")+MediaInfoLib::Config.LineSeparator_Get(); Retour+=__T('<'); Retour+=__T("Mediainfo"); Retour+=MediaInfoLib::Config.LineSeparator_Get(); Retour+=__T(" version=\"0.1\""); Retour+=MediaInfoLib::Config.LineSeparator_Get(); size_t Modified; Retour+=__T(" ref=\"")+MediaInfo_Internal::Xml_Content_Escape(Info[FilePos]->Get(Stream_General, 0, General_CompleteName), Modified)+__T("\""); Retour+=__T(">")+MediaInfoLib::Config.LineSeparator_Get(); if (MediaInfoLib::Config.Trace_Format_Get()==MediaInfoLib::Config.Trace_Format_XML) { Retour+=__T(" MediaInfoLib"); Retour+=MediaInfoLib::Config.LineSeparator_Get(); } } else Retour+=MediaInfo_Custom_View("Page_Begin"); while (FilePos")+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; PosOption(__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 MediaInfoLib/Source/Resource/0000775000000000000000000000000012652076434015100 5ustar rootrootMediaInfoLib/Source/Resource/Text/0000775000000000000000000000000012652076434016024 5ustar rootrootMediaInfoLib/Source/Resource/Text/MediaInfo/0000775000000000000000000000000012652076434017657 5ustar rootrootMediaInfoLib/Source/Resource/Text/MediaInfo/Summary.csv0000664000000000000000000000242412652076434022033 0ustar rootrootGeneral;[%Format%][ (%Format_Profile%)][ (%Format_Commercial_IfAny%)]$if(%Format%,$: $)%FileSize/String%[, %Duration/String%] 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%)] Audio;[%Language/String%, ][%BitRate/String%$if(%BitRate_Nominal/String%, \\(%BitRate_Nominal/String%\\)), ][%SamplingRate/String%, ][%BitDepth/String%, ][%Channel(s)_Original/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%)] Text;[%Language/String%, ][%Format%][ (%Format_Commercial_IfAny%)]$if(%MuxingMode%, \\(%MuxingMode%\\)) Image;[%Language/String%, ][%Width%*][%Height%][ (%DisplayAspectRatio/String%)][, %Format%] Chapters;[%Language/String%, ]%Total% chapters[, %Format%][ (%Format_Commercial_IfAny%)] MediaInfoLib/Source/Resource/Text/Enums_.9.txt0000664000000000000000000000003112652076434020154 0ustar rootroot } //NameSpace #endif MediaInfoLib/Source/Resource/Text/Stream/0000775000000000000000000000000012652076434017257 5ustar rootrootMediaInfoLib/Source/Resource/Text/Stream/Menu.csv0000664000000000000000000001374512652076434020712 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;Menu;;N NT;;;Stream type name StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YIY;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YIY;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file Format;;;N YTY;;;Format used Format/Info;;;N NT;;;Info about Format Format/Url;;;N NT;;;Link Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one Format_Version;;;Y NTY;;;Version of this format Format_Profile;;;Y NTY;;;Profile of the Format Format_Compression;;;Y NTY;;;Compression method used;; Format_Settings;;;Y NTY;;;Settings needed for decoder used CodecID;;;Y YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info about this codec CodecID/Hint;;;Y NT;;;A hint/popular name for this codec CodecID/Url;;;N NT;;;A link to more details about this codec ID CodecID_Description;;;Y YT;;;Manual description given by the container Codec;;;N YT;;;Deprecated Codec/String;;;N NT;;;Deprecated Codec/Info;;;N NT;;;Deprecated Codec/Url;;;N NT;;;Deprecated Duration;; ms;N YIY;;;Play time of the stream in ms Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_Start;;;Y YTY;;; Duration_End;;;Y YTY;;; Delay;; ms;N NIY;;;Delay fixed in the stream (relative) IN MS; Delay/String;;;N NT;;;Delay with measurement; Delay/String1;;;N NT;;;Delay with measurement; Delay/String2;;;N NT;;;Delay with measurement; Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM; Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Delay/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example); Delay_DropFrame;;;N NTY;;;Delay drop frame; Delay_Source;;;N NTY;;;Delay source (Container or Stream or empty); List_StreamKind;;;N YTY;;;List of programs available List_StreamPos;;;N YTY;;;List of programs available List;;;N YT;;;List of programs available List/String;;;Y NT;;;List of programs available Title;;;Y YIY;;;Name of this menu Language;;;N YTY;;;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) Language/String;;;Y NT;;;Language (full) Language/String1;;;N NT;;;Language (full);; Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);; Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);; 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);; Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);; ServiceName;;;Y YTY;;;;;Legal ServiceChannel;;;Y YTY;;;;;Legal Service/Url;;;Y YT;;;;;Legal ServiceProvider;;;Y YTY;;;;;Legal ServiceProviderr/Url;;;Y YT;;;;;Legal ServiceType;;;Y YTY;;;;;Legal NetworkName;;;Y YTY;;;;;Legal Original/NetworkName;;;Y YTY;;;;;Legal Countries;;;Y YTY;;;;;Legal TimeZones;;;Y YTY;;;;;Legal LawRating;;;Y YTY;;;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 LawRating_Reason;;;Y YTY;;;Reason for the law rating;;Classification Disabled;;Yes;N YTY;;;Set if that track should not be used Disabled/String;;;Y NT;;;Set if that track should not be used Default;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. Forced;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. AlternateGroup;;Yes;N YTY;;;Number of a group in order to provide versions of the same track AlternateGroup/String;;;Y NT;;;Number of a group in order to provide versions of the same track 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;; Chapters_Pos_End;;;N NI;;;Used by third-party developers to know about the end of the chapters list (this position excluded) MediaInfoLib/Source/Resource/Text/Stream/Generic.csv0000664000000000000000000000464612652076434021362 0ustar rootrootFormat Format/Info Format/Url Format_Commercial Format_Commercial_IfAny Format_Version Format_Profile Format_Compression Format_Settings InternetMediaType CodecID CodecID/Info CodecID/Hint CodecID/Url CodecID_Description Codec Codec/String Codec/Info Codec/Url Codec/CC Duration Duration/String Duration/String1 Duration/String2 Duration/String3 Duration/String4 Duration/String5 Source_Duration Source_Duration/String Source_Duration/String1 Source_Duration/String2 Source_Duration/String3 Source_Duration/String4 Source_Duration/String5 BitRate_Mode BitRate_Mode/String BitRate BitRate/String BitRate_Minimum BitRate_Minimum/String BitRate_Nominal BitRate_Nominal/String BitRate_Maximum BitRate_Maximum/String BitRate_Encoded BitRate_Encoded/String FrameRate; FrameRate/String FrameRate_Num FrameRate_Den FrameCount Source_FrameCount ColorSpace ChromaSubsampling Resolution Resolution/String BitDepth BitDepth/String Compression_Mode Compression_Mode/String Compression_Ratio Delay Delay/String Delay/String1 Delay/String2 Delay/String3 Delay/String4 Delay/String5 Delay_Settings Delay_DropFrame Delay_Source Delay_Source/String Delay_Original Delay_Original/String Delay_Original/String1 Delay_Original/String2 Delay_Original/String3 Delay_Original/String4 Delay_Original/String5 Delay_Original_Settings Delay_Original_DropFrame Delay_Original_Source Video_Delay Video_Delay/String Video_Delay/String1 Video_Delay/String2 Video_Delay/String3 Video_Delay/String4 Video_Delay/String5 StreamSize StreamSize/String StreamSize/String1 StreamSize/String2 StreamSize/String3 StreamSize/String4 StreamSize/String5 StreamSize_Proportion Source_StreamSize Source_StreamSize/String Source_StreamSize/String1 Source_StreamSize/String2 Source_StreamSize/String3 Source_StreamSize/String4 Source_StreamSize/String5 Source_StreamSize_Proportion StreamSize_Encoded StreamSize_Encoded/String StreamSize_Encoded/String1 StreamSize_Encoded/String2 StreamSize_Encoded/String3 StreamSize_Encoded/String4 StreamSize_Encoded/String5 StreamSize_Encoded_Proportion Source_StreamSize_Encoded Source_StreamSize_Encoded/String Source_StreamSize_Encoded/String1 Source_StreamSize_Encoded/String2 Source_StreamSize_Encoded/String3 Source_StreamSize_Encoded/String4 Source_StreamSize_Encoded/String5 Source_StreamSize_Encoded_Proportion Language ServiceName ServiceProvider MediaInfoLib/Source/Resource/Text/Stream/Image.csv0000664000000000000000000002016312652076434021020 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;Image;;N NT;;;Stream type name StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YIY;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YIY;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file Title;;;Y YI;;;Name of the track Format;;;Y YTY;;;Format used Format/Info;;;Y NT;;;Info about Format Format/Url;;;N NT;;;Link Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one Format_Version;;;Y NTY;;;Version of this format Format_Profile;;;Y NTY;;;Profile of the Format Format_Compression;;;N YTY;;;Compression mode of the Format Format_Settings;;;Y NT;;;Settings needed for decoder used Format_Settings_Wrapping;;;Y YTY;;;Wrapping mode (Frame wrapped or Clip wrapped) InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type) CodecID;;;Y YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info about codec ID CodecID/Hint;;;Y NT;;;A hint for this codec ID CodecID/Url;;;N NT;;;A link for more details about this codec ID CodecID_Description;;;Y YT;;;Manual description given by the container Codec;;;N NT;;;Deprecated, do not use in new projects Codec/String;;;N NT;;;Deprecated, do not use in new projects Codec/Family;;;N NT;;;Deprecated, do not use in new projects Codec/Info;;;N NT;;;Deprecated, do not use in new projects Codec/Url;;;N NT;;;Deprecated, do not use in new projects Width;; pixel;N YIY;;;Width (aperture size if present) in pixel Width/String;;;Y NT;;;Width (aperture size if present) with measurement (pixel) Width_Offset;; pixel;N YIY;;;Offset between original width and displayed width (aperture size) in pixel Width_Offset/String;;;N NT;;;Offset between original width and displayed width (aperture size) in pixel Width_Original;; pixel;N YIY;;;Original (in the raw stream) width in pixel Width_Original/String;;;Y NT;;;Original (in the raw stream) width with measurement (pixel) Height;; pixel;N YIY;;;Height (aperture size if present) in pixel Height/String;;;Y NT;;;Height (aperture size if present) with measurement (pixel) Height_Offset;; pixel;N YIY;;;Offset between original height and displayed height (aperture size) in pixel Height_Offset/String;;;N NT;;;Offset between original height and displayed height (aperture size) in pixel Height_Original;; pixel;N YIY;;;Original (in the raw stream) height in pixel Height_Original/String;;;Y NT;;;Original (in the raw stream) height with measurement (pixel) PixelAspectRatio;;;N YFY;;;Pixel Aspect ratio PixelAspectRatio/String;;;N NT;;;Pixel Aspect ratio PixelAspectRatio_Original;;;N YF;;;Original (in the raw stream) Pixel Aspect ratio PixelAspectRatio_Original/String;;;N NT;;;Original (in the raw stream) Pixel Aspect ratio DisplayAspectRatio;;;N YFY;;;Display Aspect ratio DisplayAspectRatio/String;;;Y NT;;;Display Aspect ratio DisplayAspectRatio_Original;;;N YF;;;Original (in the raw stream) Display Aspect ratio DisplayAspectRatio_Original/String;;;Y NT;;;Original (in the raw stream) Display Aspect ratio ColorSpace;;;Y YTY;;; ChromaSubsampling;;;Y YTY;;; Resolution;; bit;N NI;;;Deprecated, do not use in new projects Resolution/String;;;N NT;;;Deprecated, do not use in new projects BitDepth;; bit;N YIY;;; BitDepth/String;;;Y NT;;; Compression_Mode;;;N YTY;;;Compression mode (Lossy or Lossless) Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless) Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;; StreamSize;; byte;N YIY;;;Stream size in bytes StreamSize/String;;;Y NT;;; StreamSize/String1;;;N NT;;; StreamSize/String2;;;N NT;;; StreamSize/String3;;;N NT;;; StreamSize/String4;;;N NT;;; StreamSize/String5;;;N NT;;;With proportion;; StreamSize_Proportion;;;N NT;;;Stream size divided by file size;; StreamSize_Demuxed;; byte;N YIN;;;StreamSize in bytes of hte stream after demux;; StreamSize_Demuxed/String;;;N NT;;;StreamSize_Demuxed in with percentage value;; StreamSize_Demuxed/String1;;;N NT;;;;; StreamSize_Demuxed/String2;;;N NT;;;;; StreamSize_Demuxed/String3;;;N NT;;;;; StreamSize_Demuxed/String4;;;N NT;;;;; StreamSize_Demuxed/String5;;;N NT;;;StreamSize_Demuxed in with percentage value (note: theoritical value, not for real use);; Encoded_Library;;;N YTY;;;Software used to create the file;; Encoded_Library/String;;;Y NT;;;Software used to create the file;; Encoded_Library_Name;;;N NTY;;;Info from the software;; Encoded_Library_Version;;;N NTY;;;Version of software;; Encoded_Library_Date;;;N NTY;;;Release date of software;; Encoded_Library_Settings;;;Y YTY;;;Parameters used by the software;; Language;;;N YTY;;;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);; Language/String;;;Y NT;;;Language (full);; Language/String1;;;N NT;;;Language (full);; Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);; Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);; 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);; Language_More;;;Y YTY;;;More info about Language (e.g. Director's Comment);; Disabled;;Yes;N YTY;;;Set if that track should not be used Disabled/String;;;Y NT;;;Set if that track should not be used Default;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. Forced;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. AlternateGroup;;Yes;N YTY;;;Number of a group in order to provide versions of the same track AlternateGroup/String;;;Y NT;;;Number of a group in order to provide versions of the same track Summary;;;N NTY;;;;; Encoded_Date;;;Y YTY;;;The time that the encoding of this item was completed began.;;Temporal Tagged_Date;;;Y YTY;;;The time that the tags were done for this item.;;Temporal Encryption;;;Y YTY;;;;; colour_description_present;;;N YTY;;;Presence of colour description colour_primaries;;;Y YTY;;;Chromaticity coordinates of the source primaries transfer_characteristics;;;Y YTY;;;Opto-electronic transfer characteristic of the source picture matrix_coefficients;;;Y YTY;;;Matrix coefficients used in deriving luma and chroma signals from the green, blue, and red primaries colour_description_present_Original;;;N YTY;;;Presence of colour description colour_primaries_Original;;;Y YTY;;;Chromaticity coordinates of the source primaries transfer_characteristics_Original;;;Y YTY;;;Opto-electronic transfer characteristic of the source picture matrix_coefficients_Original;;;Y YTY;;;Matrix coefficients used in deriving luma and chroma signals from the green, blue, and red primaries MediaInfoLib/Source/Resource/Text/Stream/General.csv0000664000000000000000000005547012652076434021364 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;General;;N NT;;;Stream type name StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YI;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YI;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file GeneralCount;1;;N NI;;;Number of general streams VideoCount;;;N NI;;;Number of video streams AudioCount;;;N NI;;;Number of audio streams TextCount;;;N NI;;;Number of text streams OtherCount;;;N NI;;;Number of other streams ImageCount;;;N NI;;;Number of image streams MenuCount;;;N NI;;;Number of menu streams Video_Format_List;;;N NT;;;Video Codecs in this file, separated by / Video_Format_WithHint_List;;;N NT;;;Video Codecs in this file with popular name (hint), separated by / Video_Codec_List;;;N NT;;;Deprecated, do not use in new projects Video_Language_List;;;N NT;;;Video languagesin this file, full names, separated by / Audio_Format_List;;;N NT;;;Audio Codecs in this file,separated by / Audio_Format_WithHint_List;;;N NT;;;Audio Codecs in this file with popular name (hint), separated by / Audio_Codec_List;;;N NT;;;Deprecated, do not use in new projects Audio_Language_List;;;N NT;;;Audio languages in this file separated by / Text_Format_List;;;N NT;;;Text Codecs in this file, separated by / Text_Format_WithHint_List;;;N NT;;;Text Codecs in this file with popular name (hint),separated by / Text_Codec_List;;;N NT;;;Deprecated, do not use in new projects Text_Language_List;;;N NT;;;Text languages in this file, separated by / Other_Format_List;;;N NT;;;Other formats in this file, separated by / Other_Format_WithHint_List;;;N NT;;;Other formats in this file with popular name (hint), separated by / Other_Codec_List;;;N NT;;;Deprecated, do not use in new projects Other_Language_List;;;N NT;;;Chapters languages in this file, separated by / Image_Format_List;;;N NT;;;Image Codecs in this file, separated by / Image_Format_WithHint_List;;;N NT;;;Image Codecs in this file with popular name (hint), separated by / Image_Codec_List;;;N NT;;;Deprecated, do not use in new projects Image_Language_List;;;N NT;;;Image languages in this file, separated by / Menu_Format_List;;;N NT;;;Menu Codecsin this file, separated by / Menu_Format_WithHint_List;;;N NT;;;Menu Codecs in this file with popular name (hint),separated by / Menu_Codec_List;;;N NT;;;Deprecated, do not use in new projects Menu_Language_List;;;N NT;;;Menu languages in this file, separated by / CompleteName;;;Y YT;;;Complete name (Folder+Name+Extension) FolderName;;;N NT;;;Folder name only FileName;;;N NT;;;File name only FileExtension;;;N NT;;;File extension only CompleteName_Last;;;Y YTY;;;Complete name (Folder+Name+Extension) of the last file (in the case of a sequence of files) FolderName_Last;;;N NT;;;Folder name only of the last file (in the case of a sequence of files) FileName_Last;;;N NT;;;File name only of the last file (in the case of a sequence of files) FileExtension_Last;;;N NT;;;File extension only of the last file (in the case of a sequence of files) Format;;;Y YTY;;;Format used Format/String;;;N NT;;;Deprecated, do not use in new projects Format/Info;;;Y NT;;;Info about this Format Format/Url;;;N NT;;;Link to a description of this format Format/Extensions;;;N NT;;;Known extensions of this format Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one Format_Version;;;Y YTY;;;Version of this format Format_Profile;;;Y YTY;;;Profile of the Format Format_Compression;;;Y YTY;;;Compression method used;; Format_Settings;;;Y YTY;;;Settings needed for decoder used InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type) CodecID;;;N YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info about this codec CodecID/Hint;;;Y NT;;;A hint/popular name for this codec CodecID/Url;;;N NT;;;A link to more details about this codec ID CodecID_Description;;;Y YT;;;Manual description given by the container CodecID_Version;;;N YT;;;Version of the CodecID CodecID_Compatible;;;N YT;;;Compatible CodecIDs Interleaved;;;N YTY;;;If Audio and video are muxed Codec;;;N NT;;;Deprecated, do not use in new projects Codec/String;;;N NT;;;Deprecated, do not use in new projects Codec/Info;;;N NT;;;Deprecated, do not use in new projects Codec/Url;;;N NT;;;Deprecated, do not use in new projects Codec/Extensions;;;N NT;;;Deprecated, do not use in new projects Codec_Settings;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_Automatic;;;N NT;;;Deprecated, do not use in new projects FileSize;; byte;N YTY;;;File size in bytes FileSize/String;;;Y NT;;;File size (with measure) FileSize/String1;;;N NT;;;File size (with measure, 1 digit mini) FileSize/String2;;;N NT;;;File size (with measure, 2 digit mini) FileSize/String3;;;N NT;;;File size (with measure, 3 digit mini) FileSize/String4;;;N NT;;;File size (with measure, 4 digit mini) Duration;; ms;N YIY;;;Play time of the stream in ms Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_Start;;;Y YTY;;; Duration_End;;;Y YTY;;; OverallBitRate_Mode;;;N YTY;;;Bit rate mode of all streams (VBR, CBR) OverallBitRate_Mode/String;;;Y NT;;;Bit rate mode of all streams (Variable, Constant) OverallBitRate;; bps;N YFY;;;Bit rate of all streams in bps OverallBitRate/String;;;Y NT;;;Bit rate of all streams (with measure) OverallBitRate_Minimum;; bps;N YFY;;;Minimum Bit rate in bps OverallBitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement) OverallBitRate_Nominal;; bps;N YFY;;;Nominal Bit rate in bps OverallBitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement) OverallBitRate_Maximum;; bps;N YFY;;;Maximum Bit rate in bps OverallBitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement) FrameRate;; fps;N YFY;;;Frames per second FrameRate/String;;;N NT;;;Frames per second (with measurement) FrameRate_Num;;;N NFN;;;Frames per second, numerator FrameRate_Den;;;N NFN;;;Frames per second, denominator FrameCount;;;N NIY;;;Frame count (a frame contains a count of samples depends of the format);; Delay;; ms;N YI;;;Delay fixed in the stream (relative) IN MS Delay/String;;;N NT;;;Delay with measurement Delay/String1;;;N NT;;;Delay with measurement Delay/String2;;;N NT;;;Delay with measurement Delay/String3;;;N NT;;;format : HH:MM:SS.MMM Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Delay/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Settings;;;N NTY;;;Delay settings (in case of timecode for example); Delay_DropFrame;;;N NTY;;;Delay drop frame; Delay_Source;;;N NTY;;;Delay source (Container or Stream or empty); Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty); StreamSize;; byte;N YIY;;;Stream size in bytes StreamSize/String;;;N NT;;; StreamSize/String1;;;N NT;;; StreamSize/String2;;;N NT;;; StreamSize/String3;;;N NT;;; StreamSize/String4;;;N NT;;; StreamSize/String5;;;N NT;;;With proportion StreamSize_Proportion;;;N NT;;;Stream size divided by file size StreamSize_Demuxed;; byte;N YIN;;;StreamSize in bytes of hte stream after demux;; StreamSize_Demuxed/String;;;N NT;;;StreamSize_Demuxed in with percentage value;; StreamSize_Demuxed/String1;;;N NT;;;;; StreamSize_Demuxed/String2;;;N NT;;;;; StreamSize_Demuxed/String3;;;N NT;;;;; StreamSize_Demuxed/String4;;;N NT;;;;; StreamSize_Demuxed/String5;;;N NT;;;StreamSize_Demuxed in with percentage value (note: theoritical value, not for real use);; HeaderSize;;;N YIY;;; DataSize;;;N YIY;;; FooterSize;;;N YIY;;; IsStreamable;;;N YTY;;; Album_ReplayGain_Gain;; dB;N YTY;;;The gain to apply to reach 89dB SPL on playback Album_ReplayGain_Gain/String;;;Y YT;;; Album_ReplayGain_Peak;;;Y YTY;;;The maximum absolute peak value of the item;; Encryption;;;Y YT;;;;; Encryption_Format;;;N YTY;;;;; Encryption_Length;;;N YTY;;;;; Encryption_Method;;;N YTY;;;;; Encryption_Mode;;;N YTY;;;;; Encryption_Padding;;;N YTY;;;;; Encryption_InitializationVector;;;N YTY;;;;; Title;;;N NTY;;;(Generic)Title of file;;Title Title_More;;;N NTY;;;(Generic)More info about the title of file;;Title Title/Url;;;N NT;;;(Generic)Url;;Title Domain;;;Y YT;;;Univers movies belong to, e.g. Starwars, Stargate, Buffy, Dragonballs;;Title Collection;;;Y YT;;;Name of the series, e.g. Starwars movies, Stargate SG-1, Stargate Atlantis, Buffy, Angel;;Title Season;;;Y YT;;;Name of the season, e.g. Strawars first Trilogy, Season 1;;Title Season_Position;;;Y YI;;;Number of the Season;;Title Season_Position_Total;;;Y YI;;;Place of the season e.g. 2 of 7;;Title Movie;;;Y YT;;;Name of the movie. Eg : Starwars, a new hope;;Title Movie_More;;;Y YT;;;More infos about the movie;;Title Movie/Country;;;Y YT;;;Country, where the movie was procuced;;Title Movie/Url;;;Y YT;;;Homepage for the movie;;Title Album;;;Y YT;;;Name of an audio-album. Eg : The joshua tree;;Title Album_More;;;Y YT;;;More infos about the album;;Title Album/Sort;;;Y YT;;;;;Title Album/Performer;;;Y YT;;;Album performer/artist of this file;;Entity Album/Performer/Sort;;;Y YT;;;;;Entity Album/Performer/Url;;;Y YT;;;Homepage of the album performer/artist;;Entity Comic;;;Y YT;;;Name of the comic.;;Title Comic_More;;;Y YT;;;;;Title Comic/Position_Total;;;Y YI;;;;;Title Part;;;Y YT;;;Name of the part. e.g. CD1, CD2;;Title Part/Position;;;Y YI;;;Number of the part;;Title Part/Position_Total;;;Y YI;;;Place of the part e.g. 2 of 3;;Title Track;;;Y YT;;;Name of the track. e.g. track1, track 2;;Title Track_More;;;Y YT;;;More infos about the track;;Title Track/Url;;;Y YT;;;Link to a site about this track;;Title Track/Sort;;;Y YT;;;;;Title Track/Position;;;Y YI;;;Number of this track;;Title Track/Position_Total;;;Y YI;;;Place of this track, e.g. 3 of 15;;Title PackageName;;;Y YTY;;;Package name i.e. technical flavor of the content Grouping;;;Y YT;;;iTunes grouping;;Title Chapter;;;Y YT;;;Name of the chapter.;;Title SubTrack;;;Y YT;;;Name of the subtrack.;;Title Original/Album;;;Y YT;;;Original name of album, serie...;;Title Original/Movie;;;Y YT;;;Original name of the movie;;Title Original/Part;;;Y YT;;;Original name of the part in the original support;;Title Original/Track;;;Y YT;;;Original name of the track in the original support;;Title Compilation;;Yes;Y YT;;;iTunes compilation;;Title Compilation/String;;;Y YT;;;iTunes compilation;;Title Performer;;;Y YT;;;Main performer/artist of this file;;Entity Performer/Sort;;;Y YT;;;;;Entity Performer/Url;;;Y YT;;;Homepage of the performer/artist;;Entity Original/Performer;;;Y YT;;;Original artist(s)/performer(s).;;Entity Accompaniment;;;Y YT;;;Band/orchestra/accompaniment/musician.;;Entity Composer;;;Y YT;;;Name of the original composer.;;Entity Composer/Nationality;;;Y YT;;;Nationality of the main composer of the item, mostly for classical music.;;Entity Arranger;;;Y YT;;;The person who arranged the piece. e.g. Ravel.;;Entity Lyricist;;;Y YT;;;The person who wrote the lyrics for a musical item.;;Entity Original/Lyricist;;;Y YT;;;Original lyricist(s)/text writer(s).;;Entity Conductor;;;Y YT;;;The artist(s) who performed the work. In classical music this would be the conductor, orchestra, soloists.;;Entity Director;;;Y YT;;;Name of the director.;;Entity CoDirector;;;Y YT;;;Name of the codirector.;;Entity AssistantDirector;;;Y YT;;;Name of the assistant director.;;Entity DirectorOfPhotography;;;Y YT;;;The name of the director of photography, also known as cinematographer.;;Entity SoundEngineer;;;Y YT;;;The name of the sound engineer or sound recordist.;;Entity ArtDirector;;;Y YT;;;The person who oversees the artists and craftspeople who build the sets.;;Entity ProductionDesigner;;;Y YT;;;The person responsible for designing the Overall visual appearance of a movie.;;Entity Choregrapher;;;Y YT;;;The name of the choregrapher.;;Entity CostumeDesigner;;;Y YT;;;The name of the costume designer.;;Entity Actor;;;Y YT;;;Real name of an actor or actress playing a role in the movie.;;Entity Actor_Character;;;Y YT;;;Name of the character an actor or actress plays in this movie.;;Entity WrittenBy;;;Y YT;;;The author of the story or script.;;Entity ScreenplayBy;;;Y YT;;;The author of the screenplay or scenario (used for movies and TV shows).;;Entity EditedBy;;;Y YT;;;Editors name;;Entity CommissionedBy;;;Y YT;;;name of the person or organization that commissioned the subject of the file;;Entity Producer;;;Y YT;;;Name of the producer of the movie.;;Entity CoProducer;;;Y YT;;;The name of a co-producer.;;Entity ExecutiveProducer;;;Y YT;;;The name of an executive producer.;;Entity MusicBy;;;Y YT;;;Main music-artist for a movie;;Entity DistributedBy;;;Y YT;;;Company the item is mainly distributed by ;;Entity OriginalSourceForm/DistributedBy;;;Y YT;;;Name of the person or organization who supplied the original subject;;Entity MasteredBy;;;Y YT;;;The engineer who mastered the content for a physical medium or for digital distribution.;;Entity EncodedBy;;;Y YT;;;Name of the person or organisation that encoded/ripped the audio file.;;Entity RemixedBy;;;Y YT;;;Name of the artist(s), that interpreted, remixed, or otherwise modified the item.;;Entity ProductionStudio;;;Y YT;;;Main production studio ;;Entity ThanksTo;;;Y YT;;;A very general tag for everyone else that wants to be listed.;;Entity Publisher;;;Y YT;;;Name of the organization publishing the album (i.e. the 'record label') or movie.;;Entity Publisher/URL;;;Y YT;;;Publishers official webpage.;;Entity Label;;;Y YT;;;Brand or trademark associated with the marketing of music recordings and music videos.;;Entity Genre;;;Y YT;;;The main genre of the audio or video. e.g. classical, ambient-house, synthpop, sci-fi, drama, etc.;;Classification Mood;;;Y YT;;;Intended to reflect the mood of the item with a few keywords, e.g. Romantic, Sad, Uplifting, etc.;;Classification ContentType;;;Y YT;;;The type of the item. e.g. Documentary, Feature Film, Cartoon, Music Video, Music, Sound FX, etc.;;Classification Subject;;;Y YT;;;Describes the topic of the file, such as Aerial view of Seattle..;;Classification Description;;;Y YT;;;A short description of the contents, such as Two birds flying.;;Classification Keywords;;;Y YT;;;Keywords to the item separated by a comma, used for searching.;;Classification Summary;;;Y YT;;;A plot outline or a summary of the story.;;Classification Synopsis;;;Y YT;;;A description of the story line of the item.;;Classification Period;;;Y YT;;;Describes the period that the piece is from or about. e.g. Renaissance.;;Classification 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 LawRating_Reason;;;Y YT;;;Reason for the law rating;;Classification ICRA;;;Y YT;;;The ICRA rating. (Previously RSACi);;Classification Released_Date;;;Y YT;;;The date/year that the item was released.;;Temporal Original/Released_Date;;;Y YT;;;The date/year that the item was originaly released.;;Temporal Recorded_Date;;;Y YT;;;The time/date/year that the recording began.;;Temporal Encoded_Date;;;Y YT;;;The time/date/year that the encoding of this item was completed began.;;Temporal Tagged_Date;;;Y YT;;;The time/date/year that the tags were done for this item.;;Temporal Written_Date;;;Y YT;;;The time/date/year that the composition of the music/script began.;;Temporal Mastered_Date;;;Y YT;;;The time/date/year that the item was tranfered to a digitalmedium.;;Temporal File_Created_Date;;;N NT;;;The time that the file was created on the file system;;Temporal 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 File_Modified_Date;;;N NT;;;The time that the file was modified on the file system;;Temporal 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 Recorded_Location;;;Y YT;;;Location where track was recorded. (See COMPOSITION_LOCATION for format);;Spatial 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 Archival_Location;;;Y YT;;;Location, where an item is archived, e.eg. Louvre,Paris,France;;Spatial Encoded_Application;;;N YT;;;Name of the software package used to create the file, such as Microsoft WaveEdit;;Technical Encoded_Application/String;;;Y NT;;;Name of the software package used to create the file, such as Microsoft WaveEdit, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Application_CompanyName;;;N YT;;;Name of the company;;Technical Encoded_Application_Name;;;N YT;;;Name of the product;;Technical Encoded_Application_Version;;;N YT;;;Version of the product;;Technical Encoded_Application_Url;;;N YT;;;Name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical Encoded_Library;;;N YT;;;Software used to create the file;;Technical Encoded_Library/String;;;Y NT;;;Software used to create the file, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Library_CompanyName;;;N YT;;;Name of the company;;Technical Encoded_Library_Name;;;N NT;;;Name of the the encoding-software;;Technical Encoded_Library_Version;;;N NT;;;Version of encoding-software;;Technical Encoded_Library_Date;;;N NT;;;Release date of software;;Technical Encoded_Library_Settings;;;Y YT;;;Parameters used by the software;;Technical Encoded_OperatingSystem;;;N YT;;;Operating System of encoding-software;;Technical Cropped;;;Y YT;;;Describes whether an image has been cropped and, if so, how it was cropped.;;Technical Dimensions;;;Y YT;;;Specifies the size of the original subject of the file. eg 8.5 in h, 11 in w;;Technical DotsPerInch;;;Y YT;;;Stores dots per inch setting of the digitizer used to produce the file;;Technical Lightness;;;Y YT;;;Describes the changes in lightness settings on the digitizer required to produce the file;;Technical OriginalSourceMedium;;;Y YT;;;Original medium of the material, e.g. vinyl, Audio-CD, Super8 or BetaMax;;Technical OriginalSourceForm;;;Y YT;;;Original form of the material, e.g. slide, paper, map;;Technical OriginalSourceForm/NumColors;;;Y YT;;;Number of colors requested when digitizing, e.g. 256 for images or 32 bit RGB for video;;Technical OriginalSourceForm/Name;;;Y YT;;;Name of the product the file was originally intended for;;Technical 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 OriginalSourceForm/Sharpness;;;Y YT;;;Identifies the changes in sharpness for the digitizer requiered to produce the file;;Technical Tagged_Application;;;Y YT;;;Software used to tag this file;;Technical BPM;;;Y YT;;;Average number of beats per minute;;Technical ISRC;;;Y YT;;;International Standard Recording Code, excluding the ISRC prefix and including hyphens.;;Identifier ISBN;;;Y YT;;;International Standard Book Number.;;Identifier BarCode;;;Y YT;;;EAN-13 (13-digit European Article Numbering) or UPC-A (12-digit Universal Product Code) bar code identifier.;;Identifier LCCN;;;Y YT;;;Library of Congress Control Number.;;Identifier CatalogNumber;;;Y YT;;;A label-specific catalogue number used to identify the release. e.g. TIC 01.;;Identifier 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 Owner;;;Y YT;;;Owner of the file;;Legal Copyright;;;Y YT;;;Copyright attribution.;;Legal Copyright/Url;;;Y YT;;;Link to a site with copyright/legal information.;;Legal Producer_Copyright;;;Y YT;;;The copyright information as per the productioncopyright holder.;;Legal TermsOfUse;;;Y YT;;;License information, e.g., All Rights Reserved,Any Use Permitted.;;Legal ServiceName;;;Y YTY;;;;;Legal ServiceChannel;;;Y YTY;;;;;Legal Service/Url;;;Y YT;;;;;Legal ServiceProvider;;;Y YTY;;;;;Legal ServiceProviderr/Url;;;Y YT;;;;;Legal ServiceType;;;Y YTY;;;;;Legal NetworkName;;;Y YTY;;;;;Legal OriginalNetworkName;;;Y YTY;;;;;Legal Country;;;Y YTY;;;;;Legal TimeZone;;;Y YTY;;;;;Legal Cover;;;Y YTY;;;Is there a cover;;Info Cover_Description;;;Y YTY;;;short descriptio, e.g. Earth in space;;Info Cover_Type;;;Y YTY;;;;;Info Cover_Mime;;;Y YTY;;;;;Info Cover_Data;;;N YT;;;Cover, in binary format encoded BASE64;;Info Lyrics;;;Y YT;;;Text of a song;;Info Comment;;;Y YT;;;Any comment related to the content.;;Personal 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 Added_Date;;;Y YT;;;Date/year the item was added to the owners collection;;Personal Played_First_Date;;;Y YT;;;The date, the owner first played an item;;Personal Played_Last_Date;;;Y YT;;;The date, the owner last played an item;;Personal Played_Count;;;Y YI;;;Number of times an item was played;;Personal EPG_Positions_Begin;;;N YI;;;;; EPG_Positions_End;;;N YI;;;;; MediaInfoLib/Source/Resource/Text/Stream/Video.csv0000664000000000000000000006155512652076434021056 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;Video;;N NT;;;Stream type name StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YIY;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YIY;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file Format;;;Y YTY;;;Format used Format/Info;;;Y NT;;;Info about Format Format/Url;;;N NT;;;Link Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one Format_Version;;;Y YTY;;;Version of this format Format_Profile;;;Y YTY;;;Profile of the Format Format_Compression;;;N YTY;;;Compression mode of the Format MultiView_BaseProfile;;;Y YTY;;;Multiview, profile of the base stream MultiView_Count;;;Y YTY;;;Multiview, count of views MultiView_Layout;;;Y YTY;;;Multiview, how views are muxed in the container in case of it is not muxing in the stream Format_Settings;;;N YT;;;Settings needed for decoder used, summary Format_Settings_BVOP;;Yes;N YTY;;;Settings needed for decoder used, detailled Format_Settings_BVOP/String;;;Y NT;;;Settings needed for decoder used, detailled Format_Settings_QPel;;Yes;N YTY;;;Settings needed for decoder used, detailled Format_Settings_QPel/String;;;Y NT;;;Settings needed for decoder used, detailled Format_Settings_GMC;; warppoint;N YIY;;;Settings needed for decoder used, detailled Format_Settings_GMC/String;;;Y NT;;; Format_Settings_Matrix;;;N YTY;;;Settings needed for decoder used, detailled Format_Settings_Matrix/String;;;Y NT;;;Settings needed for decoder used, detailled Format_Settings_Matrix_Data;;;N NTY;;;Matrix, in binary format encoded BASE64. Order = intra, non-intra, gray intra, gray non-intra Format_Settings_CABAC;;Yes;N YTY;;;Settings needed for decoder used, detailled Format_Settings_CABAC/String;;;Y NT;;;Settings needed for decoder used, detailled Format_Settings_RefFrames;; frame;N YIY;;;Settings needed for decoder used, detailled Format_Settings_RefFrames/String;;;Y NT;;;Settings needed for decoder used, detailled Format_Settings_Pulldown;;;Y YTY;;;Settings needed for decoder used, detailled Format_Settings_FrameMode;;;Y YTY;;;Settings needed for decoder used, detailled Format_Settings_GOP;;;Y YTY;;;Settings needed for decoder used, detailled (M=x N=y) Format_Settings_PictureStructure;;;Y YTY;;;Settings needed for decoder used, detailled (Type of frame, and field/frame info) Format_Settings_Wrapping;;;Y YTY;;;Wrapping mode (Frame wrapped or Clip wrapped) InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type) MuxingMode;;;Y YTY;;;How this file is muxed in the container CodecID;;;Y YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info on the codec CodecID/Hint;;;Y NT;;;Hint/popular name for this codec CodecID/Url;;;N NT;;;Homepage for more details about this codec CodecID_Description;;;Y YT;;;Manual description given by the container Codec;;;N NT;;;Deprecated, do not use in new projects Codec/String;;;N NT;;;Deprecated, do not use in new projects Codec/Family;;;N NT;;;Deprecated, do not use in new projects Codec/Info;;;N NT;;;Deprecated, do not use in new projects Codec/Url;;;N NT;;;Deprecated, do not use in new projects Codec/CC;;;N NT;;;Deprecated, do not use in new projects Codec_Profile;;;N NT;;;Deprecated, do not use in new projects Codec_Description;;;N NT;;;Deprecated, do not use in new projects Codec_Settings;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_PacketBitStream;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_BVOP;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_QPel;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_GMC;; warppoint;N NT;;;Deprecated, do not use in new projects Codec_Settings_GMC/String;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_Matrix;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_Matrix_Data;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_CABAC;;;N NT;;;Deprecated, do not use in new projects Codec_Settings_RefFrames;;;N NT;;;Deprecated, do not use in new projects Duration;; ms;N YIY;;;Play time of the stream in ms; Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero; Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero; Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero; Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM; Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_FirstFrame;; ms;N YIY;;;Duration of the first frame if it is longer than others, in ms; 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; 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; 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; Duration_FirstFrame/String3;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM; Duration_FirstFrame/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration_FirstFrame/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_LastFrame;; ms;N YIY;;;Duration of the last frame if it is longer than others, in ms; 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; 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; 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; Duration_LastFrame/String3;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM; Duration_LastFrame/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration_LastFrame/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration;; ms;N YIY;;;Source Play time of the stream, in ms;; Source_Duration/String;;;Y NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;; Source_Duration/String1;;;N NT;;;Source Play time in format : HHh MMmn SSs MMMms, XX omited if zero;; Source_Duration/String2;;;N NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;; Source_Duration/String3;;;N NT;;;Source Play time in format : HH:MM:SS.MMM;; Source_Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration_FirstFrame;; ms;N YIY;;;Source Duration of the first frame if it is longer than others, in ms; 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; 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; 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; Source_Duration_FirstFrame/String3;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM; Source_Duration_FirstFrame/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration_FirstFrame/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration_LastFrame;; ms;N YIY;;;Source Duration of the last frame if it is longer than others, in ms; 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; 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; 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; Source_Duration_LastFrame/String3;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM; Source_Duration_LastFrame/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration_LastFrame/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) BitRate_Mode;;;N YTY;;;Bit rate mode (VBR, CBR); BitRate_Mode/String;;;Y NT;;;Bit rate mode (Variable, Cconstant); BitRate;; bps;N YFY;;;Bit rate in bps; BitRate/String;;;Y NT;;;Bit rate (with measurement); BitRate_Minimum;; bps;N YFY;;;Minimum Bit rate in bps; BitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement) BitRate_Nominal;; bps;N YFY;;;Nominal Bit rate in bps BitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement) BitRate_Maximum;; bps;N YFY;;;Maximum Bit rate in bps BitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement) BitRate_Encoded;; bps;N YFY;;;Encoded (with forced padding) bit rate in bps, if some container padding is present BitRate_Encoded/String;;;Y NT;;;Encoded (with forced padding) bit rate (with measurement), if some container padding is present Width;; pixel;N YIY;;;Width (aperture size if present) in pixel Width/String;;;Y NT;;;Width (aperture size if present) with measurement (pixel) Width_Offset;; pixel;N YIY;;;Offset between original width and displayed width in pixel Width_Offset/String;;;N NT;;;Offset between original width and displayed width in pixel Width_Original;; pixel;N YIY;;;Original (in the raw stream) width in pixel Width_Original/String;;;Y NT;;;Original (in the raw stream) width with measurement (pixel) Width_CleanAperture;; pixel;N YIY;;;Clean Aperture width in pixel Width_CleanAperture/String;;;Y NT;;;Clean Aperture width with measurement (pixel) Height;; pixel;N YIY;;;Height in pixel Height/String;;;Y NT;;;Height with measurement (pixel) Height_Offset;; pixel;N YIY;;;Offset between original height and displayed height in pixel Height_Offset/String;;;N NT;;;Offset between original height and displayed height in pixel Height_Original;; pixel;N YIY;;;Original (in the raw stream) height in pixel Height_Original/String;;;Y NT;;;Original (in the raw stream) height with measurement (pixel) Height_CleanAperture;; pixel;N YI;;;Clean Aperture height in pixel Height_CleanAperture/String;;;Y NT;;;Clean Aperture height with measurement (pixel) Stored_Width;;;N YIY;;;Stored width Stored_Height;;;N YIY;;;Stored height Sampled_Width;;;N YIY;;;Sampled width Sampled_Height;;;N YIY;;;Sampled height PixelAspectRatio;;;N YFY;;;Pixel Aspect ratio PixelAspectRatio/String;;;N NT;;;Pixel Aspect ratio PixelAspectRatio_Original;;;N YF;;;Original (in the raw stream) Pixel Aspect ratio PixelAspectRatio_Original/String;;;N NT;;;Original (in the raw stream) Pixel Aspect ratio PixelAspectRatio_CleanAperture;;;N YF;;;Clean Aperture Pixel Aspect ratio PixelAspectRatio_CleanAperture/String;;;N NT;;;Clean Aperture Pixel Aspect ratio DisplayAspectRatio;;;N YFY;;;Display Aspect ratio DisplayAspectRatio/String;;;Y NT;;;Display Aspect ratio DisplayAspectRatio_Original;;;N YF;;;Original (in the raw stream) Display Aspect ratio DisplayAspectRatio_Original/String;;;Y NT;;;Original (in the raw stream) Display Aspect ratio DisplayAspectRatio_CleanAperture;;;N YF;;;Clean Aperture Display Aspect ratio DisplayAspectRatio_CleanAperture/String;;;Y NT;;;Clean Aperture Display Aspect ratio ActiveFormatDescription;;;N YNY;;;Active Format Description (AFD value) ActiveFormatDescription/String;;;Y NT;;;Active Format Description (text) ActiveFormatDescription_MuxingMode;;;N YT;;;Active Format Description (AFD value) muxing mode (Ancillary or Raw stream) Rotation;;;N YTY;;;Rotation Rotation/String;;;Y NT;;;Rotation (if not horizontal) FrameRate_Mode;;;N YTY;;;Frame rate mode (CFR, VFR) FrameRate_Mode/String;;;Y NT;;;Frame rate mode (Constant, Variable) FrameRate_Mode_Original;;;N YTY;;;Original frame rate mode (CFR, VFR) FrameRate_Mode_Original/String;;;Y NT;;;Original frame rate mode (Constant, Variable) FrameRate;; fps;N YFY;;;Frames per second FrameRate/String;;;Y NT;;;Frames per second (with measurement) FrameRate_Num;;;N NFN;;;Frames per second, numerator FrameRate_Den;;;N NFN;;;Frames per second, denominator FrameRate_Minimum;; fps;N YFY;;;Minimum Frames per second FrameRate_Minimum/String;;;Y NT;;;Minimum Frames per second (with measurement) FrameRate_Nominal;; fps;N YFY;;;Nominal Frames per second FrameRate_Nominal/String;;;Y NT;;;Nominal Frames per second (with measurement) FrameRate_Maximum;; fps;N YFY;;;Maximum Frames per second FrameRate_Maximum/String;;;Y NT;;;Maximum Frames per second (with measurement) FrameRate_Original;; fps;N YFY;;;Original (in the raw stream) frames per second FrameRate_Original/String;;;Y NT;;;Original (in the raw stream) frames per second (with measurement) FrameRate_Original_Num;;;N NFN;;;Frames per second, numerator FrameRate_Original_Den;;;N NFN;;;Frames per second, denominator FrameCount;;;N NIY;;;Number of frames Source_FrameCount;;;N NI;;;Source Number of frames Standard;;;Y NTY;;;NTSC or PAL Resolution;; bit;N NI;;;Deprecated, do not use in new projects Resolution/String;;;N NT;;;Deprecated, do not use in new projects Colorimetry;;;N NT;;;Deprecated, do not use in new projects ColorSpace;;;Y YTY;;; ChromaSubsampling;;;Y YTY;;; BitDepth;; bit;N YIY;;;16/24/32 BitDepth/String;;;Y NT;;;16/24/32 bits ScanType;;;N YTY;;; ScanType/String;;;Y NT;;; ScanType_Original;;;N YT;;; ScanType_Original/String;;;Y NT;;; ScanType_StoreMethod;;;N YT;;;;Separated fields or Interleaved fields ScanType_StoreMethod_FieldsPerBlock;;;N YT;;;;Count of fields per container block ScanType_StoreMethod/String;;;Y NT;;;;Separated fields or Interleaved fields ScanOrder;;;N YTY;;;; ScanOrder/String;;;Y NT;;;; ScanOrder_Stored;;;N YTY;;;;In case the stored order is not same as the display order ScanOrder_Stored/String;;;Y NT;;;;In case the stored order is not same as the display order ScanOrder_StoredDisplayedInverted;;;N NT;;;; ScanOrder_Original;;;N YTY;;;; ScanOrder_Original/String;;;Y NT;;;; Interlacement;;;N NT;;;Deprecated, do not use in new projects; Interlacement/String;;;N NT;;;Deprecated, do not use in new projects; Compression_Mode;;;N YTY;;;Compression mode (Lossy or Lossless) Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless) Compression_Ratio;;;Y YFY;;;Current stream size divided by uncompressed stream size;; Bits-(Pixel*Frame);;;Y NFN;;;bits/(Pixel*Frame) (like Gordian Knot); Delay;; ms;N NIY;;;Delay fixed in the stream (relative) IN MS; Delay/String;;;N NT;;;Delay with measurement; Delay/String1;;;N NT;;;Delay with measurement; Delay/String2;;;N NT;;;Delay with measurement; Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM; Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Delay/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example); Delay_DropFrame;;;N NT;;;Delay drop frame; Delay_Source;;;N NT;;;Delay source (Container or Stream or empty); Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty); Delay_Original;; ms;N NIY;;;Delay fixed in the raw stream (relative) IN MS; Delay_Original/String;;;N NT;;;Delay with measurement; Delay_Original/String1;;;N NT;;;Delay with measurement; Delay_Original/String2;;;N NT;;;Delay with measurement; Delay_Original/String3;;;N NT;;;Delay in format: HH:MM:SS.MMM;; Delay_Original/String4;;;N NT;;;Delay in format: HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available; Delay_Original/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Original_Settings;;;N NT;;;Delay settings (in case of timecode for example);; Delay_Original_DropFrame;;;N NT;;;Delay drop frame info; Delay_Original_Source;;;N NT;;;Delay source (Stream or empty); TimeStamp_FirstFrame;; ms;N YIY;;;TimeStamp fixed in the stream (relative) IN MS; TimeStamp_FirstFrame/String;;;Y NT;;;TimeStamp with measurement; TimeStamp_FirstFrame/String1;;;N NT;;;TimeStamp with measurement; TimeStamp_FirstFrame/String2;;;N NT;;;TimeStamp with measurement; TimeStamp_FirstFrame/String3;;;N NT;;;TimeStamp in format : HH:MM:SS.MMM; TimeStamp_FirstFrame/String4;;;N NT;;;TimeStamp in format: HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available; TimeStamp_FirstFrame/String5;;;N NT;;;TimeStamp in format : HH:MM:SS.mmm (HH:MM:SS:FF) TimeCode_FirstFrame;;;Y YCY;;;Time code in HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available format TimeCode_Settings;;;Y YTY;;;Time code settings TimeCode_Source;;;Y YTY;;;Time code source (Container, Stream, SystemScheme1, SDTI, ANC...) Gop_OpenClosed;; ;N YTY;;;Time code information about Open/Closed Gop_OpenClosed/String;;;Y NT;;;Time code information about Open/Closed Gop_OpenClosed_FirstFrame;; ;N YTY;;;Time code information about Open/Closed of first frame if GOP is Open for the other GOPs Gop_OpenClosed_FirstFrame/String;;;Y NT;;;Time code information about Open/Closed of first frame if GOP is Open for the other GOPs StreamSize;; byte;N YIY;;;Streamsize in bytes;; StreamSize/String;;;Y NT;;;Streamsize in with percentage value;; StreamSize/String1;;;N NT;;;;; StreamSize/String2;;;N NT;;;;; StreamSize/String3;;;N NT;;;;; StreamSize/String4;;;N NT;;;;; StreamSize/String5;;;N NT;;;Streamsize in with percentage value;; StreamSize_Proportion;;;N NT;;;Stream size divided by file size;; StreamSize_Demuxed;; byte;N YIN;;;StreamSize in bytes of hte stream after demux;; StreamSize_Demuxed/String;;;N NT;;;StreamSize_Demuxed in with percentage value;; StreamSize_Demuxed/String1;;;N NT;;;;; StreamSize_Demuxed/String2;;;N NT;;;;; StreamSize_Demuxed/String3;;;N NT;;;;; StreamSize_Demuxed/String4;;;N NT;;;;; StreamSize_Demuxed/String5;;;N NT;;;StreamSize_Demuxed in with percentage value (note: theoritical value, not for real use);; Source_StreamSize;; byte;N YIY;;;Source Streamsize in bytes;; Source_StreamSize/String;;;Y NT;;;Source Streamsize in with percentage value;; Source_StreamSize/String1;;;N NT;;;;; Source_StreamSize/String2;;;N NT;;;;; Source_StreamSize/String3;;;N NT;;;;; Source_StreamSize/String4;;;N NT;;;;; Source_StreamSize/String5;;;N NT;;;Source Streamsize in with percentage value;; Source_StreamSize_Proportion;;;N NT;;;Source Stream size divided by file size;; StreamSize_Encoded;; byte;N YIY;;;Encoded Streamsize in bytes;; StreamSize_Encoded/String;;;Y NT;;;Encoded Streamsize in with percentage value;; StreamSize_Encoded/String1;;;N NT;;;;; StreamSize_Encoded/String2;;;N NT;;;;; StreamSize_Encoded/String3;;;N NT;;;;; StreamSize_Encoded/String4;;;N NT;;;;; StreamSize_Encoded/String5;;;N NT;;;Encoded Streamsize in with percentage value;; StreamSize_Encoded_Proportion;;;N NT;;;Encoded Stream size divided by file size;; Source_StreamSize_Encoded;; byte;N YIY;;;Source Encoded Streamsize in bytes;; Source_StreamSize_Encoded/String;;;Y NT;;;Source Encoded Streamsize in with percentage value;; Source_StreamSize_Encoded/String1;;;N NT;;;;; Source_StreamSize_Encoded/String2;;;N NT;;;;; Source_StreamSize_Encoded/String3;;;N NT;;;;; Source_StreamSize_Encoded/String4;;;N NT;;;;; Source_StreamSize_Encoded/String5;;;N NT;;;Source Encoded Streamsize in with percentage value;; Source_StreamSize_Encoded_Proportion;;;N NT;;;Source Encoded Stream size divided by file size;; Alignment;;;Y NTY;;;How this stream file is aligned in the container;; Alignment/String;;;N YT;;;;; Title;;;Y YIY;;;Name of the track;; Encoded_Application;;;N YTY;;;Name of the software package used to create the file, such as Microsoft WaveEdit;;Technical Encoded_Application/String;;;Y NTY;;;Name of the software package used to create the file, such as Microsoft WaveEdit, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Application_CompanyName;;;N YTY;;;Name of the company;;Technical Encoded_Application_Name;;;N YTY;;;Name of the product;;Technical Encoded_Application_Version;;;N YTY;;;Version of the product;;Technical Encoded_Application_Url;;;N YTY;;;Name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical Encoded_Library;;;N YTY;;;Software used to create the file;;Technical Encoded_Library/String;;;Y NT;;;Software used to create the file, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Library_CompanyName;;;N YTY;;;Name of the company;;Technical Encoded_Library_Name;;;N NTY;;;Name of the the encoding-software;;Technical Encoded_Library_Version;;;N NTY;;;Version of encoding-software;;Technical Encoded_Library_Date;;;N NTY;;;Release date of software;;Technical Encoded_Library_Settings;;;Y YTY;;;Parameters used by the software;;Technical Encoded_OperatingSystem;;;N YTY;;;Operating System of encoding-software;;Technical Language;;;N YTY;;;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);; Language/String;;;Y NT;;;Language (full);; Language/String1;;;N NT;;;Language (full);; Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);; Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);; 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);; Language_More;;;Y YTY;;;More info about Language (e.g. Director's Comment);; Disabled;;Yes;N YTY;;;Set if that track should not be used Disabled/String;;;Y NT;;;Set if that track should not be used Default;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. Forced;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. AlternateGroup;;Yes;N YTY;;;Number of a group in order to provide versions of the same track AlternateGroup/String;;;Y NT;;;Number of a group in order to provide versions of the same track Encoded_Date;;;Y YTY;;;UTC time that the encoding of this item was completed began.;;Temporal Tagged_Date;;;Y YTY;;;UTC time that the tags were done for this item.;;Temporal Encryption;;;Y YTY;;;;; BufferSize;;;N YTY;;;Defines the size of the buffer needed to decode the sequence. colour_range;;;Y YTY;;;Colour range for YUV colour space colour_description_present;;;N YTY;;;Presence of colour description colour_primaries;;;Y YTY;;;Chromaticity coordinates of the source primaries transfer_characteristics;;;Y YTY;;;Opto-electronic transfer characteristic of the source picture matrix_coefficients;;;Y YTY;;;Matrix coefficients used in deriving luma and chroma signals from the green, blue, and red primaries colour_description_present_Original;;;N YTY;;;Presence of colour description colour_primaries_Original;;;Y YTY;;;Chromaticity coordinates of the source primaries transfer_characteristics_Original;;;Y YTY;;;Opto-electronic transfer characteristic of the source picture matrix_coefficients_Original;;;Y YTY;;;Matrix coefficients used in deriving luma and chroma signals from the green, blue, and red primaries MediaInfoLib/Source/Resource/Text/Stream/Other.csv0000664000000000000000000001261012652076434021055 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;Other;;N NT;;;Stream type name StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YIY;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YIY;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file Type;;;Y YTY;;;Type Format;;;Y YTY;;;Format used Format/Info;;;N NT;;;Info about Format Format/Url;;;N NT;;;Link Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one Format_Version;;;Y NTY;;;Version of this format Format_Profile;;;Y NTY;;;Profile of the Format Format_Compression;;;Y NTY;;;Compression method used;; Format_Settings;;;Y NTY;;;Settings needed for decoder used MuxingMode;;;Y YTY;;;How this file is muxed in the container CodecID;;;Y YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info about this codec CodecID/Hint;;;Y NT;;;A hint/popular name for this codec CodecID/Url;;;N NT;;;A link to more details about this codec ID CodecID_Description;;;Y YT;;;Manual description given by the container Duration;; ms;N YIY;;;Play time of the stream in ms Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_Start;;;Y YTY;;; Duration_End;;;Y YTY;;; FrameRate;; fps;N YFY;;;Frames per second FrameRate/String;;;Y NT;;;Frames per second (with measurement) FrameRate_Num;;;N NFN;;;Frames per second, numerator FrameRate_Den;;;N NFN;;;Frames per second, denominator FrameCount;;;N NIY;;;Number of frames TimeStamp_FirstFrame;; ms;N YIY;;;TimeStamp fixed in the stream (relative) IN MS; TimeStamp_FirstFrame/String;;;Y NT;;;TimeStamp with measurement; TimeStamp_FirstFrame/String1;;;N NT;;;TimeStamp with measurement; TimeStamp_FirstFrame/String2;;;N NT;;;TimeStamp with measurement; TimeStamp_FirstFrame/String3;;;N NT;;;TimeStamp in format : HH:MM:SS.MMM; TimeStamp_FirstFrame/String4;;;N NT;;;TimeStamp in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available TimeStamp_FirstFrame/String5;;;N NT;;;TimeStamp in format : HH:MM:SS.mmm (HH:MM:SS:FF) TimeCode_FirstFrame;;;Y YCY;;;Time code in HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available format TimeCode_Settings;;;Y YTY;;;Time code settings TimeCode_Striped;;Yes;N YTY;;;Time code is striped (only 1st time code, no discontinuity) TimeCode_Striped/String;;;Y NT;;;Time code is striped (only 1st time code, no discontinuity) Title;;;Y YIY;;;Name of this menu Language;;;N YTY;;;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) Language/String;;;Y NT;;;Language (full) Language/String1;;;N NT;;;Language (full);; Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);; Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);; 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);; Language_More;;;Y YTY;;;More info about Language (e.g. Director's Comment);; Disabled;;Yes;N YTY;;;Set if that track should not be used Disabled/String;;;Y NT;;;Set if that track should not be used Default;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. Forced;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. AlternateGroup;;Yes;N YTY;;;Number of a group in order to provide versions of the same track AlternateGroup/String;;;Y NT;;;Number of a group in order to provide versions of the same track MediaInfoLib/Source/Resource/Text/Stream/General_Info_About_Levels.csv0000664000000000000000000000052512652076434024772 0ustar rootrootLevel;Generic;Audio;Video;Images;Examples 8;Domain;;;;Starwars, Stargate, U2 7;Collection;;;;Starwars movies, Stargate movie, Stargate SG-1, Stargate Atlantis 6;Season;;;;Strawars first Trilogy, Season 1 5;;Album;Movie;Comic;The joshua tree, Starwars, a new hope 4;Part;;;;CD1, CD2 3;;Track;Chapter;; 2;;Subtrack;Scene;; 1;;;Shot;; MediaInfoLib/Source/Resource/Text/Stream/Audio.csv0000664000000000000000000005124412652076434021043 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;Audio;;N NT;;;Stream type name;; StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YIY;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YIY;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file Format;;;Y YTY;;;Format used;; Format/Info;;;Y NT;;;Info about the format;; Format/Url;;;N NT;;;Homepage of this format;; Format_Commercial;;;N YT;;;Commercial name used by vendor for theses setings or Format field if there is no difference;; Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one;; Format_Version;;;Y YTY;;;Version of this format;; Format_Profile;;;Y YTY;;;Profile of this Format;; Format_Compression;;;Y YTY;;;Compression method used;; Format_Settings;;;N YT;;;Settings needed for decoder used, summary;; Format_Settings_SBR;;Yes;N YTY;;;;; Format_Settings_SBR/String;;;N NT;;;;; Format_Settings_PS;;Yes;N YTY;;;;; Format_Settings_PS/String;;;N NT;;;;; Format_Settings_Mode;;;Y YTY;;;;; Format_Settings_ModeExtension;;;Y YTY;;;;; Format_Settings_Emphasis;;;Y YTY;;;;; Format_Settings_Floor;;;Y YTY;;;;; Format_Settings_Firm;;;Y YTY;;;;; Format_Settings_Endianness;;;Y YTY;;;;; Format_Settings_Sign;;;Y YTY;;;;; Format_Settings_Law;;;Y YTY;;;;; Format_Settings_ITU;;;Y YTY;;;;; Format_Settings_Wrapping;;;Y YTY;;;Wrapping mode (Frame wrapped or Clip wrapped) Matrix_Format;;;Y YIY;;;Matrix format (e.g. DTS Neural);; InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type);; MuxingMode;;;Y YTY;;;How this stream is muxed in the container;; MuxingMode_MoreInfo;;;Y NT;;;More info (text) about the muxing mode;; CodecID;;;Y YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info about codec ID;; CodecID/Hint;;;Y NT;;;Hint/popular name for this codec ID;; CodecID/Url;;;N NT;;;Homepage for more details about this codec ID;; CodecID_Description;;;Y YT;;;Manual description given by the container;; Codec;;;N NT;;;Deprecated, do not use in new projects;; Codec/String;;;N NT;;;Deprecated, do not use in new projects;; Codec/Family;;;N NT;;;Deprecated, do not use in new projects;; Codec/Info;;;N NT;;;Deprecated, do not use in new projects;; Codec/Url;;;N NT;;;Deprecated, do not use in new projects;; Codec/CC;;;N NT;;;Deprecated, do not use in new projects;; Codec_Description;;;N NT;;;Deprecated, do not use in new projects;; Codec_Profile;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_Automatic;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_Floor;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_Firm;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_Endianness;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_Sign;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_Law;;;N NT;;;Deprecated, do not use in new projects;; Codec_Settings_ITU;;;N NT;;;Deprecated, do not use in new projects;; Duration;; ms;N YIY;;;Play time of the stream, in ms;; Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero;; Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero;; Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero;; Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM;; Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_FirstFrame;; ms;N YIY;;;Duration of the first frame if it is longer than others, in ms; 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; 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; 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; Duration_FirstFrame/String3;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM; Duration_FirstFrame/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration_FirstFrame/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_LastFrame;; ms;N YIY;;;Duration of the last frame if it is longer than others, in ms; 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; 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; 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; Duration_LastFrame/String3;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM; Duration_LastFrame/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration_LastFrame/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration;; ms;N YIY;;;Source Play time of the stream, in ms;; Source_Duration/String;;;Y NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;; Source_Duration/String1;;;N NT;;;Source Play time in format : HHh MMmn SSs MMMms, XX omited if zero;; Source_Duration/String2;;;N NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;; Source_Duration/String3;;;N NT;;;Source Play time in format : HH:MM:SS.MMM;; Source_Duration/String4;;;N NT;;;Source Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration/String5;;;N NT;;;Source Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration_FirstFrame;; ms;N YIY;;;Source Duration of the first frame if it is longer than others, in ms; 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; 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; 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; Source_Duration_FirstFrame/String3;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM; Source_Duration_FirstFrame/String4;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration_FirstFrame/String5;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration_LastFrame;; ms;N YIY;;;Source Duration of the last frame if it is longer than others, in ms; 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; 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; 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; Source_Duration_LastFrame/String3;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM; Source_Duration_LastFrame/String4;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration_LastFrame/String5;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.mmm (HH:MM:SS:FF) BitRate_Mode;;;N YTY;;;Bit rate mode (VBR, CBR);; BitRate_Mode/String;;;Y NT;;;Bit rate mode (Constant, Variable);; BitRate;; bps;N YFY;;;Bit rate in bps;; BitRate/String;;;Y NT;;;Bit rate (with measurement);; BitRate_Minimum;; bps;N YFY;;;Minimum Bit rate in bps;; BitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement);; BitRate_Nominal;; bps;N YFY;;;Nominal Bit rate in bps;; BitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement);; BitRate_Maximum;; bps;N YFY;;;Maximum Bit rate in bps;; BitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement);; BitRate_Encoded;; bps;N YFY;;;Encoded (with forced padding) bit rate in bps, if some container padding is present BitRate_Encoded/String;;;Y NT;;;Encoded (with forced padding) bit rate (with measurement), if some container padding is present Channel(s);; channel;N YIY;;;Number of channels;; Channel(s)/String;;;Y NT;;;Number of channels (with measurement);; Channel(s)_Original;; channel;N YI;;;Number of channels;; Channel(s)_Original/String;;;Y NT;;;Number of channels (with measurement);; Matrix_Channel(s);; channel;N YIY;;;Number of channels after matrix decoding;; Matrix_Channel(s)/String;;;Y NT;;;Number of channels after matrix decoding (with measurement);; ChannelPositions;;;Y YTY;;;Position of channels;; ChannelPositions/String2;;;N NT;;;Position of channels (x/y.z format);; Matrix_ChannelPositions;;;Y YTY;;;Position of channels after matrix decoding;; Matrix_ChannelPositions/String2;;;N NT;;;Position of channels after matrix decoding (x/y.z format);; ChannelLayout;;;N YTY;;;Layout of channels (in the stream);; ChannelLayoutID;;;N YT;;;ID of layout of channels (e.g. MXF descriptor channel assignment). Warning, sometimes this is not enough for uniquely identifying a layout (e.g. MXF descriptor channel assignment is SMPTE 377-4). For AC-3, the form is x,y with x=acmod and y=lfeon.;; SamplesPerFrame;;;N YFY;;;Sampling rate;; SamplingRate;; Hz;N YFY;;;Sampling rate;; SamplingRate/String;;;Y NT;;;in KHz;; SamplingCount;;;N NIY;;;Sample count (based on sampling rate);; Source_SamplingCount;;;N NIY;;;Source Sample count (based on sampling rate);; FrameRate;; fps;N YFY;;;Frames per second FrameRate/String;;;Y NT;;;Frames per second (with measurement) FrameRate_Num;;;N NFN;;;Frames per second, numerator FrameRate_Den;;;N NFN;;;Frames per second, denominator FrameCount;;;N NIY;;;Frame count (a frame contains a count of samples depends of the format);; Source_FrameCount;;;N NIY;;;Source Frame count (a frame contains a count of samples depends of the format);; Resolution;; bit;N NI;;;Deprecated, do not use in new projects;; Resolution/String;;;N NT;;;Deprecated, do not use in new projects;; BitDepth;; bit;N YIY;;;Resolution in bits (8, 16, 20, 24). Note: significant bits in case the stored bit depth is different;; BitDepth/String;;;Y NT;;;Resolution in bits (8, 16, 20, 24). Note: significant bits in case the stored bit depth is different;; BitDepth_Detected;; bit;N YIY;;;Detected (during scan of the input by the muxer) resolution in bits;; BitDepth_Detected/String;;;Y NT;;;Detected (during scan of the input by the muxer) resolution in bits;; BitDepth_Stored;; bit;N YIY;;;Stored Resolution in bits (8, 16, 20, 24);; BitDepth_Stored/String;;;Y NT;;;Stored Resolution in bits (8, 16, 20, 24);; Compression_Mode;;;N YTY;;;Compression mode (Lossy or Lossless) Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless) Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;; Delay;; ms;N NIY;;;Delay fixed in the stream (relative) IN MS; Delay/String;;;N NT;;;Delay with measurement; Delay/String1;;;N NT;;;Delay with measurement; Delay/String2;;;N NT;;;Delay with measurement; Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM; Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Delay/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Settings;;;N NTY;;;Delay settings (in case of timecode for example); Delay_DropFrame;;;N NTY;;;Delay drop frame; Delay_Source;;;N NTY;;;Delay source (Container or Stream or empty); Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty); Delay_Original;; ms;N NIY;;;Delay fixed in the raw stream (relative) IN MS; Delay_Original/String;;;N NT;;;Delay with measurement; Delay_Original/String1;;;N NT;;;Delay with measurement; Delay_Original/String2;;;N NT;;;Delay with measurement; Delay_Original/String3;;;N NT;;;Delay in format: HH:MM:SS.MMM;; Delay_Original/String4;;;N NT;;;Delay in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Delay_Original/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Original_Settings;;;N NT;;;Delay settings (in case of timecode for example);; Delay_Original_DropFrame;;;N NTY;;;Delay drop frame info; Delay_Original_Source;;;N NTY;;;Delay source (Stream or empty); Video_Delay;; ms;N NI;;;Delay fixed in the stream (absolute / video) Video_Delay/String;;;Y NT;;; Video_Delay/String1;;;N NT;;; Video_Delay/String2;;;N NT;;; Video_Delay/String3;;;N NT;;; Video_Delay/String4;;;N NT;;; Video_Delay/String5;;;N NT;;; Video0_Delay;; ms;N NI;;;Deprecated, do not use in new projects Video0_Delay/String;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String1;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String2;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String3;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String4;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String5;;;N NT;;;Deprecated, do not use in new projects ReplayGain_Gain;; dB;N YTY;;;The gain to apply to reach 89dB SPL on playback;; ReplayGain_Gain/String;;;Y YT;;;;; ReplayGain_Peak;;;Y YTY;;;The maximum absolute peak value of the item;; StreamSize;; byte;N YIY;;;Streamsize in bytes;; StreamSize/String;;;Y NT;;;Streamsize in with percentage value;; StreamSize/String1;;;N NT;;;;; StreamSize/String2;;;N NT;;;;; StreamSize/String3;;;N NT;;;;; StreamSize/String4;;;N NT;;;;; StreamSize/String5;;;N NT;;;Streamsize in with percentage value;; StreamSize_Proportion;;;N NTY;;;Stream size divided by file size;; StreamSize_Demuxed;; byte;N YIN;;;StreamSize in bytes of hte stream after demux;; StreamSize_Demuxed/String;;;N NT;;;StreamSize_Demuxed in with percentage value;; StreamSize_Demuxed/String1;;;N NT;;;;; StreamSize_Demuxed/String2;;;N NT;;;;; StreamSize_Demuxed/String3;;;N NT;;;;; StreamSize_Demuxed/String4;;;N NT;;;;; StreamSize_Demuxed/String5;;;N NT;;;StreamSize_Demuxed in with percentage value (note: theoritical value, not for real use);; Source_StreamSize;; byte;N YIY;;;Source Streamsize in bytes;; Source_StreamSize/String;;;Y NT;;;Source Streamsize in with percentage value;; Source_StreamSize/String1;;;N NT;;;;; Source_StreamSize/String2;;;N NT;;;;; Source_StreamSize/String3;;;N NT;;;;; Source_StreamSize/String4;;;N NT;;;;; Source_StreamSize/String5;;;N NT;;;Source Streamsize in with percentage value;; Source_StreamSize_Proportion;;;N NTY;;;Source Stream size divided by file size;; StreamSize_Encoded;; byte;N YIY;;;Encoded Streamsize in bytes;; StreamSize_Encoded/String;;;Y NT;;;Encoded Streamsize in with percentage value;; StreamSize_Encoded/String1;;;N NT;;;;; StreamSize_Encoded/String2;;;N NT;;;;; StreamSize_Encoded/String3;;;N NT;;;;; StreamSize_Encoded/String4;;;N NT;;;;; StreamSize_Encoded/String5;;;N NT;;;Encoded Streamsize in with percentage value;; StreamSize_Encoded_Proportion;;;N NT;;;Encoded Stream size divided by file size;; Source_StreamSize_Encoded;; byte;N YIY;;;Source Encoded Streamsize in bytes;; Source_StreamSize_Encoded/String;;;Y NT;;;Source Encoded Streamsize in with percentage value;; Source_StreamSize_Encoded/String1;;;N NT;;;;; Source_StreamSize_Encoded/String2;;;N NT;;;;; Source_StreamSize_Encoded/String3;;;N NT;;;;; Source_StreamSize_Encoded/String4;;;N NT;;;;; Source_StreamSize_Encoded/String5;;;N NT;;;Source Encoded Streamsize in with percentage value;; Source_StreamSize_Encoded_Proportion;;;N NT;;;Source Encoded Stream size divided by file size;; Alignment;;;N YTY;;;How this stream file is aligned in the container;; Alignment/String;;;Y NT;;;Where this stream file is aligned in the container;; Interleave_VideoFrames;;;N YFY;;;Between how many video frames the stream is inserted;; Interleave_Duration;;;N YIY;;;Between how much time (ms) the stream is inserted;; Interleave_Duration/String;;;Y NT;;;Between how much time and video frames the stream is inserted (with measurement);; Interleave_Preload;;;N YIY;;;How much time is buffered before the first video frame;; Interleave_Preload/String;;;Y NT;;;How much time is buffered before the first video frame (with measurement);; Title;;;Y YIY;;;Name of the track;; Encoded_Application;;;N YTY;;;Name of the software package used to create the file, such as Microsoft WaveEdit;;Technical Encoded_Application/String;;;Y NT;;;Name of the software package used to create the file, such as Microsoft WaveEdit, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Application_CompanyName;;;N YTY;;;Name of the company;;Technical Encoded_Application_Name;;;N YTY;;;Name of the product;;Technical Encoded_Application_Version;;;N YTY;;;Version of the product;;Technical Encoded_Application_Url;;;N YT;;;Name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical Encoded_Library;;;N YTY;;;Software used to create the file;;Technical Encoded_Library/String;;;Y NT;;;Software used to create the file, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Library_CompanyName;;;N YTY;;;Name of the company;;Technical Encoded_Library_Name;;;N NTY;;;Name of the the encoding-software;;Technical Encoded_Library_Version;;;N NTY;;;Version of encoding-software;;Technical Encoded_Library_Date;;;N NTY;;;Release date of software;;Technical Encoded_Library_Settings;;;Y YTY;;;Parameters used by the software;;Technical Encoded_OperatingSystem;;;N YTY;;;Operating System of encoding-software;;Technical Language;;;N YTY;;;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);; Language/String;;;Y NT;;;Language (full);; Language/String1;;;N NT;;;Language (full);; Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);; Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);; 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);; Language_More;;;Y YTY;;;More info about Language (e.g. Director's Comment);; Disabled;;Yes;N YTY;;;Set if that track should not be used Disabled/String;;;Y NT;;;Set if that track should not be used Default;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. Forced;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. AlternateGroup;;Yes;N YTY;;;Number of a group in order to provide versions of the same track AlternateGroup/String;;;Y NT;;;Number of a group in order to provide versions of the same track Encoded_Date;;;Y YTY;;;UTC time that the encoding of this item was completed began.;;Temporal Tagged_Date;;;Y YTY;;;UTC time that the tags were done for this item.;;Temporal Encryption;;;Y YTY;;;;; MediaInfoLib/Source/Resource/Text/Stream/Text.csv0000664000000000000000000004266012652076434020730 0ustar rootrootCount;;;N NI;;;Count of objects available in this stream Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished) StreamCount;;;N NI;;;Count of streams of that kind available StreamKind;Text;;N NT;;;Stream type name StreamKind/String;;;N NT;;;Stream type name StreamKindID;;;N NI;;;Number of the stream (base=0) StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1) StreamOrder;;;N YI;;;Stream order in the file, whatever is the kind of stream (base=0) FirstPacketOrder;;;N YI;;;Order of the first fully decodable packet met in the file, whatever is the kind of stream (base=0) Inform;;;N NT;;;Last **Inform** call ID;;;N YIY;;;The ID for this stream in this file ID/String;;;Y NT;;;The ID for this stream in this file OriginalSourceMedium_ID;;;N YIY;;;The ID for this stream in the original medium of the material OriginalSourceMedium_ID/String;;;Y NT;;;The ID for this stream in the original medium of the material UniqueID;;;N YIY;;;The unique ID for this stream, should be copied with stream copy UniqueID/String;;;Y NT;;;The unique ID for this stream, should be copied with stream copy MenuID;;;N YIY;;;The menu ID for this stream in this file MenuID/String;;;Y NT;;;The menu ID for this stream in this file Format;;;Y YTY;;;Format used Format/Info;;;Y NT;;;Info about Format Format/Url;;;N NT;;;Link Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference Format_Commercial_IfAny;;;Y YTY;;;Commercial name used by vendor for theses setings if there is one Format_Version;;;Y NTY;;;Version of this format Format_Profile;;;Y NTY;;;Profile of the Format Format_Compression;;;Y NTY;;;Compression method used;; Format_Settings;;;Y NTY;;;Settings needed for decoder used Format_Settings_Wrapping;;;Y YTY;;;Wrapping mode (Frame wrapped or Clip wrapped) InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type) MuxingMode;;;Y YTY;;;How this stream is muxed in the container MuxingMode_MoreInfo;;;Y NTY;;;More info (text) about the muxing mode CodecID;;;Y YTY;;;Codec ID (found in some containers);; CodecID/String;;;Y NT;;;Codec ID (found in some containers);; CodecID/Info;;;Y NT;;;Info about codec ID CodecID/Hint;;;Y NT;;;A hint for this codec ID CodecID/Url;;;N NT;;;A link for more details about this codec ID CodecID_Description;;;Y YT;;;Manual description given by the container Codec;;;N YT;;;Deprecated Codec/String;;;N NT;;;Deprecated Codec/Info;;;N NT;;;Deprecated Codec/Url;;;N NT;;;Deprecated Codec/CC;;;N NT;;;Deprecated; Duration;; ms;N YIY;;;Play time of the stream, in ms; Duration/String;;;Y NT;;;Play time (formated); Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero; Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero; Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM; Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration/String5;;;N NT;;;Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_FirstFrame;; ms;N YIY;;;Duration of the first frame if it is longer than others, in ms; 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; 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; 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; Duration_FirstFrame/String3;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM; Duration_FirstFrame/String4;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration_FirstFrame/String5;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.mmm (HH:MM:SS:FF) Duration_LastFrame;; ms;N YIY;;;Duration of the last frame if it is longer than others, in ms; 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; 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; 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; Duration_LastFrame/String3;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM; Duration_LastFrame/String4;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Duration_LastFrame/String5;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration;; ms;N YIY;;;Source Play time of the stream, in ms;; Source_Duration/String;;;Y NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;; Source_Duration/String1;;;N NT;;;Source Play time in format : HHh MMmn SSs MMMms, XX omited if zero;; Source_Duration/String2;;;N NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;; Source_Duration/String3;;;N NT;;;Source Play time in format : HH:MM:SS.MMM;; Source_Duration/String4;;;N NT;;;Source Play time in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration/String5;;;N NT;;;Source Play time in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration_FirstFrame;; ms;N YIY;;;Source Duration of the first frame if it is longer than others, in ms; 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; 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; 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; Source_Duration_FirstFrame/String3;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM; Source_Duration_FirstFrame/String4;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration_FirstFrame/String5;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.mmm (HH:MM:SS:FF) Source_Duration_LastFrame;; ms;N YIY;;;Source Duration of the last frame if it is longer than others, in ms; 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; 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; 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; Source_Duration_LastFrame/String3;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM; Source_Duration_LastFrame/String4;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Source_Duration_LastFrame/String5;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.mmm (HH:MM:SS:FF) BitRate_Mode;;;N YTY;;;Bit rate mode (VBR, CBR); BitRate_Mode/String;;;Y NT;;;Bit rate mode (Constant, Variable); BitRate;; bps;N YFY;;;Bit rate in bps; BitRate/String;;;Y NT;;;Bit rate (with measurement); BitRate_Minimum;; bps;N YFY;;;Minimum Bit rate in bps; BitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement); BitRate_Nominal;; bps;N YFY;;;Nominal Bit rate in bps; BitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement); BitRate_Maximum;; bps;N YFY;;;Maximum Bit rate in bps; BitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement) BitRate_Encoded;; bps;N YFY;;;Encoded (with forced padding) bit rate in bps, if some container padding is present BitRate_Encoded/String;;;Y NT;;;Encoded (with forced padding) bit rate (with measurement), if some container padding is present Width;; character;N YIY;;;Width Width/String;;;Y NT;;; Height;; character;N YIY;;;Height Height/String;;;Y NT;;; FrameRate_Mode;;;N YTY;;;Frame rate mode (CFR, VFR) FrameRate_Mode/String;;;N NT;;;Frame rate mode (Constant, Variable) FrameRate;; fps;N YFY;;;Frames per second FrameRate/String;;;N NT;;;Frames per second (with measurement) FrameRate_Num;;;N NFN;;;Frames per second, numerator FrameRate_Den;;;N NFN;;;Frames per second, denominator FrameRate_Minimum;; fps;N YFY;;;Minimum Frames per second FrameRate_Minimum/String;;;N NT;;;Minimum Frames per second (with measurement) FrameRate_Nominal;; fps;N YFY;;;Nominal Frames per second FrameRate_Nominal/String;;;N NT;;;Nominal Frames per second (with measurement) FrameRate_Maximum;; fps;N YFY;;;Maximum Frames per second FrameRate_Maximum/String;;;N NT;;;Maximum Frames per second (with measurement) FrameRate_Original;; fps;N YFY;;;Original (in the raw stream) Frames per second FrameRate_Original/String;;;N NT;;;Original (in the raw stream) Frames per second (with measurement) FrameCount;;;N NIY;;;Number of frames ElementCount;;;Y NIY;;;Number of displayed elements Source_FrameCount;;;N NIY;;;Source Number of frames ColorSpace;;;Y YTY;;; ChromaSubsampling;;;Y YTY;;; Resolution;; bit;N NI;;;Deprecated, do not use in new projects Resolution/String;;;N NT;;;Deprecated, do not use in new projects BitDepth;; bit;N YIY;;; BitDepth/String;;;Y NT;;; Compression_Mode;;;N YTY;;;Compression mode (Lossy or Lossless) Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless) Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;; Delay;; ms;N NIY;;;Delay fixed in the stream (relative) IN MS; Delay/String;;;N NT;;;Delay with measurement; Delay/String1;;;N NT;;;Delay with measurement; Delay/String2;;;N NT;;;Delay with measurement; Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM; Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available Delay/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example); Delay_DropFrame;;;N NTY;;;Delay drop frame; Delay_Source;;;N NTY;;;Delay source (Container or Stream or empty); Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty); Delay_Original;; ms;N NI;;;Delay fixed in the raw stream (relative) IN MS; Delay_Original/String;;;N NT;;;Delay with measurement; Delay_Original/String1;;;N NT;;;Delay with measurement; Delay_Original/String2;;;N NT;;;Delay with measurement; Delay_Original/String3;;;N NT;;;Delay in format: HH:MM:SS.MMM;; Delay_Original/String4;;;N NT;;;Delay in format: HH:MM:SS:FF, last colon replaced by semicolon for drop frame if available; Delay_Original/String5;;;N NT;;;Delay in format : HH:MM:SS.mmm (HH:MM:SS:FF) Delay_Original_Settings;;;N NT;;;Delay settings (in case of timecode for example);; Delay_Original_DropFrame;;;N NT;;;Delay drop frame info; Delay_Original_Source;;;N NTY;;;Delay source (Stream or empty); Video_Delay;; ms;N NI;;;Delay fixed in the stream (absolute / video) Video_Delay/String;;;Y NT;;; Video_Delay/String1;;;N NT;;; Video_Delay/String2;;;N NT;;; Video_Delay/String3;;;N NT;;; Video_Delay/String4;;;N NT;;; Video_Delay/String5;;;N NT;;; Video0_Delay;; ms;N NI;;;Deprecated, do not use in new projects Video0_Delay/String;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String1;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String2;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String3;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String4;;;N NT;;;Deprecated, do not use in new projects Video0_Delay/String5;;;N NT;;;Deprecated, do not use in new projects StreamSize;; byte;N YIY;;;Streamsize in bytes;; StreamSize/String;;;Y NT;;;Streamsize in with percentage value;; StreamSize/String1;;;N NT;;;;; StreamSize/String2;;;N NT;;;;; StreamSize/String3;;;N NT;;;;; StreamSize/String4;;;N NT;;;;; StreamSize/String5;;;N NT;;;Streamsize in with percentage value;; StreamSize_Proportion;;;N NT;;;Stream size divided by file size;; StreamSize_Demuxed;; byte;N YIN;;;StreamSize in bytes of hte stream after demux;; StreamSize_Demuxed/String;;;N NT;;;StreamSize_Demuxed in with percentage value;; StreamSize_Demuxed/String1;;;N NT;;;;; StreamSize_Demuxed/String2;;;N NT;;;;; StreamSize_Demuxed/String3;;;N NT;;;;; StreamSize_Demuxed/String4;;;N NT;;;;; StreamSize_Demuxed/String5;;;N NT;;;StreamSize_Demuxed in with percentage value (note: theoritical value, not for real use);; Source_StreamSize;; byte;N YIY;;;Source Streamsize in bytes;; Source_StreamSize/String;;;Y NT;;;Source Streamsize in with percentage value;; Source_StreamSize/String1;;;N NT;;;;; Source_StreamSize/String2;;;N NT;;;;; Source_StreamSize/String3;;;N NT;;;;; Source_StreamSize/String4;;;N NT;;;;; Source_StreamSize/String5;;;N NT;;;Source Streamsize in with percentage value;; Source_StreamSize_Proportion;;;N NT;;;Source Stream size divided by file size;; StreamSize_Encoded;; byte;N YIY;;;Encoded Streamsize in bytes;; StreamSize_Encoded/String;;;Y NT;;;Encoded Streamsize in with percentage value;; StreamSize_Encoded/String1;;;N NT;;;;; StreamSize_Encoded/String2;;;N NT;;;;; StreamSize_Encoded/String3;;;N NT;;;;; StreamSize_Encoded/String4;;;N NT;;;;; StreamSize_Encoded/String5;;;N NT;;;Encoded Streamsize in with percentage value;; StreamSize_Encoded_Proportion;;;N NT;;;Encoded Stream size divided by file size;; Source_StreamSize_Encoded;; byte;N YI;;;Source Encoded Streamsize in bytes;; Source_StreamSize_Encoded/String;;;Y NT;;;Source Encoded Streamsize in with percentage value;; Source_StreamSize_Encoded/String1;;;N NT;;;;; Source_StreamSize_Encoded/String2;;;N NT;;;;; Source_StreamSize_Encoded/String3;;;N NT;;;;; Source_StreamSize_Encoded/String4;;;N NT;;;;; Source_StreamSize_Encoded/String5;;;N NT;;;Source Encoded Streamsize in with percentage value;; Source_StreamSize_Encoded_Proportion;;;N NT;;;Source Encoded Stream size divided by file size;; Title;;;Y YIY;;;Name of the track Encoded_Application;;;N YT;;;Name of the software package used to create the file, such as Microsoft WaveEdit;;Technical Encoded_Application/String;;;Y NT;;;Name of the software package used to create the file, such as Microsoft WaveEdit, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Application_CompanyName;;;N YTY;;;Name of the company;;Technical Encoded_Application_Name;;;N YTY;;;Name of the product;;Technical Encoded_Application_Version;;;N YTY;;;Version of the product;;Technical Encoded_Application_Url;;;N YTY;;;Name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical Encoded_Library;;;N YT;;;Software used to create the file;;Technical Encoded_Library/String;;;Y NT;;;Software used to create the file, trying to have the format 'CompanyName ProductName (OperatingSystem) Version (Date)';;Technical Encoded_Library_CompanyName;;;N YTY;;;Name of the company;;Technical Encoded_Library_Name;;;N NTY;;;Name of the the encoding-software;;Technical Encoded_Library_Version;;;N NTY;;;Version of encoding-software;;Technical Encoded_Library_Date;;;N NTY;;;Release date of software;;Technical Encoded_Library_Settings;;;Y YTY;;;Parameters used by the software;;Technical Encoded_OperatingSystem;;;N YTY;;;Operating System of encoding-software;;Technical Language;;;N YTY;;;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) Language/String;;;Y NT;;;Language (full) Language/String1;;;N NT;;;Language (full) Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty) Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);; 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);; Language_More;;;Y YTY;;;More info about Language (e.g. Director's Comment);; Disabled;;Yes;N YTY;;;Set if that track should not be used Disabled/String;;;Y NT;;;Set if that track should not be used Default;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. Forced;;Yes;N YTY;;;Set if that track should be used if no language found matches the user preference. Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference. AlternateGroup;;Yes;N YTY;;;Number of a group in order to provide versions of the same track AlternateGroup/String;;;Y NT;;;Number of a group in order to provide versions of the same track Summary;;;N NTY;;;;; Encoded_Date;;;Y YTY;;;The time that the encoding of this item was completed began.;;Temporal Tagged_Date;;;Y YTY;;;The time that the tags were done for this item.;;Temporal Encryption;;;Y YTY;;;;; MediaInfoLib/Source/Resource/Text/Language/0000775000000000000000000000000012652076434017547 5ustar rootrootMediaInfoLib/Source/Resource/Text/Language/DefaultLanguage.csv0000664000000000000000000007377012652076434023332 0ustar rootroot Language_ISO639;en Author_Email;Info@MediaArea.net Author_Name;Zen Author_OldNames;Initial translator Language_Name;English Config_Text_ColumnSize;40 Config_Text_Separator; : Config_Text_NumberTag; # Config_Text_FloatSeparator;. Config_Text_ThousandsSeparator; audio stream1; audio stream audio stream2; audio streams audio stream3; audio streams bit1; bit bit2; bits bit3; bits bps; bps Bps; Bps Byte1; Byte Byte2; Bytes Byte3; Bytes channel1; channel channel2; channels channel3; channels chapter1; chapter chapter2; chapters chapter3; chapters chapters stream1; chapters stream chapters stream2; chapters streams chapters stream3; chapters streams character1; character character2; characters character3; characters day1; day day2; days day3; days dB1; dB dB2; dB dB3; dB file1; file file2; files file3; files fps1; fps fps2; fps fps3; fps frame1; frame frame2; frames frame3; frames GB; GB Gb; Gb Gbps; Gbps GBps; GBps GHz; GHz GiB; GiB GibiByte1; GibiBytes GibiByte2; GibiBytes GibiByte3; GibiBytes GiBps; GiBps GigaBit1; GigaBit GigaBit2; GigaBits GigaBit3; GigaBits GigaByte1; GigaByte GigaByte2; GigaBytes GigaByte3; GigaBytes hour1; hour hour2; hours hour3; hours Hz; Hz image stream1; image stream image stream2; image streams image stream3; image streams KB; KB Kb; Kb KBps; KBps Kbps; Kbps KHz; KHz KiB; KiB KibiBit1; KibiBit KibiBit2; KibiBits KibiBit3; KibiBits KibiByte1; KibiByte KibiByte2; KibiBytes KibiByte3; KibiBytes KiBps; KiBps KiloBit1; KiloBit KiloBit2; KiloBits KiloBit3; KiloBits KiloByte1; KiloByte KiloByte2; KiloBytes KiloByte3; KiloBytes MB; MB Mb; Mb Mbps; Mbps MBps; MebiBytes MebiBit1; MebiBit MebiBit2; MebiBits MebiBit3; MebiBits MebiByte1; MebiByte MebiByte2; MebiBytes MebiByte3; MebiBytes MegaBit1; MegaBit MegaBit2; MegaBits MegaBit3; MegaBits MegaByte1; MegaByte MegaByte2; MegaBytes MegaByte3; MegaBytes MHz; MHz MiB; MiB Mib; Mib MiBps; MiBps millisecond1; millisecond millisecond2; milliseconds millisecond3; milliseconds minute1; minute minute2; minutes minute3; minutes month1; month month2; months month3; months pixel1; pixel pixel2; pixels pixel3; pixels second1; second second2; seconds second3; seconds text stream1; text stream text stream2; text streams text stream3; text streams video frames1; video frame video frames2; video frames video frames3; video frames video stream1; video stream video stream2; video streams video stream3; video streams warppoint0;No warppoints warppoint1; warppoint warppoint2; warppoints warppoint3; warppoints week1; week week2; weeks week3; weeks year1; year year2; years year3; years , ;, : ;: 3D;3D 3DType;3D Type About;About About_Hint;How to contact me and find last version Accompaniment;Accompaniment ActiveFormatDescription;Active Format Description ActiveFormatDescription_MuxingMode;Active Format Description, Muxing mode Actor;Actor Actor_Character;Character played Added_Date;Added date Address;Address Advanced;Advanced Advanced mode;Advanced mode Album;Album Album_ReplayGain_Gain;Album replay gain Album_ReplayGain_Peak;Album replay gain peak Alignment;Alignment Alignment_Aligned;Aligned on interleaves Alignment_Split;Split accross interleaves All;All All;All AlternateGroup;Alternate group Archival_Location;Archival location Arranger;Arranger ArtDirector;ArtDirector AspectRatio;Aspect ratio AssistantDirector;AssistantDirector at;at At least one file;(You must at least open one file) Audio;Audio Audio stream(s);Audio streams Audio_Codec_List;Audio codecs Audio_No;No audio Audio1;First audio stream Audio2;Second audio stream AudioComments;Audio Comments AudioCount;Count of audio streams AudioDescriptionPresent;Audio Description Present AudioDescriptionType;Audio Description Type AudioLoudnessStandard;Audio Loudness Standard AudioTrackLayout;Audio Track Layout Author;Author BarCode;BarCode Basic;Basic Basic_Note;Note : for more information about this file, you must select a different view (Sheet, Tree...) BitDepth;Bit depth BitDepth_Detected;Detected bit depth BitDepth_Stored;Stored bit depth BitRate;Bit rate BitRate_Encoded;Encoded bit rate BitRate_Maximum;Maximum bit rate BitRate_Minimum;Minimum bit rate BitRate_Mode;Bit rate mode BitRate_Mode_CBR;Constant BitRate_Mode_VBR;Variable BitRate_Nominal;Nominal bit rate Bits-(Pixel*Frame);Bits/(Pixel*Frame) BufferSize;Buffer size Cancel;Cancel Channel(s);Channel(s) ChannelPositions;Channel positions Chapter(s);Chapter(s) Chapters;Chapters Chapters stream(s);Chapters stream(s) Chapters_Codec_List;Chapters Codecs Chapters_No;No chapters ChaptersCount;Count of chapter streams CheckNewVersion;Check for new version Choose custom;Choose custom Choose custom sheet;Choose your desired custom sheet Choose custom text;Choose your desired custom text Choose export format;Choose your desired export format Choose file(s);Choose the files to open Choose filename;Choose your desired filename Choose language;Choose your desired language Choregrapher;Choregrapher Chroma;Chroma ChromaSubsampling;Chroma subsampling Close;Close Close all before open;Close all before open ClosedCaptionsLanguage;Closed Captions Language ClosedCaptionsPresent;Closed Captions Present ClosedCaptionsType;Closed Captions Type Codec;Codec Codec_Description;Codec description Codec_Info;Details for codec Codec_Profile;Codec profile Codec_Settings;Codec settings Codec_Settings_BVOP;Codec settings, BVOP Codec_Settings_CABAC;Codec settings, CABAC Codec_Settings_Endianness;Codec settings, Endianness Codec_Settings_Firm;Codec settings, Firm Codec_Settings_Floor;Codec settings, Floor Codec_Settings_GMC;Codec settings, GMC Codec_Settings_ITU;Codec settings, ITU Codec_Settings_Law;Codec settings, Law Codec_Settings_Matrix;Codec settings, Matrix Codec_Settings_PacketBitStream;Codec settings, Packet bitstream Codec_Settings_QPel;Codec settings, QPel Codec_Settings_Sign;Codec settings, Sign Codec_Url;Weblink for codec CodecID;Codec ID CodecID_Description;Description of the codec CoDirector;Codirector Collection;Collection Colorimetry;Colorimetry ColorSpace;Color space colour_primaries;Color primaries colour_range;Color range Comment;Comment CommissionedBy;Commissioned by Compilation;Compilation CompleteName;Complete name CompletionDate;Completion Date Composer;Composer Compression_Mode;Compression mode Compression_Mode_Lossless;Lossless Compression_Mode_Lossy;Lossy Compression_Ratio;Compression ratio Conductor;Conductor ContactEmail;Contact Email ContactTelephoneNumber;Contact Telephone Number Container and general information;Container and general information ContentType;ContentType CoProducer;Coproducer Copyright;Copyright CopyrightYear;Copyright Year CostumeDesigner;Costume designer Count;Count Country;Country Cover;Cover Cover_Datas;Cover datas Cover_Description;Cover description Cover_Mime;Cover MIME Cover_Type;Cover type Cropped;Crop dimensions Custom;Custom Customize;Customize Date;Date Debug;Debug Decimal point;Decimal point Delay;Delay Delay_Source;Delay, origin Delay_Source_Container;Container Delay_Source_Stream;Raw stream Delete;Delete Description;Description Digitized_Date;Digitized date Dimensions;Dimensions Director;Director DirectorOfPhotography;Director of photography Disabled;Disabled DisplayAspectRatio;Display aspect ratio DisplayAspectRatio_CleanAperture;Clean aperture display aspect ratio DisplayAspectRatio_Original;Original display aspect ratio DistributedBy;Distributed by Distributor;Distributor Donate;Donate DotsPerInch;Dots per inch Duration;Duration Duration_End;End time Duration_Start;Start time Edit;Edit EditedBy;Edited by ElementCount;Count of elements EMail;E-Mail Encoded_Application;Writing application Encoded_Date;Encoded date Encoded_Library;Writing library Encoded_Library_Settings;Encoding settings Encoded_Original;Original support EncodedBy;Encoded by EPG_Positions;EPG positions (internal) EpisodeTitleNumber;Episode Title Number Error_File;Error while reading file ExecutiveProducer;Executive producer Exit;Exit Exit_Hint;Quit the program Export;Export Export_Hint;Export in a customized format Extensions;Extensions usually used Family;Family Fax;Fax File;File File size;File size File_Append;Append to the existing file (Warning : be careful to have the same parameters) File_Created_Date;File creation date File_Created_Date_Local;File creation date (local) File_Hint;Select a multimedia file to examine File_Modified_Date;File last modification date File_Modified_Date_Local;File last modification date (local) FileExtension;File extension FileName;File name FileSize;File size Folder;Folder Folder (R);Folder (R) Folder (R)_Hint;Select a folder to examine (with all folders recursively) Folder (Recursively);Folder (Recursively) Folder_Hint;Select a folder to examine FolderName;Folder name Format;Format Format_Commercial;Commercial name Format_Commercial_IfAny;Commercial name Format_Description;Format description Format_Info;Details for format Format_Profile;Format profile Format_Settings;Format settings Format_Settings_BVOP;Format settings, BVOP Format_Settings_CABAC;Format settings, CABAC Format_Settings_Emphasis;Emphasis Format_Settings_Endianness;Format settings, Endianness Format_Settings_Firm;Format settings, Firm Format_Settings_Floor;Format settings, Floor Format_Settings_FrameMode;Frame mode Format_Settings_GMC;Format settings, GMC Format_Settings_GOP;Format settings, GOP Format_Settings_ITU;Format settings, ITU Format_Settings_Law;Format settings, Law Format_Settings_Matrix;Format settings, Matrix Format_Settings_Matrix_Custom;Custom Format_Settings_Matrix_Default;Default Format_Settings_Mode;Mode Format_Settings_ModeExtension;Mode extension Format_Settings_PacketBitStream;Format settings, Packet bitstream Format_Settings_PictureStructure;Format settings, picture structure Format_Settings_PS;Format settings, PS Format_Settings_Pulldown;Format settings, Pulldown Format_Settings_QPel;Format settings, QPel Format_Settings_RefFrames;Format settings, ReFrames Format_Settings_SBR;Format settings, SBR Format_Settings_Sign;Format settings, Sign Format_Settings_Wrapping;Format settings, wrapping mode Format_Url;Weblink for format Format_Version;Format version FpaManufacturer;FPA Manufacturer FpaPass;FPA Pass FpaVersion;FPA Version FrameCount;Frame count FrameRate;Frame rate FrameRate_Maximum;Maximum frame rate FrameRate_Minimum;Minimum frame rate FrameRate_Mode;Frame rate mode FrameRate_Mode_CFR;Constant FrameRate_Mode_VFR;Variable FrameRate_Nominal;Nominal frame rate FrameRate_Original;Original frame rate General;General Genre;Genre Genre_000;Blues Genre_001;Classic Rock Genre_002;Country Genre_003;Dance Genre_004;Disco Genre_005;Funk Genre_006;Grunge Genre_007;Hip-Hop Genre_008;Jazz Genre_009;Metal Genre_010;New Age Genre_011;Oldies Genre_012;Other Genre_013;Pop Genre_014;R&B Genre_015;Rap Genre_016;Reggae Genre_017;Rock Genre_018;Techno Genre_019;Industrial Genre_020;Alternative Genre_021;Ska Genre_022;Death Metal Genre_023;Pranks Genre_024;Soundtrack Genre_025;Euro-Techno Genre_026;Ambient Genre_027;Trip-Hop Genre_028;Vocal Genre_029;Jazz+Funk Genre_030;Fusion Genre_031;Trance Genre_032;Classical Genre_033;Instrumental Genre_034;Acid Genre_035;House Genre_036;Game Genre_037;Sound Clip Genre_038;Gospel Genre_039;Noise Genre_040;Alt. Rock Genre_041;Bass Genre_042;Soul Genre_043;Punk Genre_044;Space Genre_045;Meditative Genre_046;Instrumental Pop Genre_047;Instrumental Rock Genre_048;Ethnic Genre_049;Gothic Genre_050;Darkwave Genre_051;Techno-Industrial Genre_052;Electronic Genre_053;Pop-Folk Genre_054;Eurodance Genre_055;Dream Genre_056;Southern Rock Genre_057;Comedy Genre_058;Cult Genre_059;Gangsta Rap Genre_060;Top 40 Genre_061;Christian Rap Genre_062;Pop/Funk Genre_063;Jungle Genre_064;Native American Genre_065;Cabaret Genre_066;New Wave Genre_067;Psychedelic Genre_068;Rave Genre_069;Showtunes Genre_070;Trailer Genre_071;Lo-Fi Genre_072;Tribal Genre_073;Acid Punk Genre_074;Acid Jazz Genre_075;Polka Genre_076;Retro Genre_077;Musical Genre_078;Rock & Roll Genre_079;Hard Rock Genre_080;Folk Genre_081;Folk-Rock Genre_082;National Folk Genre_083;Swing Genre_084;Fast-Fusion Genre_085;Bebop Genre_086;Latin Genre_087;Revival Genre_088;Celtic Genre_089;Bluegrass Genre_090;Avantgarde Genre_091;Gothic Rock Genre_092;Progressive Rock Genre_093;Psychedelic Rock Genre_094;Symphonic Rock Genre_095;Slow Rock Genre_096;Big Band Genre_097;Chorus Genre_098;Easy Listening Genre_099;Acoustic Genre_100;Humour Genre_101;Speech Genre_102;Chanson Genre_103;Opera Genre_104;Chamber Music Genre_105;Sonata Genre_106;Symphony Genre_107;Booty Bass Genre_108;Primus Genre_109;Porn Groove Genre_110;Satire Genre_111;Slow Jam Genre_112;Club Genre_113;Tango Genre_114;Samba Genre_115;Folklore Genre_116;Ballad Genre_117;Power Ballad Genre_118;Rhythmic Soul Genre_119;Freestyle Genre_120;Duet Genre_121;Punk Rock Genre_122;Drum Solo Genre_123;A Cappella Genre_124;Euro-House Genre_125;Dance Hall Genre_126;Goa Genre_127;Drum & Bass Genre_128;Club-House Genre_129;Hardcore Genre_130;Terror Genre_131;Indie Genre_132;BritPop Genre_133;Afro-Punk Genre_134;Polsk Punk Genre_135;Beat Genre_136;Christian Gangsta Rap Genre_137;Heavy Metal Genre_138;Black Metal Genre_139;Crossover Genre_140;Contemporary Christian Genre_141;Christian Rock Genre_142;Merengue Genre_143;Salsa Genre_144;Thrash Metal Genre_145;Anime Genre_146;JPop Genre_147;Synthpop Genre_148;Abstract Genre_149;Art Rock Genre_150;Baroque Genre_151;Bhangra Genre_152;Big Beat Genre_153;Breakbeat Genre_154;Chillout Genre_155;Downtempo Genre_156;Dub Genre_157;EBM Genre_158;Eclectic Genre_159;Electro Genre_160;Electroclash Genre_161;Emo Genre_162;Experimental Genre_163;Garage Genre_164;Global Genre_165;IDM Genre_166;Illbient Genre_167;Industro-Goth Genre_168;Jam Band Genre_169;Krautrock Genre_170;Leftfield Genre_171;Lounge Genre_172;Math Rock Genre_173;New Romantic Genre_174;Nu-Breakz Genre_175;Post-Punk Genre_176;Post-Rock Genre_177;Psytrance Genre_178;Shoegaze Genre_179;Space Rock Genre_180;Trop Rock Genre_181;World Music Genre_182;Neoclassical Genre_183;Audiobook Genre_184;Audio Theatre Genre_185;Neue Deutsche Welle Genre_186;Podcast Genre_187;Indie Rock Genre_188;G-Funk Genre_189;Dubstep Genre_190;Garage Rock Genre_191;Psybient Go to WebSite;Go to website Gop_OpenClosed;GOP, Open/Closed Gop_OpenClosed_Open;Open Gop_OpenClosed_Closed;Closed Gop_OpenClosed_FirstFrame;GOP, Open/Closed of first frame Grouping;Grouping h;h Header file;Create a header file Height;Height Height_CleanAperture;Clean aperture height Height_Original;Original height Help;Help Hint;Hint How many audio streams?;How many audio streams? How many chapters streams?;How many chapters streams? How many text streams?;How many text streams? How many video streams?;How many video streams? HTML;HTML ID;ID IdentClockStart;Ident Clock Start Image;Image Image stream(s);Image streams Image_Codec_List;Codecs Image ImageCount;Count of image streams Info;Info Instruments;Instruments Interlaced_BFF;Bottom Field First Interlaced_Interlaced;Interlaced Interlaced_PPF;Progressive Interlaced_Progressive;Progressive Interlaced_TFF;Top Field First Interlacement;Interlacement Interleave_Duration;Interleave, duration Interleave_Preload;Interleave, preload duration Interleave_VideoFrames;Interleave, duration Interleaved;Interleaved InternetMediaType;Internet media type IRCA;IRCA ISBN;ISBN ISRC;ISRC Keywords;Keywords Known codecs;Known codecs Known formats;Known formats Known parameters;Known parameters Label;Label Language;Language Language_aa;Afar Language_ab;Abkhazian Language_ae;Avestan Language_af;Afrikaans Language_ak;Akan Language_am;Amharic Language_an;Aragonese Language_ar;Arabic Language_as;Assamese Language_av;Avaric Language_ay;Aymara Language_az;Azerbaijani Language_ba;Bashkir Language_be;Belarusian Language_bg;Bulgarian Language_bh;Bihari Language_bi;Bislama Language_bm;Bambara Language_bn;Bengali Language_bo;Tibetan Language_br;Breton Language_bs;Bosnian Language_ca;Catalan Language_ce;Chechen Language_ch;Chamorro Language_co;Corsican Language_cr;Cree Language_cs;Czech Language_cu;Slave Language_cv;Chuvash Language_cy;Welsh Language_da;Danish Language_de;German Language_dv;Divehi Language_dz;Dzongkha Language_ee;Ewe Language_el;Greek Language_en;English Language_en-gb;English (Great Britain) Language_en-us;English (United States) Language_eo;Esperanto Language_es;Spanish Language_et;Estonian Language_eu;Basque Language_fa;Persian Language_ff;Fulah Language_fi;Finnish Language_fj;Fijian Language_fo;Faroese Language_fr;French Language_fy;Frisian Language_ga;Irish Language_gd;Gaelic Language_gl;Galician Language_gn;Guarani Language_gu;Gujarati Language_gv;Manx Language_ha;Hausa Language_he;Hebrew Language_hi;Hindi Language_ho;Hiri Motu Language_hr;Croatian Language_ht;Haitian Language_hu;Hungarian Language_hy;Armenian Language_hz;Herero Language_ia;Auxiliary Language Association Language_id;Indonesian Language_ie;Interlingue Language_ig;Igbo Language_ii;Sichuan Yi Language_ik;Inupiaq Language_Info;Language info Language_io;Ido Language_is;Icelandic Language_it;Italian Language_iu;Inuktitut Language_ja;Japanese Language_jv;Javanese Language_ka;Georgian Language_kg;Kongo Language_ki;Kikuyu Language_kj;Kuanyama Language_kk;Kazakh Language_kl;Kalaallisut Language_km;Khmer Language_kn;Kannada Language_ko;Korean Language_kr;Kanuri Language_ks;Kashmiri Language_ku;Kurdish Language_kv;Komi Language_kw;Cornish Language_ky;Kirghiz Language_la;Latin Language_lb;Luxembourgish Language_lg;Ganda Language_li;Limburgish Language_ln;Lingala Language_lo;Lao Language_lt;Lithuanian Language_lu;Luba-Katanga Language_lv;Latvian Language_mg;Malagasy Language_mh;Marshallese Language_mi;Maori Language_mk;Macedonian Language_ml;Malayalam Language_mn;Mongolian Language_mo;Moldavian Language_More;Language, more info Language_mr;Marathi Language_ms;Malay Language_mt;Maltese Language_mul;Multiple languages Language_my;Burmese Language_na;Nauru Language_nb;Norwegian Bokmal Language_nd;Ndebele Language_ne;Nepali Language_ng;Ndonga Language_nl;Dutch Language_nn;Norwegian Nynorsk Language_no;Norwegian Language_nr;Ndebele Language_nv;Navaho Language_ny;Nyanja Language_oc;Occitan Language_oj;Ojibwa Language_om;Oromo Language_or;Oriya Language_os;Ossetic Language_pa;Panjabi Language_pi;Pali Language_pl;Polish Language_ps;Pushto Language_pt;Portuguese Language_pt-br;Portuguese (Brazil) Language_qu;Quechua Language_rm;Raeto-Romance Language_rn;Rundi Language_ro;Romanian Language_ru;Russian Language_rw;Kinyarwanda Language_sa;Sanskrit Language_sc;Sardinian Language_sd;Sindhi Language_se;Northern Sami Language_sg;Sango Language_si;Sinhala Language_sk;Slovak Language_sl;Slovenian Language_sm;Samoan Language_sn;Shona Language_so;Somali Language_sq;Albanian Language_sr;Serbian Language_ss;Swati Language_st;Sotho Language_su;Sundanese Language_sv;Swedish Language_sw;Swahili Language_ta;Tamil Language_te;Telugu Language_tg;Tajik Language_th;Thai Language_ti;Tigrinya Language_tk;Turkmen Language_tl;Tagalog Language_tn;Tswana Language_to;Tonga Language_tr;Turkish Language_ts;Tsonga Language_tt;Tatar Language_tw;Twi Language_ty;Tahitian Language_ug;Uighur Language_uk;Ukrainian Language_ur;Urdu Language_uz;Uzbek Language_ve;Venda Language_vi;Vietnamese Language_vo;Volapuk Language_wa;Walloon Language_wo;Wolof Language_xh;Xhosa Language_yi;Yiddish Language_yo;Yoruba Language_za;Zhuang Language_zh;Chinese Language_zh-cn;Chinese (China) Language_zh-tw;Chinese (Taiwan) Language_zu;Zulu LawRating;Law rating LCCN;LCCN Library;Muxing library Lightness;Lightness LineUpStart;Line Up Start List;List Lyricist;Lyricist Lyrics;Lyrics Mastered_Date;Mastered date MasteredBy;Mastered by Matrix_Channel(s);Matrix encoding, Channel(s) Matrix_ChannelPositions;Matrix encoding, channel positions matrix_coefficients;Matrix coefficients Matrix_Format;Matrix encoding, format MediaInfo_About;MediaInfo provides easy access to technical and tag information about video and audio files.\r\nExcept the Mac App Store graphical user interface, it is open-source software, which means that it is free of charge to the end user and developers have freedom to study, to improve and to redistribute the program (BSD license) Menu;Menu Menu stream(s);Menu streams Menu_Codec_List;Menu codecs Menu_Hint;More possibilities Menu_No;No menu MenuCount;Count of menu streams MenuID;Menu ID mn;mn Mood;Mood More;More Movie;Movie name ms;ms MSDI;MSDI MusicBy;Music by MuxingMode;Muxing mode MuxingMode_MoreInfo;Muxing mode, more info MuxingMode_PackedBitstream;Packed bitstream Name;Name Nationality;Nationality NetworkName;Network name New;New Newest version;Check for new versions (requires Internet connection) NewVersion_Menu;A new version is available NewVersion_Question_Content;A new version (v%Version%) is available, would you like to download it? NewVersion_Question_Title;A new version was released! No;No Not yet;Not yet NumColors;Number of colors OK;OK One output file per input file;One output file per input file Open;Open OpenCandy_01;Downloading ________ OpenCandy_02;__% Complete OpenCandy_03;Internet connection interrupted OpenCandy_04;________ download complete OpenCandy_05;Click to install ________ 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. OpenCandy_07;Download of ________ has been paused.\r\nClick on the tray icon to resume downloading. OpenCandy_08;A critical error has occurred. Installation of _________ will be aborted. OpenCandy_09;Pause download OpenCandy_10;Cancel install OpenCandy_11;Resume download OpenCandy_12;Exit Installer OpenCandy_13;___________ - Recommended by ____________ OpenCandy_14;Downloading _________ 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. OpenCandy_16;___________ is ready for installation OpenCandy_17;___________ is now fully downloaded. Please click on 'Install' to proceed. OpenCandy_18;___________ of ___________ downloaded OpenCandy_19;Powered by OpenCandy OpenCandy_20;Learn more at OpenCandy.com OpenCandy_21;Install OpenCandy_22;Installation of ___________ OpenCandy_23;This will cancel the installation of ___________\r\nAre you sure you wish to exit? OpenCandy_24;Pause OpenCandy_25;Your download has been paused. Click 'Resume' when you are ready to continue. OpenCandy_26;Resume OpenCandy_27;Install Now OpenCandy_28;Pause Download OpenCandy_29;Resume Download OpenCandy_30;Cancel Install OpenCandy_31;Please choose an installation option OpenCandy_32;Install ___________ OpenCandy_33;Don't Install OpenCandy_34;Please select an install option OpenCandy_35;______ recommends this software OpenCandy_36;Your current installation will not be interrupted OpenCaptionsLanguage;Open Captions Language OpenCaptionsPresent;Open Captions Present OpenCaptionsType;Open Captions Type Options;Options Options_Hint;Preferences Original;Original OriginalNetworkName;Original network name OriginalSourceForm;Original source form OriginalSourceMedium;Original source medium OriginalSourceMedium_ID;ID in the original source medium Originator;Originator Other;Other OtherIdentifier;Other Identifier OtherIdentifierType;Other Identifier Type Output;Output Output format;Output format OverallBitRate;Overall bit rate OverallBitRate_Maximum;Maximum Overall bit rate OverallBitRate_Minimum;Minimum Overall bit rate OverallBitRate_Mode;Overall bit rate mode OverallBitRate_Nominal;Nominal Overall bit rate PackageName;Package name Part;Part Part_Count;Total count PartNumber;Part Number PartTotal;Part Total Performer;Performer Period;Period Phone;Phone PictureRatio;Picture Ratio PixelAspectRatio;Pixel aspect ratio PixelAspectRatio_CleanAperture;Clean aperture pixel aspect ratio PixelAspectRatio_Original;Original pixel aspect ratio PlayCounter;PlayCounter Played_Count;Times played Played_First_Date;First played Played_Last_Date;Last played PlayTime;PlayTime Position;Position Position_Total;Total Preferences;Preferences PrimaryAudioLanguage;Primary Audio Language Producer;Producer ProductionDesigner;Production designer ProductionNumber;Production Number ProductionStudio;Production studio ProductPlacement;Product Placement ProgrammeHasText;Programme Has Text ProgrammeTextLanguage;Programme Text Language ProgrammeTitle;Programme Title Publisher;Publisher Purchased_Date;purchased date Quote character;Quote character RadioStation;Radio station Rating;Rating Recorded_Date;Recorded date Recorded_Location;Recorded location Released_Date;Released date RemixedBy;Remixed by ReplayGain_Gain;Replay gain ReplayGain_Peak;Replay gain peak Resolution;Resolution s;s SamplesPerFrame;Samples per frame SamplingCount;Samples count SamplingRate;Sampling rate Save;Save ScanOrder;Scan order ScanOrder_Original;Original scan order ScanOrder_Stored;Stored scan order ScanOrder_StoredDisplayedInverted;Scan order, stored/displayed order inverted ScanOrder_StoreMethod;Scan order, store method ScanType;Scan type ScanType_Original;Original scan type ScanType_StoreMethod;Scan type, store method ScreenplayBy;Screenplay by Season;Season SecondaryAudioLanguage;Secondary Audio Language see below;see below Send HeaderFile;Please send me the Header file here : http://sourceforge.net/projects/mediainfo/ (Bug section) Separator_Columns;columns separator Separator_Lines;lines separator SeriesTitle;Series Title ServiceChannel;Service channel number ServiceName;Service name ServiceProvider;Service provider ServiceType;Service type Set;Set Set_Count;Set count Setup;Setup Sharpness;Sharpness Sheet;Sheet Sheet (Complete);Sheet (Complete) Shell extension;Explorer extension (in Windows Explorer, right click on a file, there will be a MediaInfo option) Shell extension, folder;For folders too Shell InfoTip;Explorer Tooltip (in Windows Explorer, move the mouse over the file, info will be displayed) ShimName;Shim Name ShimVersion;Shim Version Show menu;Show menu Show toolbar;Show toolbar SigningPresent;Signing Present SignLanguage;Sign Language Sort;Sorted by SoundEngineer;Sound engineer Source;Source Source_Duration;Source duration Source_FrameCount;Source frame count Source_SamplingCount;Source sample count Source_StreamSize;Source stream size Source_StreamSize_Encoded;Source encoded stream size Standard;Standard StoreMethod_InterleavedFields;Interleaved fields StoreMethod_SeparatedFields;Separated fields StoreMethod_SeparatedFields_1;Separated fields (1 field per block) StoreMethod_SeparatedFields_2;Separated fields (2 fields per block) Stream;Stream Stream_MoreInfo;More information about the stream StreamCount;Count of stream of this kind StreamID;Stream ID StreamKind;Kind of stream StreamKindID;Stream identifier StreamKindPos;Stream identifier StreamSize;Stream size StreamSize_Demuxed;Stream size when demuxed StreamSize_Encoded;Encoded stream size StreamSize_Proportion;Proportion of this stream Subject;Subject SubTrack;SubTrack Summary;Summary Supported formats;Supported formats Supported?;Supported? Synopsis;Synopsis SystemId;Id Tagged_Application;Tagging application Tagged_Date;Tagged date Technician;Technician TermsOfUse;Terms of use TertiaryAudioLanguage;Tertiary Audio Language Text;Text Text - Custom;Text - Custom Text (HTML);Text (HTML) Text stream(s);Text streams Text streams;Text streams Text_Codec_List;Text codecs Text_No;No text Text1;First text stream Text2;Second text stream Text3;Third text stream TextCount;Count of text streams TextlessElementsExist;Textless Elements Exist ThanksTo;Thanks to Thousands separator;Thousands separator TimeCode;Time code TimeCode_FirstFrame;Time code of first frame TimeCode_Settings;Time code settings TimeCode_Source;Time code source TimeCode_Striped;Time code, striped TimeStamp;Time stamp TimeZone;Timezone Title;Title Title_More;Title, more info Total;Total TotalNumberOfParts;Total Number Of Parts TotalProgrammeDuration;Total Programme Duration Track;Track name Track_Count;Track count transfer_characteristics;Transfer characteristics Translator;Translator Tree;Tree Tree & Text;Tree & Text Type;Type UniqueID;Unique ID Unknown;Unknown Url;Url Video;Video Video stream(s);Video stream(s) Video_Codec_List;Codecs Video Video_Delay;Delay relative to video Video_No;No video Video0_Delay;Video0 delay Video1;First video stream VideoComments;Video Comments VideoCount;Count of video streams View;View View_Hint;Change the means of viewing information Warning : more streams in the files;Warning : there are more streams in the files Web;Web WebSite_Audio;Go to the web site of this audio codec WebSite_Audio_More;Go to the web site (%Url%) to find this audio codec WebSite_General;Go to the web site of a player for this file WebSite_General_More;Go to the web site of a player for this file WebSite_Text;Go to the web site of this text codec WebSite_Text_More;Go to the web site (%Url%) to find this text codec WebSite_Url;http://MediaArea.net/MediaInfo WebSite_Video;Go to the web site of this video codec WebSite_Video_More;Go to the web site (%Url%) to find this video codec Width;Width Width_CleanAperture;Clean aperture width Width_Original;Original width WriteMe;Write mail to author WriteToTranslator;Write to translator Written_Date;Written date Written_Location;Written location WrittenBy;Written by Yes;Yes Your system;Your system ZZ_Automatic_Percent;100 ZZ_AutomaticLanguage_Percent;100MediaInfoLib/Source/Resource/Text/_.5.txt0000664000000000000000000000002012652076434017136 0ustar rootroot "%Line%\n" MediaInfoLib/Source/Resource/Text/Enums_.2.txt0000664000000000000000000000014112652076434020147 0ustar rootroot //--------------------------------------------------------------------------- enum %Name% { MediaInfoLib/Source/Resource/Text/_.2.txt0000664000000000000000000000027412652076434017146 0ustar rootroot //--------------------------------------------------------------------------- void %Name% (%Class% &Info) { Info.Separator_Set(0, __T("\n")); Info.Write(Ztring().From_UTF8( MediaInfoLib/Source/Resource/Text/DataBase/0000775000000000000000000000000012652076434017470 5ustar rootrootMediaInfoLib/Source/Resource/Text/DataBase/CodecID_Video_Mpeg4.csv0000664000000000000000000002721412652076434023627 0ustar rootroot2vuy;YUV;;;;;;YUV;4:2:2 2Vuy;YUV;;;;;;YUV;4:2:2 8BPS;RGB;;;;;;RGB;8:8:8 ac16;YUV;;;;;;YUV;4:2:2 ac32;YUV;;;;;;YUV;4:2:2 acBG;YUV;;;;;;YUV;4:2:2 apch;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422 HQ;;YUV;4:2:2 apcn;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422;;YUV;4:2:2 apcs;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422 LT;;YUV;4:2:2 apco;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;422 Proxy;;YUV;4:2:2 ap4c;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;4444;;;4:4:4 ap4h;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;4444;;;4:4:4 ap4x;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;4444 XQ;;;4:4:4 ai11;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; ai12;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; ai13;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; ai14;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; ai15;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; ai1q;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; ai5q;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;; AV1x;YUV;;;;;;YUV;4:2:2 avc1;AVC;;Advanced Video Coding;http://www.apple.com/quicktime/download/standalone.html;;;; avcp;AVC;;Advanced Video Coding Parameters;http://www.apple.com/quicktime/download/standalone.html;;;; AVDJ;JPEG;;Avid AVdv;DV;;Avid;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 AVd1;DV;;Avid;http://www.apple.com/quicktime/download/standalone.html;;; AVdn;VC-3;DNxHD;Avid;http://www.apple.com/quicktime/download/standalone.html;;;; AVmp;MPEG Video;Avid IMX;;;;Version 2;;; avr ;JPEG;;;;;;; AVrp;RGB;Avid;;;;;RGB; b16g;Gray;;;;;;Y;16 b32a;Gray/Alpha;;;;;;YA;16:16 b48r;RGB;;;;;;RGB;16:16:16 b64a;RGBA;;;;;;RGBA;16:16:16:16 base;RGBA;;;;;;RGBA;16:16:16:16 blit;RGBA;;;;;;RGBA;16:16:16:16 blnd;Alpha Compositor;;;;;;; blur;Blur;;;;;;CMYK; CFHD;CineForm;;CineForm High-Definition (HD) wavelet codec;http://www.cineform.com/;;;; CHQX;Canopus HQX;;;;;;; CLLC;Canopus Lossless;;;;;;; CUVC;Canopus HQ;;;;;;; cmyk;CMYK;;;;;;; cvid;Cinepack;;;http://www.apple.com/quicktime/download/standalone.html;;;; drac;Dirac;;Dirac Video Coder;http://www.bbc.co.uk/rd/projects/dirac/index.shtml;;;; dslv;Cross Fade;;;http://www.apple.com/quicktime/download/standalone.html;;;; DV10;Digital Voodoo;;Digital Voodoo 10 bit Uncompressed 4:2:2 codec;http://www.digitalvoodoo.net/;;;; dv5n;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dv5p;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvc ;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvcp;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvh1;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvh2;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvh3;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvh4;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvh5;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvh6;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvhp;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 dvhq;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 DVOO;Digital Voodoo;;Digital Voodoo 8 bit Uncompressed 4:2:2 codec;http://www.digitalvoodoo.net/;;;; DVOR;Digital Voodoo;;Digital Voodoo intermediate raw;http://www.digitalvoodoo.net/;;;; dvpp;DV;DVCPRO;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2 DVTV;Digital Voodoo;;Digital Voodoo intermediate 2vuy;http://www.digitalvoodoo.net/;;;; DVVT;Digital Voodoo;;Digital Voodoo intermediate v210;http://www.digitalvoodoo.net/;;;; encv;(Encrypted);;;http://www.apple.com/quicktime/download/standalone.html;;;; FFV1;FFV1;;;;;;; gif ;M-GIF;;;;;;; Hap1;Hap;;Hap Video Codec;https://github.com/Vidvox/hap;;;; Hap5;Hap Alpha;;Hap Video Codec;https://github.com/Vidvox/hap;;;; HapY;Hap Q;;Hap Video Codec;https://github.com/Vidvox/hap;;;; h261;H.261;;;http://www.apple.com/quicktime/download/standalone.html;;;; h263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;; H263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;; h264;H.264;;;http://www.apple.com/quicktime/download/standalone.html;;;; hcpa;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;High;;YUV;4:2:2 HD10;Digital Voodoo;;Digital Voodoo 10 bit Uncompressed 4:2:2 HD codec;http://www.digitalvoodoo.net/;;;; hdv1;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv2;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv3;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv4;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv5;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv6;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv7;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv8;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdv9;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdva;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdvb;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdvc;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdvd;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdve;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hdvf;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; hvc1;HEVC;;High Efficiency Video Coding;http://www.itu.int/;;;; hev1;HEVC;;High Efficiency Video Coding;http://www.itu.int/;;;; icod;AIC;;Apple Intermediate Codec;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:0 j420;YUV;;;;;;YUV;4:2:0 jpeg;JPEG;;;http://www.apple.com/quicktime/download/standalone.html;;;; kpcd;Photo CD;;;;;;; LMP2;MPEG Video;;;;;;YUV; M105;Matrox;;;http://www.matrox.com/;;;; MMES;MPEG Video;;;;;;YUV; mmes;MPEG Video;;;;;;YUV; mjp2;JPEG 2000;;;;;;; mjpa;JPEG;;;;;;; mjpb;JPEG;;;;;;; mp4v;MPEG-4 Visual;;;;;;; mpeg;MPEG Video;;;;;;; mx3n;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; mx3p;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; mx4n;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; mx4p;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; mx5n;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; mx5p;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV; myuv;YUV;;;;;;YUV;4:2:0 ncpa;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;Normal;;YUV;4:2:2 ovc1;VC-1;;Smooth Streaming Media Video;http://alexzambelli.com/blog/2009/02/10/smooth-streaming-architecture/;;;; png ;PNG;;;;;;; PIM1;MPEG Video;;;;;;YUV; PIM2;MPEG Video;;;;;;YUV; PNTG;MacPaint;;Apple MacPaint image format;http://www.apple.com/quicktime/download/standalone.html;;;; r210;RGB;Blackmagic Design;;;;;RGB; R210;RGB;Blackmagic Design;;;;;RGB; raw ;RGB;;;http://www.apple.com/quicktime/download/standalone.html;;;RGB; rle ;RLE;;;http://www.apple.com/quicktime/download/standalone.html;;;RGB; rpza;Road Pizza;;;http://www.apple.com/quicktime/download/standalone.html;;;; s263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;; Shr0;SheerVideo;;Generic SheerVideo codec;http://www.bitjazz.com/;;;; Shr1;SheerVideo;;SheerVideo RGB;http://www.bitjazz.com/;;;; Shr2;SheerVideo;;SheerVideo Y'CbCr[A] 4:4:4;http://www.bitjazz.com/;;;; Shr3;SheerVideo;;SheerVideo Y'CbCr 4:2:2;http://www.bitjazz.com/;;;; Shr4;SheerVideo;;SheerVideo Y'CbCr 4:2:2;http://www.bitjazz.com/;;;; SV10;Sorenson;;Sorenson Media Video R1;http://www.apple.com/quicktime/download/standalone.html;;;; SVQ1;Sorenson 1;;Sorenson Media Video 1 (Apple QuickTime 3);http://www.apple.com/quicktime/download/standalone.html;;;; SVQ2;Sorenson 2;;Sorenson Media Video 2 (Apple QuickTime 4);http://www.apple.com/quicktime/download/standalone.html;;;; SVQ3;Sorenson 3;;Sorenson Media Video 3 (Apple QuickTime 5);http://www.apple.com/quicktime/download/standalone.html;;;; v210;YUV;AJA Video Systems Xena;;;;;YUV;4:2:2 V210;YUV;AJA Video Systems Xena;;;;;YUV;4:2:2 vc-1;VC-1;;SMPTE VC-1;http://www.smpte.org/;;;YUV; WMV3;VC-1;WMV3;Windows Media Video 9;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;;; WRLE;Bitmap;;Windows BMP image format;http://www.apple.com/quicktime/download/standalone.html;;;YUV; xd50;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd51;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd52;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd53;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd54;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd55;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd56;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd57;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd58;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd59;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd5a;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd5b;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd5c;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd5d;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd5e;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xd5f;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdhd;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdh2;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv0;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv1;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv2;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv3;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv4;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv5;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv6;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv7;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv8;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdv9;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdva;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdvb;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdvc;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdvd;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdve;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV xdvf;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV yuv2;YUV;;;;;;YUV;4:2:2 yuvs;YUV;;;;;;YUV;4:2:2 yuvu;YUV;;;;;;YUV;4:2:2 yuvx;YUV;;;;;;YUV;4:2:2 MediaInfoLib/Source/Resource/Text/DataBase/Library_MainConcept_Avc.csv0000664000000000000000000000004212652076434024656 0ustar rootroot2.0.1889;2.0.1889;UTC 2006-01-11 MediaInfoLib/Source/Resource/Text/DataBase/CodecID_Audio_Real.csv0000664000000000000000000000165012652076434023525 0ustar rootroot14.4;VSELP;;Real Player 1;http://www.real.com 14_4;VSELP;;Real Player 1;http://www.real.com 28.8;G.728;;Real Player 2;http://www.real.com 28_8;G.728;;Real Player 2;http://www.real.com atrc;Atrac;;Real Player 8;http://www.real.com audio/X-MP3-draft-00;MPEG Audio;;; audio/x-ralf-mpeg4;RealAudio Lossless;;Real Audio Lossless Format, Real Player 10;http://www.real.com;;;;;;Lossless audio/x-ralf-mpeg4-generic;RealAudio Lossless;;Real Audio Lossless Format, Real Player 10;http://www.real.com;;;;;;Lossless cook;Cooker;;Based on G.722.1, Real Player 6;http://www.real.com dnet;AC-3;;Real Player 3;http://www.real.com lpcJ;VSELP;;Real Player 1;http://www.real.com raac;AAC;;Real Player 9;http://www.real.com;LC racp;AAC;;Real Player 10;http://www.real.com;HE-AAC rtrc;RealAudio 8;;;http://www.real.com sipr;ACELP;;Real Player 4;http://www.real.com whrl;RealAudio Multi-Channel;;Real Audio Multi-Channel;http://www.real.com MediaInfoLib/Source/Resource/Text/DataBase/CodecID_General_Mpeg4.csv0000664000000000000000000001024012652076434024125 0ustar rootrootM4V ;MPEG-4;;;; isom;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media iso2;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media iso4;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media mp41;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media / Version 1 mp42;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media / Version 2 avc1;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;JVT 3gp1;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 1 3gp2;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 2 3gp3;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 3 3gp4;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 4 3gp5;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 5 3gp6;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 6 Basic 3gp6;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 6 Progressive Download 3gp6;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 6 Streaming Servers 3gp7;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 7 Streaming Servers 3g2a;MPEG-4;;;http://www.3gpp2.org/;3GPP2 Media 3ge6;MPEG-4;;;http://www.3gpp.org/;3GPP Release 6 MBMS Extended Presentation 3ge7;MPEG-4;;;http://www.3gpp.org/;3GPP Release 7 MBMS Extended Presentation 3gg6;MPEG-4;;;http://www.3gpp.org/;3GPP Release 6 General 3gp8;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html; 3gp9;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html; CAQV;MPEG-4;;;http://world.casio.com/;Casio FACE;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Facebook isml;MPEG-4;IIS Smooth Streaming file format;;http://www.apple.com/quicktime/download/standalone.html;ISML JP20;MPEG-4;;;http://gpac.sourceforge.net/;JPEG 2000 JPM ;MPEG-4;;;http://www.iso.org/;JPEG 2000 Compound Image JPX ;MPEG-4;;;http://www.iso.org/;JPEG 2000 w/ extensions KDDI;MPEG-4;;;http://www.3gpp2.org/;3GPP2 EZMovie for KDDI 3G Cellphones MJ2S;MPEG-4;;;http://www.iso.org/;Motion JPEG 2000 Simple Profile MJP2;MPEG-4;;;http://www.iso.org/;Motion JPEG 2000 General Profile MQT ;MPEG-4;;;http://www.sony.com/;Sony/Mobile QuickTime MSNV;MPEG-4;;;http://www.sony.com/;Sony PSP ndas;MPEG-4;;;http://www.nerodigital.com;Nero Digital AAC Audio ndsc;MPEG-4;;;http://www.nerodigital.com;Nero Digital Cinema Profile ndsh;MPEG-4;;;http://www.nerodigital.com;Nero Digital HDTV Profile ndsm;MPEG-4;;;http://www.nerodigital.com;Nero Digital Mobile Profile ndsp;MPEG-4;;;http://www.nerodigital.com;Nero Digital Portable Profile ndss;MPEG-4;;;http://www.nerodigital.com;Nero Digital Standard Profile ndxc;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Cinema Profile ndxh;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC HDTV Profile ndxm;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Mobile Profile ndxp;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Portable Profile ndxs;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Standard Profile mmp4;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Mobile version mp71;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;ISO 14496-12 MPEG-7 meta data mp7b;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;ISO 14496-12 MPEG-7 meta data piff;MPEG-4;Protected Interoperable File Format;;http://www.apple.com/quicktime/download/standalone.html;PIFF qt ;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;QuickTime SDV ;MPEG-4;;;http://www.sdcard.org/;SD Memory Card Video M4A ;MPEG-4;;;http://www.apple.com/itunes/;Apple audio with iTunes info M4B ;MPEG-4;;;http://www.apple.com/itunes/;Apple audio with iTunes position M4P ;MPEG-4;;;http://www.apple.com/itunes/;AES encrypted audio M4VP;MPEG-4;;;http://www.apple.com/iphone/;Apple iPhone iphE;MPEG-4;;;http://www.apple.com/iphone/;Apple iPhone (Cellular) M4VH;MPEG-4;;;http://www.apple.com/appletv/;Apple TV QTCA;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Quicktime compressed archive CAQV;MPEG-4;;;;Casio Digital Camera QTI ;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;QuickTime Image f4v ;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Adobe Flash MediaInfoLib/Source/Resource/Text/DataBase/CodecID_Text_Mpeg4.csv0000664000000000000000000000053212652076434023477 0ustar rootrootc608;EIA-608 c708;EIA-708 subp;VobSub;;The same subtitle format used on DVDs; text;Apple text;;;http://www.apple.com/quicktime/download/standalone.html sbtl;Apple text;(iPhone);;http://www.apple.com/quicktime/download/standalone.html dfxp;TTML tx3g;Timed text;;;http://www.apple.com/quicktime/download/standalone.html enct;(Encrypted);;; MediaInfoLib/Source/Resource/Text/DataBase/CodecID_Other_Mpeg4.csv0000664000000000000000000000001212652076434023625 0ustar rootrootrtp ;RTP MediaInfoLib/Source/Resource/Text/DataBase/CodecID_Text_Riff.csv0000664000000000000000000000011412652076434023405 0ustar rootrootDXSB;DivX Subtitle;;Subtitle in AVI from DivX networks;http://www.divx.com MediaInfoLib/Source/Resource/Text/DataBase/CodecID_Video_Real.csv0000664000000000000000000000056012652076434023531 0ustar rootrootRV10;RealVideo 1;;Based on H.263, Real Player 5;http://www.real.com RV13;RealVideo 1.3;;Based on H.263, Real Player 5;http://www.real.com RV20;RealVideo 2;;Based on H.263, Real Player 6;http://www.real.com RV30;RealVideo 3;;Between H.263 and AVC (H.264), Real Player 8;http://www.real.com RV40;RealVideo 4;;Based on AVC (H.264), Real Player 9;http://www.real.com MediaInfoLib/Source/Resource/Text/DataBase/Format.csv0000664000000000000000000001741012652076434021440 0ustar rootrootAAF;;;M;Aaf;;aaf;;; AIFF;;;M;Riff;Apple/SGI;aiff aifc aif;audio/x-aiff;; AMV;;;M;Riff;Chinese hack of AVI;amv;;http://en.wikipedia.org/wiki/AMV_video_format; AVI;;;M;Riff;Audio Video Interleave;avi;video/vnd.avi;; BDAV;;;M;Bdav;Blu-ray Video;m2ts;;; Blu-ray Clip info;;;M;Bdmv;;clpi;;; Blu-ray Index;;;M;Bdmv;;bdmv;;; Blu-ray Movie object;;;M;Bdmv;;bdmv;;; Blu-ray Playlist;;;M;Bdmv;;mpls;;; CDDA;;;M;Riff;;cda;;; CDXA;;;M;Cdxa;;dat;;; DASH MPD;;;M;DashMpd;;mpd;application/dash+xml;;Lossy DV;;;M;DvdDif;;dv dif;video/DV;;Lossy DivX;;;M;Riff;Hack of AVI;divx;video/vnd.avi;http://www.divx.com; DPG;;;M;Dpg;Nintendo DS;dpg;;; DVD Video;;;M;Dvdv;;ifo;;; Flash Video;;;M;Flv;;flv;application/x-shockwave-flash;http://www.macromedia.com/go/getflashplayer; GXF;;;M;Gxf;SMPTE 360M;gxf;;; HDS F4M;Flash Media Manifest;;M;HdsF4m;;f4m; HLS;;;M;Hls;;m3u8;; Google Video;;;M;Riff;Hack of AVI;gvi;;http://video.google.com/playerdownload.html; ISM;Internet Streaming Media;;M;Ism;;ism;;; IVF;;;M;Ivf;;ivf;;; LXF;;;M;Lxf;;lxf;video/lxf;; Matroska;;;M;Mk;;mkv mk3d mka mks;;http://packs.matroska.org/; MPEG-PS;;;M;MpegPs;;mpeg mpg m2p vob pss;video/MP2P;; MPEG-TS;;;M;MpegTs;;ts m2t m2s m2ts m4t m4s ts tp trp;video/MP2T;; MPEG-4;;;M;Mpeg4;;mp4 m4v m4a m4b m4p 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma f4v;video/mp4;; MTV;;;M;Other;Chinese hack of MPEG-1 layer 3;mtv;;http://en.wikipedia.org/wiki/Chinese_MP4/MTV_Player; MXF;;;M;Mxf;;mxf;application/mxf;; NSV;;;M;Nsv;Nullsoft Streaming Video;nsv;;http://winamp.com; NUT;;;M;Nut;;nut;; Ogg;;;M;Ogg;;ogg ogm opus;video/ogg;http://www.free-codecs.com/Ogg_DirectShow_Filters_download.htm; PMP;;;M;Pmp;Playstation Portable;pmp;;; PTX;;;M;Ptx;;ptx;;; QuickTime;;;M;Mpeg4;Original Apple specifications;mov qt;video/quicktime;http://www.apple.com/quicktime/download/standalone.html; RealMedia;;;M;Rm;;rm rmvb ra;application/vnd.rn-realmedia;; RIFF-MMP;;;M;Riff;RIFF Multimedia Movie;;;; ShockWave;;;M;Swf;;swf;application/x-shockwave;http://www.macromedia.com/go/getflashplayer; SKM;;;M;Skm;Sky Korean Mobilephone;skm;;http://www.isky.co.kr/html/cs/download.jsp; Windows Media;;;M;Wm;;asf wmv wma;video/x-ms-wmv;; WebM;;;M;Mkv;;webm;video/webm;http://www.webmproject.org/; AVC;;;V;Avc;Advanced Video Codec;avc h264;video/H264;http://developers.videolan.org/x264.html AVS Video;;;V;AvsV;Audio Video Standard, Video part;;;http://www.avs.org.cn/;Lossy Dirac;;;V;Dirac;;drc;;http://diracvideo.org/;Lossy FFV1;;;V;;;;;;Lossless FFV2;;;V;;;;;;Lossless FLC;;;V;Flic;;fli flc;;http://www.chem.nott.ac.uk/flc.html;Lossy FLI;;;V;Flic;;fli flc;;http://www.chem.nott.ac.uk/flc.html;Lossy FLIC;;;V;Flic;;fli flc;;http://www.chem.nott.ac.uk/flc.html;Lossy H.261;;;V;;;h261;video/H261;;Lossy H.263;;;V;;;h263;video/H263;;Lossy HEVC;;;V;Hevc;High Efficiency Video Coding;avc h264;video/H265;http://www.itu.int MPEG Video;;;V;Mpegv;;mpgv mpv mp1v m1v mp2v m2v;video/MPV;;Lossy MPEG-4 Visual;;;V;Mpeg4;;m4v mp4v;video/MP4V-ES;;Lossy Theora;;;V;;;;;http://www.theora.org/;Lossy VC-1;;;V;Vc1;;vc1;video/vc1;;Lossy YUV4MPEG2;;;V;Y4m;;y4m;;;Lossless VP8;;;V;;;;;http://www.webmproject.org/;Lossy YUV;;;V;;;;;;Lossless AAC;;;A;;Advanced Audio Codec;;;;Lossy AC-3;;;A;Ac3;Audio Coding 3;ac3;;;Lossy ADIF;;;A;Adif;Audio Data Interchange Format;;;; ADTS;;;A;Adts;Audio Data Transport Stream;aac;;; ALS;;;A;Als;MPEG-4 Audio Lossless Coding;als;;http://www.nue.tu-berlin.de/forschung/projekte/lossless/mp4als.html#downloads;Lossless AMR;;;A;Amr;Adaptive Multi-Rate;amr;audio/AMR;http://www.apple.com/quicktime/download/standalone.html; Atrac;;;A;;;;audio/ATRAC;;Lossy Atrac3;;;A;;;;audio/ATRAC3;;Lossy AU;;;A;Au;uLaw/AU Audio File;au;audio/basic;; DolbyE;;;A;Aes3;;dde DTS;;;A;Dts;Digital Theater Systems;dts;;;Lossy DTS-HD;;;A;Dts;Digital Theater Systems;dts;;;Lossy E-AC-3;;;A;Ac3;Audio Coding 3;dd+ ec3;audio/eac3;;Lossy Extended Module;;;A;ExtendedModule;;xm;;; FLAC;;;A;Flac;Free Lossless Audio Codec;flac;;http://flac.sourceforge.net/; G.719;;;A;;;;audio/G719;;Lossy G.722;;;A;;;;audio/G722;;Lossy G.722.1;;;A;;;;audio/G7221;;Lossy G.723;;;A;;;;audio/G723;;Lossy G.729;;;A;;;;audio/G729;;Lossy G.729.1;;;A;;;;audio/G7291;;Lossy Impulse Tracker;;;A;ImpulseTracker;;it;;; LA;;;A;La;Lossless Audio Codec;la;;http://www.lossless-audio.com/;Lossless MIDI;;;A;Riff;RIFF Musical Instrument Digital Interface;midi mid kar;audio/midi;; Module;;;A;Module;;mod;;; Monkey's Audio;;;A;Ape;;ape mac;;http://www.monkeysaudio.com/;Lossless MPEG Audio;;;A;Mpega;;m1a mpa1 mp1 m2a mpa2 mp2 mp3;audio/mpeg;;Lossy OpenMG;;;A;OpenMG;;oma omg aa3;;;Lossy Musepack SV7;;;A;Mpc;;mpc;;http://www.musepack.net;Lossy Musepack SV8;;;A;Mpc;;mp+;;http://www.musepack.net;Lossy QCELP;;;A;;;;audio/QCELP;; RIFF-MIDI;;;A;Riff;RIFF Musical Instrument Digital Interface;;;; RKAU;RK Audio;;A;Rkau;;rka;;http://www.msoftware.co.nz; Scream Tracker 3;;;A;S3m;;s3m;;; Shorten;;;A;;;shn;;http://etree.org/shnutils/shorten/;Lossless SLS;;;A;;MPEG-4 Scalable Lossless Coding;sls;;http://www.chiariglione.org/mpeg/technologies/mp04-sls/index.htm;Lossless Speex;;;A;;;;audio/speex;http://www.speex.org/;Lossy Opus;;;A;;;;audio/opus;http://opus-codec.org/;Lossy TAK;;;A;;;tak;;http://thbeck.de/Tak/Tak.html;Lossless TrueHD;;;A;Ac3;;dts;;;Lossless TwinVQ;;;A;TwinVQ;Transform domain Weighted INterleave Vector Quantization;vqf;;http://www.twinvq.org/english/index_en.html; Vorbis;;;A;;;;audio/vorbis;http://www.vorbis.com/;Lossy Wave;;;A;Riff;;wav;audio/vnd.wave;; Wave64;;;A;Riff;;w64;;; WavPack;;;A;Wvpk;;wv wvc;;http://www.wavpack.com; Arri Raw;;;I;ArriRaw;;ari;;; Bitmap;;;I;Bmp;;bmp;image/bmp;;Lossless BPG;;;I;Bpg;Better Portable Graphics;bpg;image/bpg;http://bellard.org/bpg/; DDS;;;I;Dds;DirectDraw Surface;dds;;; DPX;;;I;Dpx;;dpx cin;;;Lossless EXR;;;I;Exr;;exr;;;Lossless DIB;;;I;Riff;RIFF Device Independent Bitmap;;;;Lossless GIF;;;I;Gif;Graphics Interchange Format;gif;image/gif;;Lossless ICO;;;I;Ico;;ico;image/vnd.microsoft.icon;;Lossless JNG;;;I;Jng;JPEG Network Graphic;jng;;;Lossy JPEG;;;I;Jpeg;;jpeg jpg jpe;image/jpeg;;Lossy JPEG 2000;;;I;Jpeg;;jp2;image/jp2;http://www.morgan-multimedia.com/JPEG 2000/; LZ77;;;I;;;;;; MNG;;;I;Mng;Multiple-Image Network Graphic;mng;;;Lossless PCX;;;I;pcx;Personal Computer eXchange;pcx;image/pcx;;Lossless PNG;;;I;Png;Portable Network Graphic;png;image/png;;Lossless PSD;;;I;Psd;Photoshop File Format;psd;image/psd;http://www.adobe.com/;Lossless RIFF Palette;;;I;Riff;RIFF Palette;;;; RLE;;;I;;Run-length encoding;rle;;; TIFF;;;I;Tiff;;tiff tif;image/tiff;; TGA;;;I;Tga;;tga;image/tga;; 7-Zip;;;C;7z;;7z;;http://7-zip.org; ACE;;;C;Ace;;ace;;http://winace.com; ELF;;;C;Elf;;so;;; ISO 9660;;;C;Iso9660;;iso;;; MZ;;;C;Mz;;exe dll;;; RAR;;;C;Rar;From Rarlabs;rar;application/x-rar-compressed;http://rarlabs.com; ZIP;;;C;Zip;;zip;application/zip;http://winzip.com; Adobe encore DVD;;;T;Other;;txt;;http://www.adobe.fr/products/encore/;Lossless AQTitle;;;T;Other;;aqt;;http://www.volny.cz/aberka/czech/aqt.html;Lossless ASS;;;T;Other;;ssa;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless Captions 32;;;T;Other;;txt;;;Lossless Captions Inc;;;T;Other;;txt;;;Lossless CPC Captioning;;;T;Other;;txt;;http://www.cpcweb.com/Captioning/cap_software.htm;Lossless Cheeta;;;T;Other;;asc;;;Lossless N19;;;T;N19;;stl;;;Lossless PDF;;;T;Pdf;;pdf;;; SAMI;;;T;Sami;;smi sami;;;Lossless SCC;;;T;SCC;;scc sc2;;;Lossless SubRip;;;T;SubRip;;srt;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless TTML;;;T;TTML;;dfxp;;;Lossless SSA;;;T;Other;;ssa;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless WebVTT;;;T;WebVTT;;vtt;;;Lossless Blender;;;O;Other;;blenders;;http://www.blender3d.com; AutoCAD;;;O;Other;;;;http://www.autodesk.com; PlayLater Video;;;V;Other;;;;http://www.playon.tv/playlater; MediaInfoLib/Source/Resource/Text/DataBase/Codec.csv0000664000000000000000000020007712652076434021230 0ustar rootroot BIT;RGB;4CC;V;RGB;;Uncompressed; JPG;JPEG;4CC;V;JPEG;;; PNG;PNG;4CC;V;RGB;;; RAW;RGB;4CC;V;RGB;;Uncompressed;http://www.fourcc.org/indexrgb.htm 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 RL4;RGB;4CC;V;RGB;;RLE 4bpp;http://www.fourcc.org/indexrgb.htm RL8;RGB;4CC;V;RGB;;RLE 8bpp;http://www.fourcc.org/indexrgb.htm 1978;RGB;4CC;V;JPEG;;A.M.Paredes predictor;http://www.pegasusimaging.com/cgi-bin/download2.cgi?LVIDB 2VUY;YUV;4CC;V;YUV;;Optibase VideoPump 8-bit 4:2:2 Component YCbCr; 3IV0;3ivX;4CC;V;MPEG-4V;;3ivX pre-1.0;http://www.3ivx.com/download/ 3IV1;3ivX;4CC;V;MPEG-4V;;3ivX 1.0-3.5;http://www.3ivx.com/download/ 3IV2;3ivX;4CC;V;MPEG-4V;;3ivX 4.0;http://www.3ivx.com/download/ 3IVD;3ivX;4CC;V;MPEG-4V;;;http://ffdshow-tryout.sourceforge.net/ 3IVX;3ivX;4CC;V;MPEG-4V;;;http://www.3ivx.com/download/ 3VID;3ivX;4CC;V;MPEG-4V;;;http://www.3ivx.com/download/ 8BPS;QuickTime 8bps;4CC;V;RGB;;Apple QuickTime Planar RGB with Alpha-channel;http://ffdshow-tryout.sourceforge.net/ 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 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 ABYR;Kensigton low;4CC;V;;;Kensington (low resolution, low frame rate (6fps) for digital cameras); ACTL;ACT-L2;4CC;V;;;Streambox ACT-L2;http://www.streambox.com/products/act-L2_codec.htm ADV1;WaveCodec;4CC;V;Wavelet;;Loronix WaveCodec;http://www.loronix.com/products/video_clips/wavecodec.asp ADVJ;Avid;4CC;V;JPEG;;Avid JPEG. Aka AVRn; AEIK;Indeo 3.2;4CC;V;;;Intel Indeo Video 3.2 (Vector Quantization); 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 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 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 AHDV;CineForm;4CC;V;Wavelet;;CineForm 10-bit Visually Perfect HD (Wavelet);http://www.cineform.com/products/ConnectHD.htm AJPG;JPEG;4CC;V;JPEG;;22fps JPEG-based for digital cameras; ALPH;Ziracom;4CC;V;;;Ziracom Digital Communications Inc.; AMPG;VideoONE;4CC;V;MPEG-1;;Array VideoONE MPEG;http://www.array.com AMR ;AMR;4CC;V;;;Speech codec; ANIM;RDX;4CC;V;;;Intel RDX; AP41;AngelPotion;4CC;V;MPEG-4V;;AngelPotion Definitive 1 (hack of MS MPEG-4 v3);http://www.divxity.com/download/ap4v1-702.exe AP42;AngelPotion;4CC;V;MPEG-4V;;AngelPotion Definitive 2 (hack of MS MPEG-4 v3);http://www.divxity.com/download/ap4v1-702.exe ASLC;AlparySoft Lossless;4CC;V;;;AlparySoft Lossless;http://www.free-codecs.com/download/Alparysoft_Lossless_Video_Codec.htm ASV1;Asus 1;4CC;V;;;Asus Video 1;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip ASV2;Asus 2;4CC;V;;;Asus Video 2;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip ASVX;Asus X;4CC;V;;;Asus Video X;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip ATM4;Nero MPEG-4;4CC;V;MPEG-4V;;Ahead Nero Digital MPEG-4;http://www.nero.com AUR2;YUV;4CC;V;YUV;;Auravision Aura 2 - YUV 422; AURA;YUV;4CC;V;YUV;;Auravision Aura 1 - YUV 411; AUVX;AUVX;4CC;V;;;USH GmbH; AV1X;Avid 1:1;4CC;V;;;Avid 1:1x (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVC1;AVC;4CC;V;AVC;;Advanced Video Codec;http://ffdshow-tryout.sourceforge.net/ AVD1;Avid DV;4CC;V;DV;;Avid DV (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe 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 AVDN;Avid HD;4CC;V;;;Avid DNxHD (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVDV;Avid DV;4CC;V;DV;;Avid DV;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVI1;MainConcept;4CC;V;JPEG;;MainConcept JPEG; AVI2;MainConcept;4CC;V;JPEG;;MainConcept JPEG; AVID;Avid JPEG;4CC;V;JPEG;;Avid JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVIS;AviSynth;4CC;V;;;Wrapper for AviSynth (Dummy);http://ffdshow-tryout.sourceforge.net/ AVMP;Avid IMX;4CC;V;;;Avid IMX (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVR ;Avid NuVista;4CC;V;JPEG;;Avid ABVB/NuVista JPEG with Alpha-channel; AVRn;Avid JPEG;4CC;V;JPEG;;Avid JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVRN;Avid JPEG;4CC;V;JPEG;;Avid JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVUI;Avid;4CC;V;;;Avid Meridien Uncompressed with Alpha-channel;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AVUP;Avid;4CC;V;;;Avid 10bit Packed (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe AYUV;YUV;4CC;V;YUV;;4:4:4 YUV (AYUV); AZPR;QuickTime;4CC;V;;;Quicktime Apple Video;http://www.apple.com/quicktime/download/standalone.html AZRP;QuickTime;4CC;V;;;Quicktime Apple Video;http://www.apple.com/quicktime/download/standalone.html BGR ;RGB;4CC;V;RGB;;Uncompressed RGB32; BHIV;BeHere iVideo;4CC;V;;;BeHere iVideo; BINK;Bink;4CC;V;;;RAD Game Tools Bink Video; BIT ;RGB;4CC;V;RGB;;Uncompressed. BI_BITFIELDS; BITM;H.261;4CC;V;;;Microsoft H.261; BLOX;Blox;4CC;V;;;Jan Jezabek BLOX MPEG;http://www.ii.uj.edu.pl/~jezabek/blox/blox-0.1.0b.zip BLZ0;DivX;4CC;V;MPEG-4V;;DivX for Blizzard Decoder Filter;http://ffdshow-tryout.sourceforge.net/ BT20;MediaStream;4CC;V;;;Conexant ProSummer MediaStream; BTCV;Composite;4CC;V;;;Conexant Composite Video; BTVC;Composite;4CC;V;;;Conexant Composite Video; BW00;BergWave;4CC;V;Wavelet;;BergWave (Wavelet); BW10;Broadway;4CC;V;MPEG-1;;Data Translation Broadway MPEG Capture/Compression; BXBG;Boxx RGB;4CC;V;;;BOXX BGR; BXRG;Boxx RGB;4CC;V;;;BOXX RGB; BXY2;Boxx YUV;4CC;V;;;BOXX 10-bit YUV; BXYV;Boxx YUV;4CC;V;;;BOXX YUV; CC12;Intel YUV;4CC;V;YUV;;Intel YUV12; CDV5;Canopus DV;4CC;V;DV;;Canopus SD50/DVHD;http://www.cineform.com/products/ConnectHD.htm CDVC;Canopus DV;4CC;V;DV;;Canopus DV (DV);http://www.cineform.com/products/ConnectHD.htm CDVH;Canopus DV;4CC;V;DV;;Canopus SD50/DVHD;http://www.cineform.com/products/ConnectHD.htm CFCC;Perception;4CC;V;;;DPS Perception JPEG (dummy format - only AVI header); CFHD;CineForm;4CC;V;;;CineForm 10-bit Visually Perfect HD (Wavelet); CGDI;Camcorder;4CC;V;;;Camcorder Video (MS Office 97); CHAM;Champagne;4CC;V;;;Winnov Caviara Champagne; CJPG;Creative JPEG;4CC;V;JPEG;;Creative Video Blaster Webcam Go JPEG; CLJR;YUV;4CC;V;YUV;;Cirrus Logic YUV 4:1:1;http://www.fourcc.org/indexyuv.htm CLLC;Canopus;4CC;V;;;Canopus LossLess; CLPL;YUV;4CC;V;YUV;;Format similar to YV12 but including a level of indirection.; CM10;MediaShow;4CC;V;;;CyberLink Corporation;http://www.cyberlink.com CMYK;CMYK;4CC;V;;;Common Data Format in Printing; COL0;MS MPEG-4 v3;4CC;V;MPEG-4V;;Hacked MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/ COL1;MS MPEG-4 v3;4CC;V;MPEG-4V;;Hacked MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/ CPLA;YUV;4CC;V;YUV;;Weitek YUV 4:2:0 Planar; CRAM;MS Video;4CC;V;;;Microsoft Video 1; CSCD;CamStudio;4CC;V;;;RenderSoft CamStudio lossless (LZO & GZIP compression); CT10;TalkingShow;4CC;V;;;CyberLink Corporation;http://www.cyberlink.com CTRX;Citrix;4CC;V;;;Citrix Scalable Video; CUVC;Canopus HQ;4CC;V;;;Canopus HQ; CVID;Cinepack;4CC;V;;;Cinepak by CTi (ex. Radius) Vector Quantization;http://www.cinepak.com/text.html cvid;Cinepack;4CC;V;;;Cinepak by CTi (ex. Radius) Vector Quantization;http://www.apple.com/quicktime/download/standalone.html CWLT;WLT;4CC;V;;;Microsoft Color WLT DIB; CYUV;YUV;4CC;V;YUV;;Creative Labs YUV 4:2:2;http://www.fourcc.org/indexyuv.htm CYUY;YUV;4CC;V;YUV;;ATI Technologies YUV;http://www.fourcc.org/indexyuv.htm D261;H.261;4CC;V;;;DEC H.261; D263;H.263;4CC;V;;;DEC H.263; DAVC;AVC;4CC;V;AVC;;Dicas MPEGable H.264/MPEG-4 AVC base profile; DC25;MainConcept DV;4CC;V;DV;;MainConcept ProDV; DCAP;Pinnacle DV25;4CC;V;DV;;Pinnacle DV25; DCL1;Data Connextion;4CC;V;;;Data Connection Conferencing; DCT0;WniWni;4CC;V;;;WniWni; DFSC;VFW;4CC;V;;;DebugMode FrameServer VFW; DIB ;RGB;4CC;V;RGB;;Device Independent Bitmap; DIV1;FFMpeg;4CC;V;MPEG-4V;;FFmpeg-4 V1 (hacked MS MPEG-4 V1);http://ffdshow-tryout.sourceforge.net/ DIV2;MS MPEG-4 1/2;4CC;V;MPEG-4V;;;http://ffdshow-tryout.sourceforge.net/ DIV3;DivX 3 Low;4CC;V;MPEG-4V;;;http://www.divx.com DIV4;DivX 3 Fast;4CC;V;MPEG-4V;;;http://www.divx.com DIV5;DivX 5;4CC;V;MPEG-4V;;;http://www.divx.com DIV6;MS MPEG-4 v3;4CC;V;MPEG-4V;;MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/ DIVX;DivX 4;4CC;V;MPEG-4V;;Project Mayo DivX 4;http://www.divx.com divx;DivX;4CC;V;MPEG-4V;;Mainly used by Google;http://www.divx.com DJPG;Broadway 101;4CC;V;JPEG;;Data Translation, Inc.; DM4V;Dicas;4CC;V;MPEG-4V;;Dicas MPEGable MPEG-4; DMB1;Rainbow;4CC;V;JPEG;;Matrox Rainbow Runner hardware compression;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.MJPG.v2.10.27.codec.exe DMB2;Paradigm JPEG;4CC;V;JPEG;;JPEG used by Paradigm; DMK2;V36 PDA;4CC;V;;;ViewSonic V36 PDA Video; DP02;DynaPel;4CC;V;MPEG-4V;;DynaPel MPEG-4; DP16;YUV411;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression); DP18;YUV411;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 8-bit compression) DP26;YUV422;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression) DP28;YUV422;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 8-bit compression) DP96;YVU9;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression) DP98;YVU9;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 8-bit compression) DP9L;YVU9;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression) DPS0;DPS Reality;4CC;V;JPEG;;DPS Reality JPEG (dummy format - only AVI header) DPSC;DPS PAR;4CC;V;JPEG;;DPS PAR JPEG (dummy format - only AVI header) DRWX;Pinnacle DV25;4CC;V;DV;;Pinnacle DV25 DSVD;DV;4CC;V;DV;;Microsoft DirectShow DV DTMT;Media-100;4CC;V;;;Media-100 DTNT;Media-100;4CC;V;;;Media-100 DUCK;TrueMotion S;4CC;V;;;Duck Corporation True Motion S DV10;BlueFish;4CC;V;;;BlueFish444 (lossless RGBA, YUV 10-bit) DV25;DVCPro;4CC;V;DV;;Matrox DVCPRO DV50;DVCPro5;4CC;V;DV;;Matrox DVAN;Pinnacle DV300;4CC;V;DV;;Pinnacle miroVideo DV300 SW only; DVC ;Apple DV NTSC;4CC;V;DV;;Apple QuickTime DV (DVCPRO NTSC);http://www.apple.com/quicktime/download/standalone.html dvc ;Apple DV NTSC;4CC;V;DV;;Apple QuickTime DV (DVCPRO NTSC);http://www.apple.com/quicktime/download/standalone.html DVCP;Apple DV PAL;4CC;V;DV;;Apple QuickTime DV (DVCPRO PAL);http://www.apple.com/quicktime/download/standalone.html dvcp;Apple DV PAL;4CC;V;DV;;Apple QuickTime DV (DVCPRO PAL);http://www.apple.com/quicktime/download/standalone.html DVCS;MainConcept DV;4CC;V;DV;;MainConcept DV; DVE2;Insoft DVE-2;4CC;V;DV;;InSoft DVE-2 Videoconferencing; DVH1;Pinnacle DV;4CC;V;DV;;Pinnacle DVHD100; dvhd;DV HD;4CC;V;DV;;DV 1125 lines at 30.00 Hz or 1250 lines at 25.00 Hz; dvhd;DV HD;4CC;A;DV;;Sony DV (DV), audio part; DVIS;DualMoon DV;4CC;V;DV;;VSYNC DualMoon Iris DV; DVL ;Radius DV NTSC;4CC;V;DV;;Radius SoftDV 16:9 NTSC; DVLP;Radius DV PAL;4CC;V;DV;;Radius SoftDV 16:9 PAL; DVMA;Darim DV;4CC;V;DV;;Darim Vision DVMPEG (dummy for MPEG compressor); DVNM;DVNM;4CC;V;;;Matsushita Electric Industrial Co., Ltd.; DVOR;BlueFish;4CC;V;;;BlueFish444 (lossless RGBA, YUV 10-bit); DVPN;Apple DV NTSC;4CC;V;DV;;Apple QuickTime DV (DV NTSC); DVPP;Apple DV PAL;4CC;V;DV;;Apple QuickTime DV (DV PAL); DVR ;MPEG-2 Video;4CC;V;MPEG-2;;MPEG-2 Video in a ASF container; DVR1;Targa2000;4CC;V;;;TARGA2000; DVRS;DualMoon DV;4CC;V;DV;;VSYNC DualMoon Iris DV; DVSD;DV;4CC;V;DV;;IEC 61834 and SMPTE 314M; dvsd;Sony DV;4CC;V;DV;;Sony DV (DV) 525 lines at 29.97 Hz or 625 lines at 25.00 Hz; dvsd;Sony DV;4CC;A;DV;;Sony DV (DV), audio part; dvsl;Sony DV;4CC;V;DV;;Sony DV (DV) 525 lines at 29.97 Hz or 625 lines at 25.00 Hz; dvsl;Sony DV;4CC;A;DV;;Sony DV (DV), audio part; DVSL;DSL DV;4CC;V;DV;;DV compressed in SD (SDL); DVX1;DVX 1 SP;4CC;V;;;Lucent DVX1000SP Video Decoder; DVX2;DVX 2 S;4CC;V;;;Lucent DVX2000S Video Decoder; DVX3;DVX 3 S;4CC;V;;;Lucent DVX3000S Video Decoder; DX50;DivX 5;4CC;V;MPEG-4V;;;http://www.divx.com DXGM;EA GameVideo;4CC;V;;;Electronic Arts Game Video; DXSB;DivX.com Subtitle;4CC;T;;;Subtitle in AVI from DivX networks;http://www.divx.com DXT1;DirectX TC;4CC;V;;;DirectX Compressed Texture (1bit alpha channel); DXT2;DirectX TC;4CC;V;;;DirectX Compressed Texture; DXT3;DirectX TC;4CC;V;;;DirectX Compressed Texture (4bit alpha channel); DXT4;DirectX TC;4CC;V;;;DirectX Compressed Texture; DXT5;DirectX TC;4CC;V;;;DirectX Compressed Texture (3bit alpha channel with interpolation); DXTC;DirectX TC;4CC;V;;;DirectX Texture Compression; DXTn;DirectX TC;4CC;V;;;Microsoft Compressed Texture; DXTN;DirectX TC;4CC;V;;;Microsoft DirectX Compressed Texture (DXTn); EKQ0;Elsa KQ;4CC;V;;;Elsa graphics card quick; ELK0;Elsa LK;4CC;V;;;Elsa graphics card; EM2V;Elymonyx MPEG-2;4CC;V;;;Etymonix MPEG-2 I-frame; EMWC;WMA;;A;;;EverAd, Inc.; EQK0;Elsa;4CC;V;;;Elsa graphics card quick; ESCP;Escape;4CC;V;;;Eidos Escape; ETV1;eTreppid 1;4CC;V;;;eTreppid Video 1; ETV2;eTreppid 2;4CC;V;;;eTreppid Video 2; ETVC;eTreppid C;4CC;V;;;eTreppid Video C; FFDS;FFDS;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ FFV1;FFV1;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ FFVH;FFVH;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ FLIC;FLI/FLC;4CC;V;;;Autodesk FLI/FLC Animation; FLJP;DField JPEG;4CC;V;;;D-Vision Field Encoded JPEG with LSI (or Targa emulation); FLV1;H.263;;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ FLV4;VP6;4CC;V;;;Flash, On2 Technologies;http://www.on2.com FMJP;D-Vision JPEG;4CC;V;;;D-Vision fieldbased ISO JPEG; FMP4;MPEG-4 Visual;4CC;V;MPEG-4V;;;http://ffdshow-tryout.sourceforge.net/ FPS1;FRAPS;4CC;V;;;;http://www.fraps.com/ FRLE;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Y16 + Alpha RLE; FRWA;SoftLab-Nsk JPEG (w Alpha);4CC;V;;;SoftLab-NSK Vision Forward JPEG with Alpha-channel; FRWD;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Vision Forward JPEG; FRWT;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Vision Forward JPEG with Alpha-channel; FRWU;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Vision Forward Uncompressed; FVF1;Itered Fractal;4CC;V;;;Iterated Systems Fractal Video Frame; FVFW;FVFW;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ FXT1;3DFX;4CC;V;;;3dfx Interactive, Inc.; G2M2;GoToMeeting2;4CC;V;;;Citrix Systems, Inc.;http://www.gotomeeting.com/ G2M3;GoToMeeting3;4CC;V;;;Citrix Systems, Inc.;http://www.gotomeeting.com/ GEPJ;White Pine JPEG;4CC;V;;;White Pine JPEG; GJPG;Grand Tech GT891x;4CC;V;;;Grand Tech GT891x; GLCC;GigaLink;4CC;V;;;GigaLink AV Capture; GLZW;Gabest;4CC;V;;;Motion LZW by Gabest;http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=84358 GPEG;Gabest;4CC;V;JPEG;;JPEG by Gabest (with floating point);http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=84358 GPJM;Pinnacle JPEG;4CC;V;JPEG;;Pinnacle ReelTime JPEG; GREY;YUV;4CC;V;YUV;;Simple grayscale video;http://www.fourcc.org/indexyuv.htm GWLT;MS GWLT;4CC;V;;;Microsoft Greyscale WLT DIB; GXVE;ViVD V2;4CC;V;;;SoftMedia; H260;Intel H.260;4CC;V;;;Intel H.260; H261;Intel H.261;4CC;V;;;Intel H.261 H262;Intel H.262;4CC;V;;;Intel H.262 H263;Intel H.263;4CC;V;;;Intel H.263 H264;AVC;4CC;V;AVC;;Intel H.264 h264;AVC;4CC;V;AVC;;Intel H.264 H265;Intel H.265;4CC;V;;;Intel H.265 H266;Intel H.266;4CC;V;;;Intel H.266 H267;Intel H.267;4CC;V;;;Intel H.267 H268;Intel H.268;4CC;V;;;Intel H.268 H269;Intel H.263;4CC;V;;;Intel H.263 for POTS-based videoconferencing HD10;BlueFish;4CC;V;;;BlueFish444 (lossless RGBA, YUV 10-bit) HDX4;Jomigo;4CC;V;;;Jomigo HDX4 HFYU;Huffman;4CC;V;;;Huffman Lossless YUV and RGB formats (with Alpha-channel) HMCR;Rendition;4CC;V;;;Rendition Motion Compensation Format HMRR;Rendition;4CC;V;;;Rendition Motion Compensation Format i263;Intel H.263;4CC;V;;;Intel H.263 I420;YUV;4CC;V;;; IAN ;Indeo 4;4CC;V;;;Intel Indeo 4 ICLB;CellB;4CC;V;;;InSoft CellB Videoconferencing IDM0;Wavelets 2;4CC;V;;;IDM Motion Wavelets 2.0 IF09;H.261;4CC;V;;;Microsoft H.261 IFO9;YUV9;4CC;V;YUV;;Intel IGOR;PowerDVD;4CC;V;;;Power DVD IJPG;Intergraph JPEG;4CC;V;JPEG;;Intergraph ILVC;Layered Video;4CC;V;;;Intel Layered Video ILVR;H.263+;4CC;V;;;Intel H.263+ IMAC;MotionComp;4CC;V;;;Intel hardware motion compensation. IMC1;YUV;4CC;V;YUV;;As YV12, except the U and V planes each have the same stride as the Y plane IMC2;YUV;4CC;V;YUV;;Similar to IMC1, except that the U and V lines are interleaved at half stride boundaries IMC3;YUV;4CC;V;YUV;;As IMC1, except that U and V are swapped IMC4;YUV;4CC;V;YUV;;As IMC2, except that U and V are swapped IMG ;YUV;4CC;V;YUV;; IMJG;Accom JPEG;4CC;V;;;Accom SphereOUS JPEG with Alpha-channel; IPDV;I-O DV;4CC;V;;;I-O Data Device Giga AVI DV; IPJ2;JPEG 2000;4CC;V;;;Image Power JPEG 2000; IR21;Indeo 2.1;4CC;V;;;Intel Indeo 2.1; IRAW;YUV;4CC;V;YUV;;Intel YUV Uncompressed;http://www.fourcc.org/indexyuv.htm ISME;ISME;4CC;V;;;Intel; IUYV;YUV;4CC;V;YUV;;Lead 16bpp. Interlaced version of UYVY (line order 0, 2, 4,....,1, 3, 5....); IV30;Indeo 3;4CC;V;;;Intel Indeo Video 3; IV31;Indeo 3;4CC;V;;;Intel Indeo Video 3.1; IV32;Indeo 3;4CC;V;;;Intel Indeo Video 3.2; IV33;Indeo 3;4CC;V;;;Intel Indeo Video 3.3; IV34;Indeo 3;4CC;V;;;Intel Indeo Video 3.4; IV35;Indeo 3;4CC;V;;;Intel Indeo Video 3.5; IV36;Indeo 3;4CC;V;;;Intel Indeo Video 3.6; IV37;Indeo 3;4CC;V;;;Intel Indeo Video 3.7; IV38;Indeo 3;4CC;V;;;Intel Indeo Video 3.8; IV39;Indeo 3;4CC;V;;;Intel Indeo Video 3.9; IV40;Indeo 4;4CC;V;;;Intel Indeo Video 4.0; IV41;Indeo 4;4CC;V;;;Intel Indeo Video 4.1; IV42;Indeo 4;4CC;V;;;Intel Indeo Video 4.2; IV43;Indeo 4;4CC;V;;;Intel Indeo Video 4.3; IV44;Indeo 4;4CC;V;;;Intel Indeo Video 4.4; IV45;Indeo 4;4CC;V;;;Intel Indeo Video 4.5; IV46;Indeo 4;4CC;V;;;Intel Indeo Video 4.6; IV47;Indeo 4;4CC;V;;;Intel Indeo Video 4.7; IV48;Indeo 4;4CC;V;;;Intel Indeo Video 4.8; IV49;Indeo 4;4CC;V;;;Intel Indeo Video 4.9; IV50;Indeo 4;4CC;V;;;Intel Indeo Video 5.0 Wavelet;http://www.fourcc.org/indexyuv.htm 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 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 IYU2;YUV;4CC;V;YUV;;IEEE1394 24bpp. 24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec; IYUV;YUV;4CC;V;YUV;;Intel Indeo iYUV 4:2:0; JBYR;Kensington;4CC;V;;;Kensington Video;http://ffdshow-tryout.sourceforge.net/ JFIF;JPEG;4CC;V;JPEG;;; JPEG;JPEG;4CC;V;JPEG;;JPEG compressed;http://www.apple.com/quicktime/download/standalone.html jpeg;JPEG;4CC;V;JPEG;;JPEG compressed; JPG;JPEG;4CC;V;JPEG;;JPEG compressed;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe JPGL;Pegasus JPEG;4CC;V;;;DIVIO JPEG Light for WebCams (Pegasus Lossless JPEG); KMVC;Karl;4CC;V;;;Karl Morton's Video (presumably);http://www.apple.com/quicktime/download/standalone.html kpcd;Photo CD;4CC;V;;;Kodak Photo CD; L261;H.261;4CC;V;;;Lead Technologies H.261; L263;H.263+;4CC;V;;;Lead Technologies H.263; LAGS;Lagarith;4CC;V;;;Lagarith LossLess; LBYR;Creative WebCam;4CC;V;;;Creative WebCam; LCMW;Lead CMW;4CC;V;;;Lead Technologies Motion CMW; LCW2;Lead MCMW;4CC;V;;;LEADTools MCMW 9Motion Wavelet;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe LEAD;Lead Video;4CC;V;;;LEAD Video; LGRY;Lead GrayScale;4CC;V;;;Lead Technologies Grayscale Image; LIA1;Liafail;4CC;V;;;Liafail, Inc.; LJ2K;Lead JPEG 2000;4CC;V;;;LEADTools JPEG 2000;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe LJPG;Lead JPEG;4CC;V;JPEG;;LEAD JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe Ljpg;Lead JPEG;4CC;V;JPEG;;LEAD JPEG; LMP2;Lead MPEG-2;4CC;V;;;LEADTools MPEG-2; LOCO;LOCO;4CC;V;;;LOCO Lossless; LSCR;Lead Screen capture;4CC;V;;;LEAD Screen Capture; LSV0;LSV0;4CC;V;;;Infinop Inc.; LSVC;Vmail;4CC;V;;;Vianet Lighting Strike Vmail (Streaming); LSVM;Vmail;4CC;V;;;Vianet Lighting Strike Vmail (Streaming); LSVW;Infinop;4CC;V;;;Infinop Lightning Strike multiple bit rate video codec.; LSVX;Vmail;4CC;V;;;Vianet Lightning Strike Video Codec; LZO1;LZO;4CC;V;;;LZO compressed (lossless); M101;YUV;4CC;V;YUV;;Matrox; M261;H.261;4CC;V;;;Microsoft H.261; M263;H.263;4CC;V;;;Microsoft H.263; M4CC;ESS Divo;4CC;V;MPEG-4V;;ESS MPEG-4 Divio; M4S2;FFmpeg MPEG-4;4CC;V;;;Microsoft MPEG-4 (hacked MS MPEG-4); MC12;ATI Motion;4CC;V;;;ATI Motion Compensation Format; MC24;MainConcept JPEG;4CC;V;JPEG;;MainConcept JPEG; MCAM;ATI Motion;4CC;V;;;ATI Motion Compensation Format; MCZM;RGB;4CC;V;RGB;;Theory MicroCosm Lossless 64bit RGB with Alpha-channel; MDVD;MicroDVD;4CC;V;;;Alex MicroDVD Video (hacked MS MPEG-4); MDVF;Pinnacle DV;4CC;V;DV;;Pinnacle DV/DV50/DVHD100; 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 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 MJPA;Pinacle JPEG A;4CC;V;;;Pinnacle ReelTime MJPG hardware;http://mediaxw.sourceforge.net MJPB;Pinacle JPEG B;4CC;V;JPEG;;JPEG; MJPG;JPEG;4CC;V;JPEG;;JPEG including Huffman Tables; mJPG;IBM JPEG (w Huffman);4CC;V;JPEG;;IBM JPEG including Huffman Tables; MJPX;Pegasus JPEG;4CC;V;;;Pegasus PICVideo JPEG; ML20;Webcam;4CC;V;;;Mimic MSN Messenger Webcam; MMES;Matrox MPEG-2;4CC;V;MPEG-V;;Matrox MPEG-2 I-frame; MMIF;Matrox MPEG-2;4CC;V;MPEG-V;;Matrox MPEG-2 I-frame; MNVD;MindVid;4CC;V;;;MindBend MindVid LossLess; MP2A;MPEG-2 Audio;4CC;A;MPEG-A;;Media Excel MPEG-2 Audio; MP2T;MPEG-2 TS;4CC;M;MPEG-TS;;Media Excel MPEG-2 Transport Stream; MP2V;MPEG-2 Video;4CC;V;MPEG-V;;Media Excel MPEG-2 Video;http://ffdshow-tryout.sourceforge.net/ MP2v;MPEG-2 Video;4CC;V;MPEG-V;;MPEG-2 Video;http://ffdshow-tryout.sourceforge.net/ MP41;S-Mpeg 4 v1;4CC;V;;;Microsoft MPEG-4 V1 (enhansed H263);http://ffdshow-tryout.sourceforge.net/ MP42;S-Mpeg 4 v2;4CC;V;;;Microsoft MPEG-4 V2;http://www.apple.com/quicktime/download/standalone.html MP43;S-Mpeg 4 v3;4CC;V;;;Microsoft MPEG-4 V3; mp4a;AAC;4CC;A;AAC;;AAC;http://ffdshow-tryout.sourceforge.net/ MP4A;MPEG-4 Audio;4CC;A;AAC;;Media Excel MPEG-4 Audio;http://www.apple.com/quicktime/download/standalone.html MP4S;MS MPEG-4 v3;4CC;V;MPEG-4V;;Microsoft MPEG-4 (Windows Media 7.0); mp4s;MPEG-4 TS;4CC;M;MPEG-TS;;(MPEG-4) Apple MPEG-4 Transport Stream;http://ffdshow-tryout.sourceforge.net/ MP4T;MPEG-4 TS;4CC;M;MPEG-TS;;Media Excel MPEG-4 Transport Stream;http://www.apple.com/quicktime/download/standalone.html MP4V;MPEG-4 Video;4CC;V;MPEG-4V;;Apple QuickTime MPEG-4 native;http://ffdshow-tryout.sourceforge.net/ mp4v;MPEG-4 Video;4CC;V;MPEG-4V;;(MPEG-4) Apple MPEG-4 Video;http://www.apple.com/quicktime/download/standalone.html MPEG;MPEG;4CC;V;MPEG-V;;Chromatic MPEG 1 Video I Frame;http://ffdshow-tryout.sourceforge.net/ mpeg;MPEG;4CC;V;MPEG-V;;MPEG-1 Video;http://ffdshow-tryout.sourceforge.net/ MPG1;FFmpeg MPEG 1/2;4CC;V;MPEG-V;;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/ MPG2;FFmpeg MPEG 1/2;4CC;V;MPEG-V;;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/ MPG3;FFmpeg DivX 3;4CC;V;MPEG-4V;;(MPEG-4) MS MPEG-4 v3; MPG4;MS MPEG-4 v1;4CC;V;MPEG-4V;;Microsoft MPEG-4 v1; MPGI;Sigma MPEG;4CC;V;MPEG-V;;Sigma Design MPEG-1 I-frame; MPNG;PNG;4CC;V;RGB;;Motion PNG; MRCA;Mrcodec;4CC;V;;;FAST Multimedia; MRLE;RLE;4CC;V;RGB;;Microsoft RLE; MSS1;Windows Screen Video;4CC;V;;;Windows Screen Video; MSS2;Windows Media;4CC;V;;;Windows Media 9; MSUC;MSU;4CC;V;;;MSU LossLess; MSUD;MSU;4CC;V;;;MSU LossLess; MSV1;Microsoft Video 1;4CC;V;;;Microsoft Video 1; MSVC;Microsoft Video 1;4CC;V;;;Microsoft Video 1 MSZH;AVImszh;4CC;V;;;Lossless (ZIP compression) MTGA;TGA;4CC;V;RGB;;Motion TGA images (24, 32 bpp) MTX1;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX2;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX3;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX4;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX5;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX6;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX7;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX8;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MTX9;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG MV10;Nokia;4CC;V;;;Nokia Mobile Phones MV11;Nokia;4CC;V;;;Nokia Mobile Phones MV12;MVI;4CC;V;;;Motion Pixels (old) MV99;Nokia;4CC;V;;;Nokia Mobile Phones MVC1;Nokia;4CC;V;;;Nokia Mobile Phones MVC2;Nokia;4CC;V;;;Nokia Mobile Phones MVC9;Nokia;4CC;V;;;Nokia Mobile Phones MVI1;MVI;4CC;V;;;Motion Pixels MVI MVI2;MVI;4CC;V;;;Motion Pixels MVI MWV1;Aware Motion Wavelets;4CC;V;;;Aware Motion Wavelets MYUV;RGB;4CC;V;RGB;;Media-100 844/X Uncompressed NAVI;MS MPEG-4;4CC;V;MPEG-4V;;nAVI video (hacked MS MPEG-4) NDIG;Ahead MPEG-4;4CC;V;MPEG-4V;;Ahead Nero Digital MPEG-4 NHVU;Nvidia Texture;4CC;V;;;Nvidia Texture Format (GEForce 3) NO16;RGB;4CC;V;RGB;;Theory None16 64bit uncompressed Uncompressed NT00;LightWave;4CC;V;YUV;;NewTek LightWave HDTV YUV with Alpha-channel NTN1;NogaTech Video 1;4CC;V;;;Nogatech Video Compression 1 NTN2;NogaTech Video 2;4CC;V;;;Nogatech Video Compression 2 (GrabBee hardware coder) NUV1;Nuppel;4CC;V;;;NuppelVideo NV12;YUV;4CC;V;YUV;;8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling NV21;YUV;4CC;V;YUV;;As NV12 with U and V reversed in the interleaved plane NVDS;Nvidia Texture;4CC;V;;;Nvidia Texture Format NVHS;Nvidia Texture;4CC;V;;;Nvidia Texture Format (GeForce 3) NVHU;Nvidia Texture;4CC;V;;;Nvidia Texture Format NVS0;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS1;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS2;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS3;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS4;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS5;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS6;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS7;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS8;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVS9;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVT0;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVT1;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format NVT2;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT3;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT4;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT5;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT6;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT7;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT8;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NVT9;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format; NY12;YUV;4CC;V;YUV;;Nogatech Ltd.; NYUV;YUV;4CC;V;YUV;;Nogatech Ltd.; ONYX;VP7;4CC;V;;;On2 VP7;http://www.on2.com/vp7.php3 PCLE;Studio400;4CC;V;;;Pinnacle Systems, Inc.; PDVC;Panasonic DV;4CC;V;DV;;Panasonic DV; PGVV;Radius Video Vision;4CC;V;;;Radius Video Vision Telecast (adaptive JPEG); PHMO;Photomotion;4CC;V;;;IBM Photomotion; 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 PIM2;Pegasus JPEG;4CC;V;JPEG;;Pegasus Imaging;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe 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 PIXL;Miro JPEG;4CC;V;JPEG;;MiroVideo XL (JPEG); PNG;PNG;4CC;V;RGB;;; PNG1;PNG;4CC;V;RGB;;Corecodec.org CorePNG; PVEZ;PowerEZ;4CC;V;;;Horizons Technology PowerEZ; PVMM;Pegasus MPEG-4;4CC;V;MPEG-4V;;PacketVideo Corporation MPEG-4; PVW2;Pegasus Wavelet;4CC;V;;;Pegasus Imaging Wavelet 2000; PVWV;Pegasus Wavelet;4CC;V;;;Pegasus Imaging Wavelet 2000; PXLT;Pixlet;4CC;V;;;Apple Pixlet (Wavelet); Q1.0;QPEG 1.0;4CC;V;;;Q-Team QPEG 1.0;http://www.q-team.de Q1.1;QPEG 1.1;4CC;V;;;Q-Team QPEG 1.1;http://www.q-team.de Qclp;QCLP;4CC;A;;;; QDGX;Apple GX;4CC;V;;;Apple QuickDUncompressed GX; QDM1;QDesign 1;4CC;A;;;QDesign Music 1; QDM2;Qdesign 2;4CC;A;;;QDesign Music 2; QDRW;Palettized Video;4CC;V;;;Apple; QPEG;QPEG 1.1;4CC;V;;;Q-Team QPEG 1.1; QPEQ;QPEG 1.1;4CC;V;;;Q-Team QPEG 1.1; R210;YUV;4CC;V;YUV;;BlackMagic YUV (Quick Time); R411;Radius DV;4CC;V;DV;;Radius DV NTSC YUV; R420;Radius DV;4CC;V;DV;;Radius DV PAL YUV; RAV_;GroupTron;4CC;V;MPEG-1;;GroupTRON ReferenceAVI (dummy for MPEG compressor); RAVI;GroupTron;4CC;V;MPEG-1;;GroupTRON ReferenceAVI (dummy for MPEG compressor); RAW ;RGB;4CC;V;RGB;;Full Frames (Uncompressed); raw ;RGB;4CC;V;RGB;;Full Frames (Uncompressed);http://www.apple.com/quicktime/download/standalone.html RGB ;RGB;4CC;V;RGB;;Uncompressed RGB32; RGB1;RGB;4CC;V;RGB;;Uncompressed RGB332 3:3:2; 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 RGBO;RGB;4CC;V;RGB;;Uncompressed RGB555 5:5:5; RGBP;RGB;4CC;V;RGB;;Uncompressed RGB565 5:6:5; RGBQ;RGB;4CC;V;RGB;;Uncompressed RGB555X 5:5:5 BE; RGBR;RGB;4CC;V;RGB;;Uncompressed RGB565X 5:6:5 BE; RGBT;RGB;4CC;V;RGB;;Uncompressed RGB with transparency;http://www.fourcc.org/indexrgb.htm RIVA;Swizzled texture;4CC;V;;;Nvidia; RL4;RLE;4CC;V;RGB;;RLE 4bpp RGB; RL8;RLE;4CC;V;RGB;;RLE 8bpp RGB; RLE ;RLE;4CC;V;RGB;;RLE RGB with arbitrary sample packing within a pixel;http://www.fourcc.org/indexrgb.htm rle ;Animation;4CC;V;RGB;;;http://www.apple.com/quicktime/download/standalone.html RLE4;RLE;4CC;V;RGB;;RLE 4bpp RGB;http://www.fourcc.org/indexrgb.htm RLE8;RLE;4CC;V;RGB;;RLE 8bpp RGB;http://www.fourcc.org/indexrgb.htm RLND;Roland;4CC;V;;;Roland Corporation; RMP4;RealMagic MPEG-4;4CC;V;MPEG-4V;;REALmagic MPEG-4 Video (Sigma Design, built on XviD); ROQV;Id RoQ;4CC;V;;;Id RoQ File Video Decoder; rpza;Road Pizza;4CC;V;;;Apple Video 16 bit road pizza;http://www.apple.com/quicktime/download/standalone.html RT21;Intel Video 2.1;4CC;V;;;Intel Real Time Video 2.1; RTV0;NewTek VideoToaster;4CC;V;;;NewTek VideoToaster (dummy format - only AVI header); RUD0;Rududu;4CC;V;;;Rududu video; RV10;RealVideo 1;4CC;V;;;H263, RealVideo 5;http://www.real.com rv10;RealVideo 1;Real;V;;;H263, RealVideo 5;http://www.real.com RV13;RealVideo 1;4CC;V;;;H263, RealVideo 5;http://www.real.com rv20;RealVideo 2;Real;V;;;H263, RealVideo 6;http://www.real.com RV20;RealVideo 2;4CC;V;;;H263, RealVideo 6;http://www.real.com rv30;RealVideo 3;Real;V;;;Between H263 and H264, RealVideo 8;http://www.real.com RV30;RealVideo 3;4CC;V;;;Between H263 and H264, RealVideo 8;http://www.real.com rv40;RealVideo 4;Real;V;;;H264, RealVideo 9;http://www.real.com RV40;RealVideo 4;4CC;V;;;H264, RealVideo 9;http://www.real.com RVX ;RDX;4CC;V;;;Intel RDX; S263;S263;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ S422;VideoCap C210;4CC;V;YUV;;VideoCap C210; s422;VideoCap C210;4CC;V;YUV;;VideoCap C210; SAMR;AMR;4CC;A;;;; SAN3;SAN3;4CC;V;MPEG-4V;;Direct copy of DivX 3.11; SANM;Smush v2;4CC;V;;;LucasArts;http://www.lucasarts.com/ SCCD;SoftCam;4CC;V;;;; SDCC;Sun DV;4CC;V;DV;;Sun Digital Camera; SEDG;Samsung MPEG-4;4CC;V;MPEG-4V;;Samsung MPEG-4; SEG4;Cinepak;4CC;V;;;;http://www.sega.com/ SEGA;Cinepak;4CC;V;;;;http://www.sega.com/ SFMC;CrystalNet;4CC;V;;;CrystalNet Surface Fitting Method; SHR0;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR1;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR2;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR3;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR4;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR5;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR6;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SHR7;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless); SJPG;CuSeeMe;4CC;V;JPEG;;CuSeeMe;http://mirror01.iptelecom.net.ua/~video/codecs/CUseeMe.JPEG.CODEC.v1.17.exe SL25;SoftLab DVCPro;4CC;V;;;SoftLab-NSK DVCPRO; SL50;SoftLab DVCPro5;4CC;V;;;SoftLab-NSK ; SLDV;SoftLab DV;4CC;V;;;SoftLab-NSK Forward DV Draw; SLIF;SoftLab MPEG-2;4CC;V;MPEG-V;;SoftLab-NSK MPEG-2 I-frames; SLMJ;SoftLab JPEG;4CC;V;JPEG;;SoftLab-NSK Forward JPEG; smc ;SMC;4CC;V;;;Apple Graphics (SMC);http://www.apple.com/quicktime/download/standalone.html SMSC;Radius;4CC;V;;;; SMSD;Radius;4CC;V;;;; SMSV;Wavelet Video;4CC;V;;;WorldConnect Wavelet Streaming Video; smsv;Wavelet Video;4CC;V;;;WorldConnect Wavelet Video; SNOW;Snow;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/ SP40;SunPlus YUV;4CC;V;YUV;;SunPlus YUV; SP44;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam; SP53;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam; SP54;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam; SP55;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam; SP56;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam; SP57;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam SP58;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam SP61;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam SPIG;Spigot;4CC;V;;;Radius Spigot SPLC;ACM audio;4CC;V;;;Splash Studios ACM Audio SPRK;Spark;4CC;V;;; SQZ2;VXTreme 2;4CC;V;;;Microsoft VXTreme Video V2 STVA;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Bayer) STVB;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Nudged Bayer) STVC;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Bunched) STVX;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Extended Data Format) STVY;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Extended Data Format with Correction Data) subp;VobSub;4CC;T;;;The same subtitle format used on DVDs SV10;Sorenson;4CC;V;;;Sorenson Media Video R1 SVQ1;Sorenson 1;4CC;V;;;Sorenson Media Video 1 (Apple QuickTime 3) SVQ2;Sorenson 2;4CC;V;;;Sorenson Media Video 2 (Apple QuickTime 4) SVQ3;Sorenson 3;4CC;V;;;Sorenson Media Video 3 (Apple QuickTime 5) SWC1;MainConcept JPEG;4CC;V;JPEG;;MainConcept JPEG T420;Toshiba YUV;4CC;V;YUV;;Toshiba YUV 4:2:0 TGA ;Apple TGA;4CC;V;;;Apple TGA (with Alpha-channel) THEO;Theora;4CC;V;;;FFVFW Supported TIFF;Apple TIFF;4CC;V;;;Apple TIFF (with Alpha-channel) TIM2;Pinnacle DVI;4CC;V;;;Pinnacle RAL DVI TLMS;TeraLogic;4CC;V;;;TeraLogic Motion Intraframe TLST;TeraLogic;4CC;V;;;TeraLogic Motion Intraframe TM10;Duck;4CC;V;;;Duck TrueMotion TM20;Duck 2;4CC;V;;;Duck TrueMotion 2.0 TM2A;Duck Archiver 2;4CC;V;;;Duck TrueMotion Archiver 2.0 TM2X;Duck 2;4CC;V;;;Duck TrueMotion 2X TMIC;TeraLogic;4CC;V;;;TeraLogic Motion Intraframe TMOT;Horizons TM S;4CC;V;;;Horizons Technology TrueMotion Video TR20;Duck TM RT2;4CC;V;;;Duck TrueMotion RT 2.0 TRLE;Akula;4CC;V;;;Akula Alpha Pro Custom AVI (LossLess); TSCC;TechSmith;4CC;V;;;TechSmith Screen Capture; TV10;Tecomac;4CC;V;;;Tecomac Low-Bit Rate; TVJP;Pinnacle/Truevision;4CC;V;;;TrueVision Field Encoded JPEG (Targa emulation); TVMJ;Pinnacle/Truevision;4CC;V;;;Truevision TARGA JPEG Hardware (or Targa emulation); TY0N;Trident;4CC;V;;;Trident Decompression Driver; TY2C;Trident;4CC;V;;;Trident Decompression Driver; TY2N;Trident;4CC;V;;;Trident Decompression Driver; U5.3.0, <5.9.0; 1438;>5.3.0, <5.9.0; 1453;5.9.0 Fusion (InertialConfinement);UTC 2005-01 1461;5.9.0 Fusion (HiggsBoson);UTC 2005-01 1528;5.9.0 Fusion (HiggsBoson);UTC 2005-03-05 1571;6.0.0;UTC 2005-06-15 1594;6.0.0 (DivX Converter1.0);UTC 2005-06 1599;6.0.0 Helium;UTC 2005-06 1612;6.0.0 Helium (GodFatherOfSoul);UTC 2005-06-15 1697;6.0.3 Fusion (ThermonuclearFusion);UTC 2005-10-18 1737;He-3 (TwinTurbocharger);UTC 2005-12 1786;6.1.0;UTC 2005-12-12 1828;6.1.1;UTC 2006-02-01 1893;6.2.0 Beta1;UTC 2006-03-25 1910;6.2.0;UTC 2006-04-11 1913;6.2.1;UTC 2006-04 1915;6.2.1 Patch1Beta;UTC 2006-04 1920;6.2.2;UTC 2006-04-26 1977;6.2.5;UTC 2006-06-16 1988;6.2.5;UTC 2006-07 2075;>6.2.5, <6.4.0; 2081;6.4.0 Beta1;UTC 2006-09-27 2086;6.4.0;UTC 2006-10-03 2201;6.5.0;UTC 2006-12 2207;6.5.1;UTC 2007-03 2292;6.6.0;UTC 2007-05-04 2306;6.6.1; 2309;6.6.1; 2318;6.6.1.4; 2396;6.7 Beta;UTC 2007-08-26 2432;6.7.0;UTC 2007-09-20 2510;6.8.0;UTC 2007-12-04 2521;6.8.0 Converter 6.6; 2559;6.8.2;UTC 2008-05-17 2676;6.8.3-6.8.4;UTC 2008-06-07 2816;6.8.5;UTC 2009-08-20 2851;6.8.5;UTC 2009-08-20 MediaInfoLib/Source/Resource/Text/Enums_.5.txt0000664000000000000000000000002412652076434020152 0ustar rootroot %Name%_%Line%, MediaInfoLib/Source/Resource/Text/_.9.txt0000664000000000000000000000002112652076434017143 0ustar rootroot } //NameSpace MediaInfoLib/Source/Resource/Text/_.8.txt0000664000000000000000000000006512652076434017152 0ustar rootroot )); Info.Separator_Set(0, ZenLib::EOL); } MediaInfoLib/Source/Resource/Text/_.1.txt0000664000000000000000000000151112652076434017140 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 { MediaInfoLib/Source/Resource/Text/Enums_.8.txt0000664000000000000000000000000412652076434020153 0ustar rootroot}; MediaInfoLib/Source/Resource/Text/Enums_.1.txt0000664000000000000000000000140612652076434020153 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // 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 { MediaInfoLib/Source/PreRelease/0000775000000000000000000000000012652076434015340 5ustar rootrootMediaInfoLib/Source/PreRelease/OldFiles.h0000664000000000000000000000007612652076434017215 0ustar rootroot#include ZenLib::Ztring OldFiles_Test (); MediaInfoLib/Source/PreRelease/WxWidgets/0000775000000000000000000000000012652076434017265 5ustar rootrootMediaInfoLib/Source/PreRelease/WxWidgets/App.cpp0000664000000000000000000000060312652076434020510 0ustar rootroot// ---------------------------------------------------------------------------- #include "PreRelease/WxWidgets/App.h" #include "PreRelease/WxWidgets/GUI_Main.h" // ---------------------------------------------------------------------------- bool App::OnInit() { GUI_Main *frame = new GUI_Main(wxPoint(50, 50), wxSize(450, 340)); frame->Show(TRUE); return TRUE; } MediaInfoLib/Source/PreRelease/WxWidgets/GUI_Main.cpp0000664000000000000000000000310212652076434021355 0ustar rootroot//---------------------------------------------------------------------------- #include "PreRelease/WxWidgets/GUI_Main.h" #include #include #include #include "PreRelease/OldFiles.h" #include "PreRelease/Resources.h" //---------------------------------------------------------------------------- //Menu BEGIN_EVENT_TABLE(GUI_Main, wxFrame) EVT_MENU(1, GUI_Main::OldFiles) EVT_MENU(2, GUI_Main::Resources) END_EVENT_TABLE() // ---------------------------------------------------------------------------- // main frame // ---------------------------------------------------------------------------- // frame constructor GUI_Main::GUI_Main(const wxPoint& pos, const wxSize& size, long style) :wxFrame(NULL, -1, __T("MediaInfoLib - Too old files test"), pos, size, style) { // set the frame icon SetIcon(wxICON(mondrian)); //Menu wxMenu *Menu_File = new wxMenu; Menu_File->Append(1, __T("Test if there are too old files")); Menu_File->Append(2, __T("Update ressource files")); wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(Menu_File, __T("&File")); SetMenuBar(menuBar); Text=new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_RICH2); } GUI_Main::~GUI_Main() { } void GUI_Main::OldFiles(wxCommandEvent& WXUNUSED(event)) { Text->SetValue(OldFiles_Test().c_str()); } void GUI_Main::Resources(wxCommandEvent& WXUNUSED(event)) { Text->SetValue(Resources_Create().c_str()); } MediaInfoLib/Source/PreRelease/WxWidgets/App.h0000664000000000000000000000033412652076434020156 0ustar rootroot#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif class App : public wxApp { public: virtual bool OnInit(); }; IMPLEMENT_APP(App) MediaInfoLib/Source/PreRelease/WxWidgets/GUI_Main.h0000664000000000000000000000146012652076434021027 0ustar rootroot#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif // the application icon (under Windows and OS/2 it is in resources) #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__) #include "mondrian.xpm" #endif class wxTextCtrl; class GUI_Main : public wxFrame { public: GUI_Main(const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE); ~GUI_Main(); // event handlers (these functions should _not_ be virtual) void OldFiles(wxCommandEvent& event); void Resources(wxCommandEvent& event); private: wxTextCtrl* Text; DECLARE_EVENT_TABLE() // any class wishing to process wxWindows events must use this macro }; MediaInfoLib/Source/PreRelease/Resources.h0000664000000000000000000000010112652076434017453 0ustar rootroot#include ZenLib::Ztring Resources_Create (); MediaInfoLib/Source/PreRelease/OldFiles.cpp0000664000000000000000000001035112652076434017545 0ustar rootroot//--------------------------------------------------------------------------- //#include #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- /* #include #include #include */ #include #include "PreRelease/OldFiles.h" using namespace ZenLib; //--------------------------------------------------------------------------- Ztring Version; //X.X.X.X Ztring Version_Short; //X.X Ztring ToShow; //What to show to the user char C[1000000]; /* wxFile F; wxFileName FN; int I; Ztring Z; wxDateTime Access; */ int Test_Version(char* FileName_, char* Begin, char* End) { /* wxString FileName=Ztring().From_Local(FileName_).c_str(); //Opening File F.Open(FileName); I=F.Read(C, 1000000); if (!I) { ToShow+=__T("Error opening ")+FileName; return -1; } //Getting information C[I]=0; Z.From_Local(C); Z=Z.SubString(Ztring().From_Local(Begin), Ztring().From_Local(End)); //deleting extra bytes if (Z[Z.size()-1]=='\n') Z.resize(Z.size()-1); if (Z[Z.size()-1]=='\r') Z.resize(Z.size()-1); //Testing validity if (Z.size()!=3 && Z.size()!=7) //non long, no short { ToShow+=__T("Error reading ")+FileName; return -2; } //Reformtation information Z.FindAndReplace(__T(","), __T("."), 0, Ztring_Recursive); if (Z!=Version && Z!=Version_Short) { ToShow+=FileName; ToShow+=__T(" is not good : version is marked "); ToShow+=Z; ToShow+=__T("\r\n"); } */ return 0; } //--------------------------------------------------------------------------- /* int Test_Date(wxString FileName) { FN.Assign(FileName); if (!FN.FileExists()) { ToShow+=FileName; ToShow+=__T(" does not exist"); return -1; } if (!FN.GetTimes(&Access, NULL, NULL)) { ToShow+=__T("Error getting date of "); ToShow+=FileName; return -1; } wxTimeSpan TS=wxDateTime::Now()-Access; if (TS.GetWeeks()>0 || TS.GetDays()>0 || TS.GetHours()>0 || TS.GetMinutes()>0) { ToShow+=FileName; ToShow+=__T(" is old : was compiled"); ToShow+=TS.Format().c_str(); ToShow+=__T(" ago\r\n"); } return 0; } */ //--------------------------------------------------------------------------- Ztring OldFiles_Test () { /* //Checking version in Info_Version ToShow+=__T("Version checked : "); F.Open(__T("../Source/MediaInfo/MediaInfo_Config.cpp")); I=F.Read(C, 1000000); if (!I) { ToShow+=__T("Error opening ../Source/MediaInfo/MediaInfo_Config.cpp"); return ToShow; } C[I]=0; Z.From_Local(C); Version=Z.SubString(__T("MediaInfoLib - v"), __T("\")")); if (Version.size()!=7) { ToShow+=__T("Error reading ../Source/MediaInfo/MediaInfo.cpp : \"MediaInfoLib - vX.X.X.X - \" not found"); return ToShow; } Version_Short=Version; Version_Short.resize(3); ToShow+=Version+__T("\r\n"); //Checking version in MediaInfo.h if (Test_Version("../Source/MediaInfo/MediaInfo.h", "@version ", "\n")) return ToShow; if (Test_Version("../Source/MediaInfo/MediaInfoList.h", "@version ", "\n")) return ToShow; if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " FILEVERSION ", "\n")) return ToShow; if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " PRODUCTVERSION ", "\n")) return ToShow; if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " VALUE \"FileVersion\", \"", "\"")) return ToShow; if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " VALUE \"ProductVersion\", \"", "\"")) return ToShow; if (Test_Version("../History.txt", "Version ", " ")) return ToShow; if (Test_Date(__T("MSVC/Library/MediaInfo.lib"))) return ToShow; if (Test_Date(__T("MSVC/Dll/MediaInfo.dll"))) return ToShow; */ return ToShow; } //--------------------------------------------------------------------------- MediaInfoLib/Source/PreRelease/VCL/0000775000000000000000000000000012652076434015764 5ustar rootrootMediaInfoLib/Source/PreRelease/VCL/PreRelease_.dfm0000664000000000000000000000172512652076434020647 0ustar rootrootobject Form1: TForm1 Left = 192 Top = 114 Caption = 'Form1' ClientHeight = 505 ClientWidth = 680 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] Menu = MainMenu1 OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Memo1: TMemo Left = 0 Top = 16 Width = 649 Height = 481 Lines.Strings = ( 'Memo1') ScrollBars = ssVertical TabOrder = 0 end object MainMenu1: TMainMenu Left = 648 Top = 16 object File1: TMenuItem Caption = 'File' object Testiftherearetoooldfiles1: TMenuItem Caption = 'Test if there are too old files' OnClick = Testiftherearetoooldfiles1Click end object Updateresourcefiles1: TMenuItem Caption = 'Update resource files' OnClick = Updateresourcefiles1Click end end end end MediaInfoLib/Source/PreRelease/VCL/PreRelease_.cpp0000664000000000000000000000207312652076434020660 0ustar rootroot//--------------------------------------------------------------------------- #include #pragma hdrstop #include "PreRelease/VCL/PreRelease_.h" #include "PreRelease/OldFiles.h" #include "PreRelease/Resources.h" #include "PreRelease/Enums.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Testiftherearetoooldfiles1Click(TObject *Sender) { Memo1->Text=OldFiles_Test().c_str(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Updateresourcefiles1Click(TObject *Sender) { Memo1->Text=Resources_Create().c_str(); Memo1->Text=Enums_Create().c_str(); } //--------------------------------------------------------------------------- MediaInfoLib/Source/PreRelease/VCL/PreRelease_.h0000664000000000000000000000263112652076434020325 0ustar rootroot//--------------------------------------------------------------------------- #ifndef PreRelease_H #define PreRelease_H //--------------------------------------------------------------------------- #include #include #include #include #include //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TMainMenu *MainMenu1; TMemo *Memo1; TMenuItem *File1; TMenuItem *Testiftherearetoooldfiles1; TMenuItem *Updateresourcefiles1; void __fastcall Testiftherearetoooldfiles1Click(TObject *Sender); void __fastcall Updateresourcefiles1Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // For Widgets with DEBUG in BCB // Here only because this is useful everywhere #ifdef _DEBUG void wxAssert(int, const wchar_t*, int, const wchar_t*, const wchar_t*) {} #endif //_DEBUG //--------------------------------------------------------------------------- #endif MediaInfoLib/Source/PreRelease/Resources.cpp0000664000000000000000000002107412652076434020022 0ustar rootroot//--------------------------------------------------------------------------- //#include #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //#include #include #include #include "PreRelease/Resources.h" using namespace ZenLib; using namespace std; #define FILE_MAX 20000 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Open a file ZenLib::Ztring Resources_Create_Load(Ztring FileName, Ztring &Contents) { File F; if (F.Open(FileName.c_str())==false) { Ztring ToReturn=L"Problems to open "; ToReturn+=FileName; ToReturn+=L"\r\n"; return ToReturn; } char C[FILE_MAX]; size_t Size=F.Read(C, FILE_MAX-1); Contents.From_Local(C, Size); return L""; } //--------------------------------------------------------------------------- // Write a file ZenLib::Ztring Resources_Create_Save(Ztring FileName, Ztring &Contents) { File F; if (F.Create(FileName.c_str(), true)==false) { Ztring ToReturn=L"Problems to create "; ToReturn+=FileName; ToReturn+=L"\r\n"; return ToReturn; } std::string S1=Contents.To_UTF8(); size_t Size=F.Write((const int8u*)S1.c_str(), S1.size()); Contents.From_Number(Size); Contents+=L" bytes written"; return L""; } //--------------------------------------------------------------------------- // Open an item ZenLib::Ztring Resources_Create_Item(const Ztring &Directory, const Ztring &Name, const Ztring &Class, Ztring &Contents) { Contents.clear(); Ztring Result; //Load header Ztring Partial; Result=Resources_Create_Load(L"../Source/Resource/Text/_.2.txt", Partial); if (!Result.empty()) return Result; Partial.FindAndReplace(L"%Name%", Ztring(L"MediaInfo_Config_")+Name); Partial.FindAndReplace(L"%Class%", Class); Contents+=Partial; //Load line template Ztring Line; Result=Resources_Create_Load(L"../Source/Resource/Text/_.5.txt", Line); if (!Result.empty()) return Result; //Read input file ZtringListListF ZLL; ZLL.Load(Ztring(L"../Source/Resource/Text/")+Directory+L"/"+Name+L".csv"); for (size_t Pos=0; Pos #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //#include #include #include #include "PreRelease/Enums.h" using namespace ZenLib; using namespace std; #define FILE_MAX 20000 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Open a file ZenLib::Ztring Enums_Create_Load(Ztring FileName, Ztring &Contents) { File F; if (F.Open(FileName.c_str())==false) { Ztring ToReturn=L"Problems to open "; ToReturn+=FileName; ToReturn+=L"\r\n"; return ToReturn; } char C[FILE_MAX]; size_t Size=F.Read(C, FILE_MAX-1); Contents.From_Local(C, Size); return L""; } //--------------------------------------------------------------------------- // Write a file ZenLib::Ztring Enums_Create_Save(Ztring FileName, Ztring &Contents) { File F; if (F.Create(FileName.c_str(), true)==false) { Ztring ToReturn=L"Problems to create "; ToReturn+=FileName; ToReturn+=L"\r\n"; return ToReturn; } std::string S1=Contents.To_UTF8(); size_t Size=F.Write((const int8u*)S1.c_str(), S1.size()); Contents.From_Number(Size); Contents+=L" bytes written"; return L""; } //--------------------------------------------------------------------------- // Open an item ZenLib::Ztring Enums_Create_Item(const Ztring &Directory, const Ztring &Name, Ztring &Contents) { Contents.clear(); Ztring Result; //Load header Ztring Partial; Result=Enums_Create_Load(L"../Source/Resource/Text/Enums_.2.txt", Partial); if (!Result.empty()) return Result; Partial.FindAndReplace(L"%Name%", Ztring(Name).MakeLowerCase()); Contents+=Partial; //Load line template Ztring Line; Result=Enums_Create_Load(L"../Source/Resource/Text/Enums_.5.txt", Line); if (!Result.empty()) return Result; //Read input file ZtringListListF ZLL; ZLL.Load(Ztring(L"../Source/Resource/Text/")+Directory+L"/"+Name+L".csv"); for (size_t Pos=0; Pos ZenLib::Ztring Enums_Create (); MediaInfoLib/Source/ThirdParty/0000775000000000000000000000000012652076434015403 5ustar rootrootMediaInfoLib/Source/ThirdParty/sha1-gladman/0000775000000000000000000000000012652076434017640 5ustar rootrootMediaInfoLib/Source/ThirdParty/sha1-gladman/sha1.h0000664000000000000000000000457612652076434020661 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 01/08/2005 */ #ifndef _SHA1_H #define _SHA1_H #include #include "brg_types.h" #define SHA1_BLOCK_SIZE 64 #define SHA1_DIGEST_SIZE 20 #if defined(__cplusplus) extern "C" { #endif /* type to hold the SHA256 context */ typedef struct { uint32_t count[2]; uint32_t hash[5]; uint32_t wbuf[16]; } sha1_ctx; /* Note that these prototypes are the same for both bit and */ /* byte oriented implementations. However the length fields */ /* are in bytes or bits as appropriate for the version used */ /* and bit sequences are input as arrays of bytes in which */ /* bit sequences run from the most to the least significant */ /* end of each byte */ VOID_RETURN sha1_compile(sha1_ctx ctx[1]); VOID_RETURN sha1_begin(sha1_ctx ctx[1]); VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]); VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1]); VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len); #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/sha1-gladman/sha1.c0000664000000000000000000002100712652076434020640 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 01/08/2005 This is a byte oriented version of SHA1 that operates on arrays of bytes stored in memory. */ #include /* for memcpy() etc. */ #include "sha1.h" #include "brg_endian.h" #if defined(__cplusplus) extern "C" { #endif #if defined( _MSC_VER ) && ( _MSC_VER > 800 ) #pragma intrinsic(memcpy) #endif #if 0 && defined(_MSC_VER) #define rotl32 _lrotl #define rotr32 _lrotr #else #define rotl32(x,n) (((x) << n) | ((x) >> (32 - n))) #define rotr32(x,n) (((x) >> n) | ((x) << (32 - n))) #endif #if !defined(bswap_32) #define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00)) #endif #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) #define SWAP_BYTES #else #undef SWAP_BYTES #endif #if defined(SWAP_BYTES) #define bsw_32(p,n) \ { int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); } #else #define bsw_32(p,n) #endif #define SHA1_MASK (SHA1_BLOCK_SIZE - 1) #if 0 #define ch(x,y,z) (((x) & (y)) ^ (~(x) & (z))) #define parity(x,y,z) ((x) ^ (y) ^ (z)) #define maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #else /* Discovered by Rich Schroeppel and Colin Plumb */ #define ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) #define parity(x,y,z) ((x) ^ (y) ^ (z)) #define maj(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) #endif /* Compile 64 bytes of hash data into SHA1 context. Note */ /* that this routine assumes that the byte order in the */ /* ctx->wbuf[] at this point is in such an order that low */ /* address bytes in the ORIGINAL byte stream will go in */ /* this buffer to the high end of 32-bit words on BOTH big */ /* and little endian systems */ #ifdef ARRAY #define q(v,n) v[n] #else #define q(v,n) v##n #endif #define one_cycle(v,a,b,c,d,e,f,k,h) \ q(v,e) += rotr32(q(v,a),27) + \ f(q(v,b),q(v,c),q(v,d)) + k + h; \ q(v,b) = rotr32(q(v,b), 2) #define five_cycle(v,f,k,i) \ one_cycle(v, 0,1,2,3,4, f,k,hf(i )); \ one_cycle(v, 4,0,1,2,3, f,k,hf(i+1)); \ one_cycle(v, 3,4,0,1,2, f,k,hf(i+2)); \ one_cycle(v, 2,3,4,0,1, f,k,hf(i+3)); \ one_cycle(v, 1,2,3,4,0, f,k,hf(i+4)) VOID_RETURN sha1_compile(sha1_ctx ctx[1]) { uint32_t *w = ctx->wbuf; #ifdef ARRAY uint32_t v[5]; memcpy(v, ctx->hash, 5 * sizeof(uint32_t)); #else uint32_t v0, v1, v2, v3, v4; v0 = ctx->hash[0]; v1 = ctx->hash[1]; v2 = ctx->hash[2]; v3 = ctx->hash[3]; v4 = ctx->hash[4]; #endif #define hf(i) w[i] five_cycle(v, ch, 0x5a827999, 0); five_cycle(v, ch, 0x5a827999, 5); five_cycle(v, ch, 0x5a827999, 10); one_cycle(v,0,1,2,3,4, ch, 0x5a827999, hf(15)); \ #undef hf #define hf(i) (w[(i) & 15] = rotl32( \ w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \ ^ w[((i) + 2) & 15] ^ w[(i) & 15], 1)) one_cycle(v,4,0,1,2,3, ch, 0x5a827999, hf(16)); one_cycle(v,3,4,0,1,2, ch, 0x5a827999, hf(17)); one_cycle(v,2,3,4,0,1, ch, 0x5a827999, hf(18)); one_cycle(v,1,2,3,4,0, ch, 0x5a827999, hf(19)); five_cycle(v, parity, 0x6ed9eba1, 20); five_cycle(v, parity, 0x6ed9eba1, 25); five_cycle(v, parity, 0x6ed9eba1, 30); five_cycle(v, parity, 0x6ed9eba1, 35); five_cycle(v, maj, 0x8f1bbcdc, 40); five_cycle(v, maj, 0x8f1bbcdc, 45); five_cycle(v, maj, 0x8f1bbcdc, 50); five_cycle(v, maj, 0x8f1bbcdc, 55); five_cycle(v, parity, 0xca62c1d6, 60); five_cycle(v, parity, 0xca62c1d6, 65); five_cycle(v, parity, 0xca62c1d6, 70); five_cycle(v, parity, 0xca62c1d6, 75); #ifdef ARRAY ctx->hash[0] += v[0]; ctx->hash[1] += v[1]; ctx->hash[2] += v[2]; ctx->hash[3] += v[3]; ctx->hash[4] += v[4]; #else ctx->hash[0] += v0; ctx->hash[1] += v1; ctx->hash[2] += v2; ctx->hash[3] += v3; ctx->hash[4] += v4; #endif } VOID_RETURN sha1_begin(sha1_ctx ctx[1]) { ctx->count[0] = ctx->count[1] = 0; ctx->hash[0] = 0x67452301; ctx->hash[1] = 0xefcdab89; ctx->hash[2] = 0x98badcfe; ctx->hash[3] = 0x10325476; ctx->hash[4] = 0xc3d2e1f0; } /* SHA1 hash data in an array of bytes into hash buffer and */ /* call the hash_compile function as required. */ VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]) { uint32_t pos = (uint32_t)(ctx->count[0] & SHA1_MASK), space = SHA1_BLOCK_SIZE - pos; const unsigned char *sp = data; if((ctx->count[0] += len) < len) ++(ctx->count[1]); while(len >= space) /* tranfer whole blocks if possible */ { memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space); sp += space; len -= space; space = SHA1_BLOCK_SIZE; pos = 0; bsw_32(ctx->wbuf, SHA1_BLOCK_SIZE >> 2); sha1_compile(ctx); } memcpy(((unsigned char*)ctx->wbuf) + pos, sp, len); } /* SHA1 final padding and digest calculation */ VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1]) { uint32_t i = (uint32_t)(ctx->count[0] & SHA1_MASK); /* put bytes in the buffer in an order in which references to */ /* 32-bit words will put bytes with lower addresses into the */ /* top of 32 bit words on BOTH big and little endian machines */ bsw_32(ctx->wbuf, (i + 3) >> 2); /* we now need to mask valid bytes and add the padding which is */ /* a single 1 bit and as many zero bits as necessary. Note that */ /* we can always add the first padding byte here because the */ /* buffer always has at least one empty slot */ ctx->wbuf[i >> 2] &= 0xffffff80 << 8 * (~i & 3); ctx->wbuf[i >> 2] |= 0x00000080 << 8 * (~i & 3); /* we need 9 or more empty positions, one for the padding byte */ /* (above) and eight for the length count. If there is not */ /* enough space, pad and empty the buffer */ if(i > SHA1_BLOCK_SIZE - 9) { if(i < 60) ctx->wbuf[15] = 0; sha1_compile(ctx); i = 0; } else /* compute a word index for the empty buffer positions */ i = (i >> 2) + 1; while(i < 14) /* and zero pad all but last two positions */ ctx->wbuf[i++] = 0; /* the following 32-bit length fields are assembled in the */ /* wrong byte order on little endian machines but this is */ /* corrected later since they are only ever used as 32-bit */ /* word values. */ ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29); ctx->wbuf[15] = ctx->count[0] << 3; sha1_compile(ctx); /* extract the hash value as bytes in case the hash buffer is */ /* misaligned for 32-bit words */ for(i = 0; i < SHA1_DIGEST_SIZE; ++i) hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3))); } VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len) { sha1_ctx cx[1]; sha1_begin(cx); sha1_hash(data, len, cx); sha1_end(hval, cx); } #if defined(__cplusplus) } #endif MediaInfoLib/Source/ThirdParty/base64/0000775000000000000000000000000012652076434016467 5ustar rootrootMediaInfoLib/Source/ThirdParty/base64/base64.h0000664000000000000000000001335312652076434017731 0ustar rootroot//  // // #### ### ## -= 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 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 MediaInfoLib/Source/ThirdParty/md5/0000775000000000000000000000000012652076434016070 5ustar rootrootMediaInfoLib/Source/ThirdParty/md5/md5.c0000664000000000000000000001756112652076434016733 0ustar rootroot/* * 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. * * 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. */ #include #include #if defined(__sparc__) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) #define byteReverse(buf, len) /* Nothing */ #else void byteReverse(unsigned char *buf, unsigned longs); #ifndef ASM_MD5 /* * Note: this code is harmless on little-endian machines. */ void byteReverse(unsigned char *buf, unsigned longs) { uint32_t t; do { t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); *(uint32_t *) buf = t; buf += 4; } while (--longs); } #endif #endif /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ void MD5Init(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; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) { uint32_t t; /* Update bitcount */ t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32_t) 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); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32_t *) ctx->in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32_t *) ctx->in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(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); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32_t *) 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); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ ((uint32_t *) ctx->in)[14] = ctx->bits[0]; ((uint32_t *) ctx->in)[15] = ctx->bits[1]; MD5Transform(ctx->buf, (uint32_t *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } #ifndef ASM_MD5 /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ #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. */ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) /* * 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. */ void MD5Transform(uint32_t buf[4], uint32_t const in[16]) { register uint32_t a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; 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); buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #endif MediaInfoLib/Source/ThirdParty/md5/md5.h0000664000000000000000000000102012652076434016717 0ustar rootroot#ifndef MD5_H #define MD5_H #if defined(_MSC_VER) && _MSC_VER < 1600 typedef unsigned __int32 uint32_t; #else #include #endif struct MD5Context { uint32_t buf[4]; uint32_t bits[2]; unsigned char in[64]; }; void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len); void MD5Final(unsigned char digest[16], struct MD5Context *context); void MD5Transform(uint32_t buf[4], uint32_t const in[16]); #endif /* !MD5_H */ MediaInfoLib/Source/ThirdParty/sha2-gladman/0000775000000000000000000000000012652076434017641 5ustar rootrootMediaInfoLib/Source/ThirdParty/sha2-gladman/sha2.c0000664000000000000000000006576212652076434020662 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 01/08/2005 This is a byte oriented version of SHA2 that operates on arrays of bytes stored in memory. This code implements sha256, sha384 and sha512 but the latter two functions rely on efficient 64-bit integer operations that may not be very efficient on 32-bit machines The sha256 functions use a type 'sha256_ctx' to hold details of the current hash state and uses the following three calls: void sha256_begin(sha256_ctx ctx[1]) void sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx ctx[1]) void sha_end1(unsigned char hval[], sha256_ctx ctx[1]) The first subroutine initialises a hash computation by setting up the context in the sha256_ctx context. The second subroutine hashes 8-bit bytes from array data[] into the hash state withinh sha256_ctx context, the number of bytes to be hashed being given by the the unsigned long integer len. The third subroutine completes the hash calculation and places the resulting digest value in the array of 8-bit bytes hval[]. The sha384 and sha512 functions are similar and use the interfaces: void sha384_begin(sha384_ctx ctx[1]); void sha384_hash(const unsigned char data[], unsigned long len, sha384_ctx ctx[1]); void sha384_end(unsigned char hval[], sha384_ctx ctx[1]); void sha512_begin(sha512_ctx ctx[1]); void sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx ctx[1]); void sha512_end(unsigned char hval[], sha512_ctx ctx[1]); In addition there is a function sha2 that can be used to call all these functions using a call with a hash length parameter as follows: int sha2_begin(unsigned long len, sha2_ctx ctx[1]); void sha2_hash(const unsigned char data[], unsigned long len, sha2_ctx ctx[1]); void sha2_end(unsigned char hval[], sha2_ctx ctx[1]); My thanks to Erik Andersen for testing this code on big-endian systems and for his assistance with corrections */ #if 0 #define UNROLL_SHA2 /* for SHA2 loop unroll */ #endif #include /* for memcpy() etc. */ #include "sha2.h" #include "brg_endian.h" #if defined(__cplusplus) extern "C" { #endif #if defined( _MSC_VER ) && ( _MSC_VER > 800 ) #pragma intrinsic(memcpy) #endif #if 0 && defined(_MSC_VER) #define rotl32 _lrotl #define rotr32 _lrotr #else #define rotl32(x,n) (((x) << n) | ((x) >> (32 - n))) #define rotr32(x,n) (((x) >> n) | ((x) << (32 - n))) #endif #if !defined(bswap_32) #define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00)) #endif #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) #define SWAP_BYTES #else #undef SWAP_BYTES #endif #if 0 #define ch(x,y,z) (((x) & (y)) ^ (~(x) & (z))) #define maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #else /* Thanks to Rich Schroeppel and Colin Plumb for the following */ #define ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) #define maj(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) #endif /* round transforms for SHA256 and SHA512 compression functions */ #define vf(n,i) v[(n - i) & 7] #define hf(i) (p[i & 15] += \ g_1(p[(i + 14) & 15]) + p[(i + 9) & 15] + g_0(p[(i + 1) & 15])) #define v_cycle(i,j) \ vf(7,i) += (j ? hf(i) : p[i]) + k_0[i+j] \ + s_1(vf(4,i)) + ch(vf(4,i),vf(5,i),vf(6,i)); \ vf(3,i) += vf(7,i); \ vf(7,i) += s_0(vf(0,i))+ maj(vf(0,i),vf(1,i),vf(2,i)) #if defined(SHA_224) || defined(SHA_256) #define SHA256_MASK (SHA256_BLOCK_SIZE - 1) #if defined(SWAP_BYTES) #define bsw_32(p,n) \ { int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); } #else #define bsw_32(p,n) #endif #define s_0(x) (rotr32((x), 2) ^ rotr32((x), 13) ^ rotr32((x), 22)) #define s_1(x) (rotr32((x), 6) ^ rotr32((x), 11) ^ rotr32((x), 25)) #define g_0(x) (rotr32((x), 7) ^ rotr32((x), 18) ^ ((x) >> 3)) #define g_1(x) (rotr32((x), 17) ^ rotr32((x), 19) ^ ((x) >> 10)) #define k_0 k256 /* rotated SHA256 round definition. Rather than swapping variables as in */ /* FIPS-180, different variables are 'rotated' on each round, returning */ /* to their starting positions every eight rounds */ #define q(n) v##n #define one_cycle(a,b,c,d,e,f,g,h,k,w) \ q(h) += s_1(q(e)) + ch(q(e), q(f), q(g)) + k + w; \ q(d) += q(h); q(h) += s_0(q(a)) + maj(q(a), q(b), q(c)) /* SHA256 mixing data */ const uint32_t k256[64] = { 0x428a2f98ul, 0x71374491ul, 0xb5c0fbcful, 0xe9b5dba5ul, 0x3956c25bul, 0x59f111f1ul, 0x923f82a4ul, 0xab1c5ed5ul, 0xd807aa98ul, 0x12835b01ul, 0x243185beul, 0x550c7dc3ul, 0x72be5d74ul, 0x80deb1feul, 0x9bdc06a7ul, 0xc19bf174ul, 0xe49b69c1ul, 0xefbe4786ul, 0x0fc19dc6ul, 0x240ca1ccul, 0x2de92c6ful, 0x4a7484aaul, 0x5cb0a9dcul, 0x76f988daul, 0x983e5152ul, 0xa831c66dul, 0xb00327c8ul, 0xbf597fc7ul, 0xc6e00bf3ul, 0xd5a79147ul, 0x06ca6351ul, 0x14292967ul, 0x27b70a85ul, 0x2e1b2138ul, 0x4d2c6dfcul, 0x53380d13ul, 0x650a7354ul, 0x766a0abbul, 0x81c2c92eul, 0x92722c85ul, 0xa2bfe8a1ul, 0xa81a664bul, 0xc24b8b70ul, 0xc76c51a3ul, 0xd192e819ul, 0xd6990624ul, 0xf40e3585ul, 0x106aa070ul, 0x19a4c116ul, 0x1e376c08ul, 0x2748774cul, 0x34b0bcb5ul, 0x391c0cb3ul, 0x4ed8aa4aul, 0x5b9cca4ful, 0x682e6ff3ul, 0x748f82eeul, 0x78a5636ful, 0x84c87814ul, 0x8cc70208ul, 0x90befffaul, 0xa4506cebul, 0xbef9a3f7ul, 0xc67178f2ul, }; /* Compile 64 bytes of hash data into SHA256 digest value */ /* NOTE: this routine assumes that the byte order in the */ /* ctx->wbuf[] at this point is such that low address bytes */ /* in the ORIGINAL byte stream will go into the high end of */ /* words on BOTH big and little endian systems */ VOID_RETURN sha256_compile(sha256_ctx ctx[1]) { #if !defined(UNROLL_SHA2) uint32_t j, *p = ctx->wbuf, v[8]; memcpy(v, ctx->hash, 8 * sizeof(uint32_t)); for(j = 0; j < 64; j += 16) { v_cycle( 0, j); v_cycle( 1, j); v_cycle( 2, j); v_cycle( 3, j); v_cycle( 4, j); v_cycle( 5, j); v_cycle( 6, j); v_cycle( 7, j); v_cycle( 8, j); v_cycle( 9, j); v_cycle(10, j); v_cycle(11, j); v_cycle(12, j); v_cycle(13, j); v_cycle(14, j); v_cycle(15, j); } ctx->hash[0] += v[0]; ctx->hash[1] += v[1]; ctx->hash[2] += v[2]; ctx->hash[3] += v[3]; ctx->hash[4] += v[4]; ctx->hash[5] += v[5]; ctx->hash[6] += v[6]; ctx->hash[7] += v[7]; #else uint32_t *p = ctx->wbuf,v0,v1,v2,v3,v4,v5,v6,v7; v0 = ctx->hash[0]; v1 = ctx->hash[1]; v2 = ctx->hash[2]; v3 = ctx->hash[3]; v4 = ctx->hash[4]; v5 = ctx->hash[5]; v6 = ctx->hash[6]; v7 = ctx->hash[7]; one_cycle(0,1,2,3,4,5,6,7,k256[ 0],p[ 0]); one_cycle(7,0,1,2,3,4,5,6,k256[ 1],p[ 1]); one_cycle(6,7,0,1,2,3,4,5,k256[ 2],p[ 2]); one_cycle(5,6,7,0,1,2,3,4,k256[ 3],p[ 3]); one_cycle(4,5,6,7,0,1,2,3,k256[ 4],p[ 4]); one_cycle(3,4,5,6,7,0,1,2,k256[ 5],p[ 5]); one_cycle(2,3,4,5,6,7,0,1,k256[ 6],p[ 6]); one_cycle(1,2,3,4,5,6,7,0,k256[ 7],p[ 7]); one_cycle(0,1,2,3,4,5,6,7,k256[ 8],p[ 8]); one_cycle(7,0,1,2,3,4,5,6,k256[ 9],p[ 9]); one_cycle(6,7,0,1,2,3,4,5,k256[10],p[10]); one_cycle(5,6,7,0,1,2,3,4,k256[11],p[11]); one_cycle(4,5,6,7,0,1,2,3,k256[12],p[12]); one_cycle(3,4,5,6,7,0,1,2,k256[13],p[13]); one_cycle(2,3,4,5,6,7,0,1,k256[14],p[14]); one_cycle(1,2,3,4,5,6,7,0,k256[15],p[15]); one_cycle(0,1,2,3,4,5,6,7,k256[16],hf( 0)); one_cycle(7,0,1,2,3,4,5,6,k256[17],hf( 1)); one_cycle(6,7,0,1,2,3,4,5,k256[18],hf( 2)); one_cycle(5,6,7,0,1,2,3,4,k256[19],hf( 3)); one_cycle(4,5,6,7,0,1,2,3,k256[20],hf( 4)); one_cycle(3,4,5,6,7,0,1,2,k256[21],hf( 5)); one_cycle(2,3,4,5,6,7,0,1,k256[22],hf( 6)); one_cycle(1,2,3,4,5,6,7,0,k256[23],hf( 7)); one_cycle(0,1,2,3,4,5,6,7,k256[24],hf( 8)); one_cycle(7,0,1,2,3,4,5,6,k256[25],hf( 9)); one_cycle(6,7,0,1,2,3,4,5,k256[26],hf(10)); one_cycle(5,6,7,0,1,2,3,4,k256[27],hf(11)); one_cycle(4,5,6,7,0,1,2,3,k256[28],hf(12)); one_cycle(3,4,5,6,7,0,1,2,k256[29],hf(13)); one_cycle(2,3,4,5,6,7,0,1,k256[30],hf(14)); one_cycle(1,2,3,4,5,6,7,0,k256[31],hf(15)); one_cycle(0,1,2,3,4,5,6,7,k256[32],hf( 0)); one_cycle(7,0,1,2,3,4,5,6,k256[33],hf( 1)); one_cycle(6,7,0,1,2,3,4,5,k256[34],hf( 2)); one_cycle(5,6,7,0,1,2,3,4,k256[35],hf( 3)); one_cycle(4,5,6,7,0,1,2,3,k256[36],hf( 4)); one_cycle(3,4,5,6,7,0,1,2,k256[37],hf( 5)); one_cycle(2,3,4,5,6,7,0,1,k256[38],hf( 6)); one_cycle(1,2,3,4,5,6,7,0,k256[39],hf( 7)); one_cycle(0,1,2,3,4,5,6,7,k256[40],hf( 8)); one_cycle(7,0,1,2,3,4,5,6,k256[41],hf( 9)); one_cycle(6,7,0,1,2,3,4,5,k256[42],hf(10)); one_cycle(5,6,7,0,1,2,3,4,k256[43],hf(11)); one_cycle(4,5,6,7,0,1,2,3,k256[44],hf(12)); one_cycle(3,4,5,6,7,0,1,2,k256[45],hf(13)); one_cycle(2,3,4,5,6,7,0,1,k256[46],hf(14)); one_cycle(1,2,3,4,5,6,7,0,k256[47],hf(15)); one_cycle(0,1,2,3,4,5,6,7,k256[48],hf( 0)); one_cycle(7,0,1,2,3,4,5,6,k256[49],hf( 1)); one_cycle(6,7,0,1,2,3,4,5,k256[50],hf( 2)); one_cycle(5,6,7,0,1,2,3,4,k256[51],hf( 3)); one_cycle(4,5,6,7,0,1,2,3,k256[52],hf( 4)); one_cycle(3,4,5,6,7,0,1,2,k256[53],hf( 5)); one_cycle(2,3,4,5,6,7,0,1,k256[54],hf( 6)); one_cycle(1,2,3,4,5,6,7,0,k256[55],hf( 7)); one_cycle(0,1,2,3,4,5,6,7,k256[56],hf( 8)); one_cycle(7,0,1,2,3,4,5,6,k256[57],hf( 9)); one_cycle(6,7,0,1,2,3,4,5,k256[58],hf(10)); one_cycle(5,6,7,0,1,2,3,4,k256[59],hf(11)); one_cycle(4,5,6,7,0,1,2,3,k256[60],hf(12)); one_cycle(3,4,5,6,7,0,1,2,k256[61],hf(13)); one_cycle(2,3,4,5,6,7,0,1,k256[62],hf(14)); one_cycle(1,2,3,4,5,6,7,0,k256[63],hf(15)); ctx->hash[0] += v0; ctx->hash[1] += v1; ctx->hash[2] += v2; ctx->hash[3] += v3; ctx->hash[4] += v4; ctx->hash[5] += v5; ctx->hash[6] += v6; ctx->hash[7] += v7; #endif } /* SHA256 hash data in an array of bytes into hash buffer */ /* and call the hash_compile function as required. */ VOID_RETURN sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx ctx[1]) { uint32_t pos = (uint32_t)(ctx->count[0] & SHA256_MASK), space = SHA256_BLOCK_SIZE - pos; const unsigned char *sp = data; if((ctx->count[0] += len) < len) ++(ctx->count[1]); while(len >= space) /* tranfer whole blocks while possible */ { memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space); sp += space; len -= space; space = SHA256_BLOCK_SIZE; pos = 0; bsw_32(ctx->wbuf, SHA256_BLOCK_SIZE >> 2) sha256_compile(ctx); } memcpy(((unsigned char*)ctx->wbuf) + pos, sp, len); } /* SHA256 Final padding and digest calculation */ static void sha_end1(unsigned char hval[], sha256_ctx ctx[1], const unsigned int hlen) { uint32_t i = (uint32_t)(ctx->count[0] & SHA256_MASK); /* put bytes in the buffer in an order in which references to */ /* 32-bit words will put bytes with lower addresses into the */ /* top of 32 bit words on BOTH big and little endian machines */ bsw_32(ctx->wbuf, (i + 3) >> 2) /* we now need to mask valid bytes and add the padding which is */ /* a single 1 bit and as many zero bits as necessary. Note that */ /* we can always add the first padding byte here because the */ /* buffer always has at least one empty slot */ ctx->wbuf[i >> 2] &= 0xffffff80 << 8 * (~i & 3); ctx->wbuf[i >> 2] |= 0x00000080 << 8 * (~i & 3); /* we need 9 or more empty positions, one for the padding byte */ /* (above) and eight for the length count. If there is not */ /* enough space pad and empty the buffer */ if(i > SHA256_BLOCK_SIZE - 9) { if(i < 60) ctx->wbuf[15] = 0; sha256_compile(ctx); i = 0; } else /* compute a word index for the empty buffer positions */ i = (i >> 2) + 1; while(i < 14) /* and zero pad all but last two positions */ ctx->wbuf[i++] = 0; /* the following 32-bit length fields are assembled in the */ /* wrong byte order on little endian machines but this is */ /* corrected later since they are only ever used as 32-bit */ /* word values. */ ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29); ctx->wbuf[15] = ctx->count[0] << 3; sha256_compile(ctx); /* extract the hash value as bytes in case the hash buffer is */ /* mislaigned for 32-bit words */ for(i = 0; i < hlen; ++i) hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3))); } #endif #if defined(SHA_224) const uint32_t i224[8] = { 0xc1059ed8ul, 0x367cd507ul, 0x3070dd17ul, 0xf70e5939ul, 0xffc00b31ul, 0x68581511ul, 0x64f98fa7ul, 0xbefa4fa4ul }; VOID_RETURN sha224_begin(sha224_ctx ctx[1]) { ctx->count[0] = ctx->count[1] = 0; memcpy(ctx->hash, i224, 8 * sizeof(uint32_t)); } VOID_RETURN sha224_end(unsigned char hval[], sha224_ctx ctx[1]) { sha_end1(hval, ctx, SHA224_DIGEST_SIZE); } VOID_RETURN sha224(unsigned char hval[], const unsigned char data[], unsigned long len) { sha224_ctx cx[1]; sha224_begin(cx); sha224_hash(data, len, cx); sha_end1(hval, cx, SHA224_DIGEST_SIZE); } #endif #if defined(SHA_256) const uint32_t i256[8] = { 0x6a09e667ul, 0xbb67ae85ul, 0x3c6ef372ul, 0xa54ff53aul, 0x510e527ful, 0x9b05688cul, 0x1f83d9abul, 0x5be0cd19ul }; VOID_RETURN sha256_begin(sha256_ctx ctx[1]) { ctx->count[0] = ctx->count[1] = 0; memcpy(ctx->hash, i256, 8 * sizeof(uint32_t)); } VOID_RETURN sha256_end(unsigned char hval[], sha256_ctx ctx[1]) { sha_end1(hval, ctx, SHA256_DIGEST_SIZE); } VOID_RETURN sha256(unsigned char hval[], const unsigned char data[], unsigned long len) { sha256_ctx cx[1]; sha256_begin(cx); sha256_hash(data, len, cx); sha_end1(hval, cx, SHA256_DIGEST_SIZE); } #endif #if defined(SHA_384) || defined(SHA_512) #define SHA512_MASK (SHA512_BLOCK_SIZE - 1) #define rotr64(x,n) (((x) >> n) | ((x) << (64 - n))) #if !defined(bswap_64) #define bswap_64(x) (((uint64_t)(bswap_32((uint32_t)(x)))) << 32 | bswap_32((uint32_t)((x) >> 32))) #endif #if defined(SWAP_BYTES) #define bsw_64(p,n) \ { int _i = (n); while(_i--) ((uint64_t*)p)[_i] = bswap_64(((uint64_t*)p)[_i]); } #else #define bsw_64(p,n) #endif /* SHA512 mixing function definitions */ #ifdef s_0 # undef s_0 # undef s_1 # undef g_0 # undef g_1 # undef k_0 #endif #define s_0(x) (rotr64((x), 28) ^ rotr64((x), 34) ^ rotr64((x), 39)) #define s_1(x) (rotr64((x), 14) ^ rotr64((x), 18) ^ rotr64((x), 41)) #define g_0(x) (rotr64((x), 1) ^ rotr64((x), 8) ^ ((x) >> 7)) #define g_1(x) (rotr64((x), 19) ^ rotr64((x), 61) ^ ((x) >> 6)) #define k_0 k512 /* SHA384/SHA512 mixing data */ const uint64_t k512[80] = { li_64(428a2f98d728ae22), li_64(7137449123ef65cd), li_64(b5c0fbcfec4d3b2f), li_64(e9b5dba58189dbbc), li_64(3956c25bf348b538), li_64(59f111f1b605d019), li_64(923f82a4af194f9b), li_64(ab1c5ed5da6d8118), li_64(d807aa98a3030242), li_64(12835b0145706fbe), li_64(243185be4ee4b28c), li_64(550c7dc3d5ffb4e2), li_64(72be5d74f27b896f), li_64(80deb1fe3b1696b1), li_64(9bdc06a725c71235), li_64(c19bf174cf692694), li_64(e49b69c19ef14ad2), li_64(efbe4786384f25e3), li_64(0fc19dc68b8cd5b5), li_64(240ca1cc77ac9c65), li_64(2de92c6f592b0275), li_64(4a7484aa6ea6e483), li_64(5cb0a9dcbd41fbd4), li_64(76f988da831153b5), li_64(983e5152ee66dfab), li_64(a831c66d2db43210), li_64(b00327c898fb213f), li_64(bf597fc7beef0ee4), li_64(c6e00bf33da88fc2), li_64(d5a79147930aa725), li_64(06ca6351e003826f), li_64(142929670a0e6e70), li_64(27b70a8546d22ffc), li_64(2e1b21385c26c926), li_64(4d2c6dfc5ac42aed), li_64(53380d139d95b3df), li_64(650a73548baf63de), li_64(766a0abb3c77b2a8), li_64(81c2c92e47edaee6), li_64(92722c851482353b), li_64(a2bfe8a14cf10364), li_64(a81a664bbc423001), li_64(c24b8b70d0f89791), li_64(c76c51a30654be30), li_64(d192e819d6ef5218), li_64(d69906245565a910), li_64(f40e35855771202a), li_64(106aa07032bbd1b8), li_64(19a4c116b8d2d0c8), li_64(1e376c085141ab53), li_64(2748774cdf8eeb99), li_64(34b0bcb5e19b48a8), li_64(391c0cb3c5c95a63), li_64(4ed8aa4ae3418acb), li_64(5b9cca4f7763e373), li_64(682e6ff3d6b2b8a3), li_64(748f82ee5defb2fc), li_64(78a5636f43172f60), li_64(84c87814a1f0ab72), li_64(8cc702081a6439ec), li_64(90befffa23631e28), li_64(a4506cebde82bde9), li_64(bef9a3f7b2c67915), li_64(c67178f2e372532b), li_64(ca273eceea26619c), li_64(d186b8c721c0c207), li_64(eada7dd6cde0eb1e), li_64(f57d4f7fee6ed178), li_64(06f067aa72176fba), li_64(0a637dc5a2c898a6), li_64(113f9804bef90dae), li_64(1b710b35131c471b), li_64(28db77f523047d84), li_64(32caab7b40c72493), li_64(3c9ebe0a15c9bebc), li_64(431d67c49c100d4c), li_64(4cc5d4becb3e42b6), li_64(597f299cfc657e2a), li_64(5fcb6fab3ad6faec), li_64(6c44198c4a475817) }; /* Compile 128 bytes of hash data into SHA384/512 digest */ /* NOTE: this routine assumes that the byte order in the */ /* ctx->wbuf[] at this point is such that low address bytes */ /* in the ORIGINAL byte stream will go into the high end of */ /* words on BOTH big and little endian systems */ VOID_RETURN sha512_compile(sha512_ctx ctx[1]) { uint64_t v[8], *p = ctx->wbuf; uint32_t j; memcpy(v, ctx->hash, 8 * sizeof(uint64_t)); for(j = 0; j < 80; j += 16) { v_cycle( 0, j); v_cycle( 1, j); v_cycle( 2, j); v_cycle( 3, j); v_cycle( 4, j); v_cycle( 5, j); v_cycle( 6, j); v_cycle( 7, j); v_cycle( 8, j); v_cycle( 9, j); v_cycle(10, j); v_cycle(11, j); v_cycle(12, j); v_cycle(13, j); v_cycle(14, j); v_cycle(15, j); } ctx->hash[0] += v[0]; ctx->hash[1] += v[1]; ctx->hash[2] += v[2]; ctx->hash[3] += v[3]; ctx->hash[4] += v[4]; ctx->hash[5] += v[5]; ctx->hash[6] += v[6]; ctx->hash[7] += v[7]; } /* Compile 128 bytes of hash data into SHA256 digest value */ /* NOTE: this routine assumes that the byte order in the */ /* ctx->wbuf[] at this point is in such an order that low */ /* address bytes in the ORIGINAL byte stream placed in this */ /* buffer will now go to the high end of words on BOTH big */ /* and little endian systems */ VOID_RETURN sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx ctx[1]) { uint32_t pos = (uint32_t)(ctx->count[0] & SHA512_MASK), space = SHA512_BLOCK_SIZE - pos; const unsigned char *sp = data; if((ctx->count[0] += len) < len) ++(ctx->count[1]); while(len >= space) /* tranfer whole blocks while possible */ { memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space); sp += space; len -= space; space = SHA512_BLOCK_SIZE; pos = 0; bsw_64(ctx->wbuf, SHA512_BLOCK_SIZE >> 3); sha512_compile(ctx); } memcpy(((unsigned char*)ctx->wbuf) + pos, sp, len); } /* SHA384/512 Final padding and digest calculation */ static void sha_end2(unsigned char hval[], sha512_ctx ctx[1], const unsigned int hlen) { uint32_t i = (uint32_t)(ctx->count[0] & SHA512_MASK); /* put bytes in the buffer in an order in which references to */ /* 32-bit words will put bytes with lower addresses into the */ /* top of 32 bit words on BOTH big and little endian machines */ bsw_64(ctx->wbuf, (i + 7) >> 3); /* we now need to mask valid bytes and add the padding which is */ /* a single 1 bit and as many zero bits as necessary. Note that */ /* we can always add the first padding byte here because the */ /* buffer always has at least one empty slot */ ctx->wbuf[i >> 3] &= li_64(ffffffffffffff00) << 8 * (~i & 7); ctx->wbuf[i >> 3] |= li_64(0000000000000080) << 8 * (~i & 7); /* we need 17 or more empty byte positions, one for the padding */ /* byte (above) and sixteen for the length count. If there is */ /* not enough space pad and empty the buffer */ if(i > SHA512_BLOCK_SIZE - 17) { if(i < 120) ctx->wbuf[15] = 0; sha512_compile(ctx); i = 0; } else i = (i >> 3) + 1; while(i < 14) ctx->wbuf[i++] = 0; /* the following 64-bit length fields are assembled in the */ /* wrong byte order on little endian machines but this is */ /* corrected later since they are only ever used as 64-bit */ /* word values. */ ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 61); ctx->wbuf[15] = ctx->count[0] << 3; sha512_compile(ctx); /* extract the hash value as bytes in case the hash buffer is */ /* misaligned for 32-bit words */ for(i = 0; i < hlen; ++i) hval[i] = (unsigned char)(ctx->hash[i >> 3] >> (8 * (~i & 7))); } #endif #if defined(SHA_384) /* SHA384 initialisation data */ const uint64_t i384[80] = { li_64(cbbb9d5dc1059ed8), li_64(629a292a367cd507), li_64(9159015a3070dd17), li_64(152fecd8f70e5939), li_64(67332667ffc00b31), li_64(8eb44a8768581511), li_64(db0c2e0d64f98fa7), li_64(47b5481dbefa4fa4) }; VOID_RETURN sha384_begin(sha384_ctx ctx[1]) { ctx->count[0] = ctx->count[1] = 0; memcpy(ctx->hash, i384, 8 * sizeof(uint64_t)); } VOID_RETURN sha384_end(unsigned char hval[], sha384_ctx ctx[1]) { sha_end2(hval, ctx, SHA384_DIGEST_SIZE); } VOID_RETURN sha384(unsigned char hval[], const unsigned char data[], unsigned long len) { sha384_ctx cx[1]; sha384_begin(cx); sha384_hash(data, len, cx); sha_end2(hval, cx, SHA384_DIGEST_SIZE); } #endif #if defined(SHA_512) /* SHA512 initialisation data */ const uint64_t i512[80] = { li_64(6a09e667f3bcc908), li_64(bb67ae8584caa73b), li_64(3c6ef372fe94f82b), li_64(a54ff53a5f1d36f1), li_64(510e527fade682d1), li_64(9b05688c2b3e6c1f), li_64(1f83d9abfb41bd6b), li_64(5be0cd19137e2179) }; VOID_RETURN sha512_begin(sha512_ctx ctx[1]) { ctx->count[0] = ctx->count[1] = 0; memcpy(ctx->hash, i512, 8 * sizeof(uint64_t)); } VOID_RETURN sha512_end(unsigned char hval[], sha512_ctx ctx[1]) { sha_end2(hval, ctx, SHA512_DIGEST_SIZE); } VOID_RETURN sha512(unsigned char hval[], const unsigned char data[], unsigned long len) { sha512_ctx cx[1]; sha512_begin(cx); sha512_hash(data, len, cx); sha_end2(hval, cx, SHA512_DIGEST_SIZE); } #endif #if defined(SHA_2) #define CTX_224(x) ((x)->uu->ctx256) #define CTX_256(x) ((x)->uu->ctx256) #define CTX_384(x) ((x)->uu->ctx512) #define CTX_512(x) ((x)->uu->ctx512) /* SHA2 initialisation */ INT_RETURN sha2_begin(unsigned long len, sha2_ctx ctx[1]) { switch(len) { #if defined(SHA_224) case 224: case 28: CTX_256(ctx)->count[0] = CTX_256(ctx)->count[1] = 0; memcpy(CTX_256(ctx)->hash, i224, 32); ctx->sha2_len = 28; return EXIT_SUCCESS; #endif #if defined(SHA_256) case 256: case 32: CTX_256(ctx)->count[0] = CTX_256(ctx)->count[1] = 0; memcpy(CTX_256(ctx)->hash, i256, 32); ctx->sha2_len = 32; return EXIT_SUCCESS; #endif #if defined(SHA_384) case 384: case 48: CTX_384(ctx)->count[0] = CTX_384(ctx)->count[1] = 0; memcpy(CTX_384(ctx)->hash, i384, 64); ctx->sha2_len = 48; return EXIT_SUCCESS; #endif #if defined(SHA_512) case 512: case 64: CTX_512(ctx)->count[0] = CTX_512(ctx)->count[1] = 0; memcpy(CTX_512(ctx)->hash, i512, 64); ctx->sha2_len = 64; return EXIT_SUCCESS; #endif default: return EXIT_FAILURE; } } VOID_RETURN sha2_hash(const unsigned char data[], unsigned long len, sha2_ctx ctx[1]) { switch(ctx->sha2_len) { #if defined(SHA_224) case 28: sha224_hash(data, len, CTX_224(ctx)); return; #endif #if defined(SHA_256) case 32: sha256_hash(data, len, CTX_256(ctx)); return; #endif #if defined(SHA_384) case 48: sha384_hash(data, len, CTX_384(ctx)); return; #endif #if defined(SHA_512) case 64: sha512_hash(data, len, CTX_512(ctx)); return; #endif } } VOID_RETURN sha2_end(unsigned char hval[], sha2_ctx ctx[1]) { switch(ctx->sha2_len) { #if defined(SHA_224) case 28: sha_end1(hval, CTX_224(ctx), SHA224_DIGEST_SIZE); return; #endif #if defined(SHA_256) case 32: sha_end1(hval, CTX_256(ctx), SHA256_DIGEST_SIZE); return; #endif #if defined(SHA_384) case 48: sha_end2(hval, CTX_384(ctx), SHA384_DIGEST_SIZE); return; #endif #if defined(SHA_512) case 64: sha_end2(hval, CTX_512(ctx), SHA512_DIGEST_SIZE); return; #endif } } INT_RETURN sha2(unsigned char hval[], unsigned long size, const unsigned char data[], unsigned long len) { sha2_ctx cx[1]; if(sha2_begin(size, cx) == EXIT_SUCCESS) { sha2_hash(data, len, cx); sha2_end(hval, cx); return EXIT_SUCCESS; } else return EXIT_FAILURE; } #endif #if defined(__cplusplus) } #endif MediaInfoLib/Source/ThirdParty/sha2-gladman/shasum.c0000664000000000000000000000202512652076434021304 0ustar rootroot #include #include #include #include "sha2.h" #define BUF_SIZE 16384 int main(int argc, char *argv[]) { FILE *inf; sha256_ctx ctx[1]; unsigned char buf[BUF_SIZE], hval[SHA256_DIGEST_SIZE]; int i, len, is_console; if(argc != 2) { printf("\nusage: shasum filename\n"); exit(0); } if(is_console = (!strcmp(argv[1], "con") || !strcmp(argv[1], "CON"))) { if(!(inf = fopen(argv[1], "r"))) { printf("\n%s not found\n", argv[1]); exit(0); } } else if(!(inf = fopen(argv[1], "rb"))) { printf("\n%s not found\n", argv[1]); exit(0); } sha256_begin(ctx); do { len = (int)fread(buf, 1, BUF_SIZE, inf); i = len; if(is_console) { i = 0; while(i < len && buf[i] != '\x1a') ++i; } if(i) sha256_hash(buf, i, ctx); } while (len && i == len); fclose(inf); sha256_end(hval, ctx); printf("\n"); for(i = 0; i < SHA256_DIGEST_SIZE; ++i) printf("%02x", hval[i]); printf("\n"); return 0; } MediaInfoLib/Source/ThirdParty/sha2-gladman/sha2.h0000664000000000000000000001110612652076434020646 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 01/08/2005 */ #ifndef _SHA2_H #define _SHA2_H #include #define SHA_64BIT /* define the hash functions that you need */ #define SHA_2 /* for dynamic hash length */ #define SHA_224 #define SHA_256 #ifdef SHA_64BIT # define SHA_384 # define SHA_512 # define NEED_UINT_64T #endif #include "brg_types.h" #if defined(__cplusplus) extern "C" { #endif /* Note that the following function prototypes are the same */ /* for both the bit and byte oriented implementations. But */ /* the length fields are in bytes or bits as is appropriate */ /* for the version used. Bit sequences are arrays of bytes */ /* in which bit sequence indexes increase from the most to */ /* the least significant end of each byte */ #define SHA224_DIGEST_SIZE 28 #define SHA224_BLOCK_SIZE 64 #define SHA256_DIGEST_SIZE 32 #define SHA256_BLOCK_SIZE 64 /* type to hold the SHA256 (and SHA224) context */ typedef struct { uint32_t count[2]; uint32_t hash[8]; uint32_t wbuf[16]; } sha256_ctx; typedef sha256_ctx sha224_ctx; VOID_RETURN sha256_compile(sha256_ctx ctx[1]); VOID_RETURN sha224_begin(sha224_ctx ctx[1]); #define sha224_hash sha256_hash VOID_RETURN sha224_end(unsigned char hval[], sha224_ctx ctx[1]); VOID_RETURN sha224(unsigned char hval[], const unsigned char data[], unsigned long len); VOID_RETURN sha256_begin(sha256_ctx ctx[1]); VOID_RETURN sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx ctx[1]); VOID_RETURN sha256_end(unsigned char hval[], sha256_ctx ctx[1]); VOID_RETURN sha256(unsigned char hval[], const unsigned char data[], unsigned long len); #ifndef SHA_64BIT typedef struct { union { sha256_ctx ctx256[1]; } uu[1]; uint32_t sha2_len; } sha2_ctx; #define SHA2_MAX_DIGEST_SIZE SHA256_DIGEST_SIZE #else #define SHA384_DIGEST_SIZE 48 #define SHA384_BLOCK_SIZE 128 #define SHA512_DIGEST_SIZE 64 #define SHA512_BLOCK_SIZE 128 #define SHA2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE /* type to hold the SHA384 (and SHA512) context */ typedef struct { uint64_t count[2]; uint64_t hash[8]; uint64_t wbuf[16]; } sha512_ctx; typedef sha512_ctx sha384_ctx; typedef struct { union { sha256_ctx ctx256[1]; sha512_ctx ctx512[1]; } uu[1]; uint32_t sha2_len; } sha2_ctx; VOID_RETURN sha512_compile(sha512_ctx ctx[1]); VOID_RETURN sha384_begin(sha384_ctx ctx[1]); #define sha384_hash sha512_hash VOID_RETURN sha384_end(unsigned char hval[], sha384_ctx ctx[1]); VOID_RETURN sha384(unsigned char hval[], const unsigned char data[], unsigned long len); VOID_RETURN sha512_begin(sha512_ctx ctx[1]); VOID_RETURN sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx ctx[1]); VOID_RETURN sha512_end(unsigned char hval[], sha512_ctx ctx[1]); VOID_RETURN sha512(unsigned char hval[], const unsigned char data[], unsigned long len); INT_RETURN sha2_begin(unsigned long size, sha2_ctx ctx[1]); VOID_RETURN sha2_hash(const unsigned char data[], unsigned long len, sha2_ctx ctx[1]); VOID_RETURN sha2_end(unsigned char hval[], sha2_ctx ctx[1]); INT_RETURN sha2(unsigned char hval[], unsigned long size, const unsigned char data[], unsigned long len); #endif #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/tinyxml2/0000775000000000000000000000000012652076434017171 5ustar rootrootMediaInfoLib/Source/ThirdParty/tinyxml2/tinyxml2.cpp0000664000000000000000000015370012652076434021471 0ustar rootroot/* 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" #include // yes, this one new style header, is in the Android SDK. # ifdef ANDROID_NDK # include #else # include #endif 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 ); \ } \ } namespace tinyxml2 { 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; _flags = flags | NEEDS_DELETE; } char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) { TIXMLASSERT( endTag && *endTag ); char* start = p; char endChar = *endTag; size_t 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; } while( *p && ( p == start ? XMLUtil::IsNameStartChar( *p ) : XMLUtil::IsNameChar( *p ) )) { ++p; } if ( p > start ) { Set( start, p, 0 ); return p; } return 0; } void StrPair::CollapseWhitespace() { // Adjusting _start would cause undefined behavior on delete[] TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); // Trim leading space. _start = XMLUtil::SkipWhiteSpace( _start ); if ( _start && *_start ) { char* p = _start; // the read pointer char* q = _start; // the write pointer while( *p ) { if ( XMLUtil::IsWhiteSpace( *p )) { p = XMLUtil::SkipWhiteSpace( p ); if ( *p == 0 ) { break; // don't write to q; this trims the trailing space. } *q = ' '; ++q; } *q = *p; ++q; ++p; } *q = 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 == '&' ) { // Entities handled by tinyXML2: // - special entities in the entity table [in/out] // - numeric character reference [in] // 中 or 中 if ( *(p+1) == '#' ) { const int buflen = 10; char buf[buflen] = { 0 }; int len = 0; p = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); TIXMLASSERT( 0 <= len && len <= buflen ); TIXMLASSERT( q + len <= p ); memcpy( q, buf, len ); q += len; } else { int i=0; for(; i(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; // This code won't covert this correctly anyway. return; } 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]); default: break; } } 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; ptrdiff_t 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; } void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); } void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); } void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); } /* ToStr() of a number is a very tricky topic. https://github.com/leethomason/tinyxml2/issues/106 */ void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); } void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); } bool XMLUtil::ToInt( const char* str, int* value ) { if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { return true; } return false; } bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) { if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { return true; } return false; } bool XMLUtil::ToBool( const char* str, bool* value ) { int ival = 0; if ( ToInt( str, &ival )) { *value = (ival==0) ? false : true; return true; } if ( StringEqual( str, "true" ) ) { *value = true; return true; } else if ( StringEqual( str, "false" ) ) { *value = false; return true; } return false; } bool XMLUtil::ToFloat( const char* str, float* value ) { if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { return true; } return false; } bool XMLUtil::ToDouble( const char* str, double* value ) { if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { return true; } return false; } 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? // These strings define the matching patters: static const char* xmlHeader = { "_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 ), _memPool( 0 ) { } XMLNode::~XMLNode() { DeleteChildren(); if ( _parent ) { _parent->Unlink( this ); } } const char* XMLNode::Value() const { return _value.GetStr(); } 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 ) { 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 (addThis->_document != _document) return 0; if (addThis->_parent) addThis->_parent->Unlink( addThis ); else addThis->_memPool->SetTracked(); 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 (addThis->_document != _document) return 0; if (addThis->_parent) addThis->_parent->Unlink( addThis ); else addThis->_memPool->SetTracked(); 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 ) { if (addThis->_document != _document) return 0; TIXMLASSERT( afterThis->_parent == this ); if ( afterThis->_parent != this ) { return 0; } if ( afterThis->_next == 0 ) { // The last node or the only node. return InsertEndChild( addThis ); } if (addThis->_parent) addThis->_parent->Unlink( addThis ); else addThis->_memPool->SetTracked(); 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* node=this->_next; node; node = node->_next ) { const XMLElement* element = node->ToElement(); if ( element && (!value || XMLUtil::StringEqual( value, node->Value() ))) { return element; } } return 0; } const XMLElement* XMLNode::PreviousSiblingElement( const char* value ) const { for( XMLNode* node=_prev; node; node = node->_prev ) { const XMLElement* element = node->ToElement(); if ( element && (!value || XMLUtil::StringEqual( value, node->Value() ))) { return element; } } 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: // // // // With a special case: // // // // // 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; } XMLElement* ele = node->ToElement(); // We read the end tag. Return it to the parent. if ( ele && ele->ClosingType() == XMLElement::CLOSING ) { if ( parentEnd ) { *parentEnd = static_cast(node)->_value; } node->_memPool->SetTracked(); // created and then immediately deleted. DELETE_NODE( node ); return p; } // Handle an end tag returned to this level. // And handle a bunch of annoying errors. 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 { int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { flags |= StrPair::COLLAPSE_WHITESPACE; } p = _value.ParseText( p, "<", flags ); 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() { } 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 { const XMLComment* comment = compare->ToComment(); return ( comment && XMLUtil::StringEqual( comment->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 { const XMLDeclaration* declaration = compare->ToDeclaration(); return ( declaration && XMLUtil::StringEqual( declaration->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 { const XMLUnknown* unknown = compare->ToUnknown(); return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() )); } bool XMLUnknown::Accept( XMLVisitor* visitor ) const { return visitor->Visit( *this ); } // --------- XMLAttribute ---------- // const char* XMLAttribute::Name() const { return _name.GetStr(); } const char* XMLAttribute::Value() const { return _value.GetStr(); } char* XMLAttribute::ParseDeep( char* p, bool processEntities ) { // Parse using the name rules: bug fix, was using ParseText before p = _name.ParseName( p ); if ( !p || !*p ) { return 0; } // Skip white space before = p = XMLUtil::SkipWhiteSpace( p ); if ( !p || *p != '=' ) { return 0; } ++p; // move up to opening quote p = XMLUtil::SkipWhiteSpace( p ); if ( *p != '\"' && *p != '\'' ) { return 0; } char endTag[2] = { *p, 0 }; ++p; // move past opening quote p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES ); return p; } void XMLAttribute::SetName( const char* n ) { _name.SetStr( n ); } XMLError XMLAttribute::QueryIntValue( int* value ) const { if ( XMLUtil::ToInt( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const { if ( XMLUtil::ToUnsigned( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryBoolValue( bool* value ) const { if ( XMLUtil::ToBool( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryFloatValue( float* value ) const { if ( XMLUtil::ToFloat( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryDoubleValue( double* value ) const { if ( XMLUtil::ToDouble( Value(), value )) { 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]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( unsigned v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( bool v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( double v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( float v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _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; } void XMLElement::SetText( const char* inText ) { if ( FirstChild() && FirstChild()->ToText() ) FirstChild()->SetValue( inText ); else { XMLText* theText = GetDocument()->NewText( inText ); InsertFirstChild( theText ); } } void XMLElement::SetText( int v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); SetText( buf ); } void XMLElement::SetText( unsigned v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); SetText( buf ); } void XMLElement::SetText( bool v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); SetText( buf ); } void XMLElement::SetText( float v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); SetText( buf ); } void XMLElement::SetText( double v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); SetText( buf ); } XMLError XMLElement::QueryIntText( int* ival ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToInt( t, ival ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToUnsigned( t, uval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryBoolText( bool* bval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToBool( t, bval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryDoubleText( double* dval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToDouble( t, dval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryFloatText( float* fval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToFloat( t, fval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) { XMLAttribute* last = 0; XMLAttribute* attrib = 0; for( attrib = _rootAttribute; attrib; last = attrib, attrib = attrib->_next ) { if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { break; } } if ( !attrib ) { attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); attrib->_memPool = &_document->_attributePool; if ( last ) { last->_next = attrib; } else { _rootAttribute = attrib; } attrib->SetName( name ); attrib->_memPool->SetTracked(); // always created and linked. } return 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; XMLAttribute* prevAttribute = 0; // 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::IsNameStartChar( *p ) ) { XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); attrib->_memPool = &_document->_attributePool; attrib->_memPool->SetTracked(); p = attrib->ParseDeep( p, _document->ProcessEntities() ); if ( !p || Attribute( attrib->Name() ) ) { DELETE_ATTRIBUTE( attrib ); _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); return 0; } // There is a minor bug here: if the attribute in the source xml // document is duplicated, it will not be detected and the // attribute will be doubly added. However, tracking the 'prevAttribute' // avoids re-scanning the attribute list. Preferring performance for // now, may reconsider in the future. if ( prevAttribute ) { prevAttribute->_next = attrib; } else { _rootAttribute = attrib; } prevAttribute = 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; } // // // foobar // char* XMLElement::ParseDeep( char* p, StrPair* strPair ) { // Read the element name. p = XMLUtil::SkipWhiteSpace( p ); if ( !p ) { return 0; } // The closing element is the 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; } a = a->Next(); b = b->Next(); } 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, Whitespace whitespace ) : XMLNode( 0 ), _writeBOM( false ), _processEntities( processEntities ), _errorID( XML_NO_ERROR ), _whitespace( whitespace ), _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 #ifdef DEBUG if ( Error() == false ) { TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); } #endif } void XMLDocument::Clear() { DeleteChildren(); _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 ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); return dec; } XMLUnknown* XMLDocument::NewUnknown( const char* str ) { XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this ); unk->_memPool = &_commentPool; unk->SetValue( str ); return unk; } static FILE* callfopen( const char* filepath, const char* mode ) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) FILE* fp = 0; errno_t err = fopen_s( &fp, filepath, mode ); if ( err ) { return 0; } #else FILE* fp = fopen( filepath, mode ); #endif return fp; } XMLError XMLDocument::LoadFile( const char* filename ) { Clear(); FILE* fp = callfopen( filename, "rb" ); if ( !fp ) { SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); return _errorID; } LoadFile( fp ); fclose( fp ); return _errorID; } XMLError XMLDocument::LoadFile( FILE* fp ) { Clear(); fseek( fp, 0, SEEK_SET ); if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); return _errorID; } fseek( fp, 0, SEEK_END ); const long filelength = ftell( fp ); fseek( fp, 0, SEEK_SET ); if ( filelength == -1L ) { SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); return _errorID; } const size_t size = filelength; if ( size == 0 ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } _charBuffer = new char[size+1]; size_t read = fread( _charBuffer, 1, size, fp ); if ( read != size ) { SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); return _errorID; } _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; } XMLError XMLDocument::SaveFile( const char* filename, bool compact ) { FILE* fp = callfopen( filename, "w" ); if ( !fp ) { SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); return _errorID; } SaveFile(fp, compact); fclose( fp ); return _errorID; } XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) { XMLPrinter stream( fp, compact ); Print( &stream ); return _errorID; } XMLError XMLDocument::Parse( const char* p, size_t len ) { const char* start = p; Clear(); if ( len == 0 || !p || !*p ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } if ( len == (size_t)(-1) ) { len = strlen( p ); } _charBuffer = new char[ len+1 ]; memcpy( _charBuffer, p, len ); _charBuffer[len] = 0; p = XMLUtil::SkipWhiteSpace( p ); p = XMLUtil::ReadBOM( p, &_writeBOM ); if ( !p || !*p ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } ptrdiff_t delta = p - start; // skip initial whitespace, BOM, etc. ParseDeep( _charBuffer+delta, 0 ); return _errorID; } void XMLDocument::Print( XMLPrinter* streamer ) const { XMLPrinter stdStreamer( stdout ); if ( !streamer ) { streamer = &stdStreamer; } Accept( streamer ); } void XMLDocument::SetError( XMLError 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, bool compact, int depth ) : _elementJustOpened( false ), _firstElement( true ), _fp( file ), _depth( depth ), _textDepth( -1 ), _processEntities( true ), _compactMode( compact ) { for( int i=0; i'] = 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 { #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) #if defined(WINCE) int len = 512; do { len = len*2; char* str = new char[len](); len = _vsnprintf(str, len, format, va); delete[] str; }while (len < 0); #else int len = _vscprintf( format, va ); #endif #else int len = vsnprintf( 0, 0, format, va ); #endif // Close out and re-start the va-args va_end( va ); va_start( va, format ); char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) #if defined(WINCE) _vsnprintf( p, len+1, format, va ); #else vsnprintf_s( p, len+1, _TRUNCATE, format, va ); #endif #else vsnprintf( p, len+1, format, va ); #endif } va_end( va ); } void XMLPrinter::PrintSpace( int depth ) { for( int i=0; i 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 0) ) { Print( "%s", p ); } } void XMLPrinter::PushHeader( bool writeBOM, bool writeDec ) { if ( writeBOM ) { static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 }; Print( "%s", bom ); } if ( writeDec ) { PushDeclaration( "xml version=\"1.0\"" ); } } void XMLPrinter::OpenElement( const char* name, bool compactMode ) { if ( _elementJustOpened ) { SealElement(); } _stack.Push( name ); if ( _textDepth < 0 && !_firstElement && !compactMode ) { Print( "\n" ); } if ( !compactMode ) { 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]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::PushAttribute( const char* name, unsigned v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::PushAttribute( const char* name, bool v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::PushAttribute( const char* name, double v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::CloseElement( bool compactMode ) { --_depth; const char* name = _stack.Pop(); if ( _elementJustOpened ) { Print( "/>" ); } else { if ( _textDepth < 0 && !compactMode) { Print( "\n" ); PrintSpace( _depth ); } Print( "", name ); } if ( _textDepth == _depth ) { _textDepth = -1; } if ( _depth == 0 && !compactMode) { 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( "" ); } else { PrintString( text, true ); } } void XMLPrinter::PushText( int value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( unsigned value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( bool value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( float value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( double value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushComment( const char* comment ) { if ( _elementJustOpened ) { SealElement(); } if ( _textDepth < 0 && !_firstElement && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } _firstElement = false; Print( "", comment ); } void XMLPrinter::PushDeclaration( const char* value ) { if ( _elementJustOpened ) { SealElement(); } if ( _textDepth < 0 && !_firstElement && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } _firstElement = false; Print( "", value ); } void XMLPrinter::PushUnknown( const char* value ) { if ( _elementJustOpened ) { SealElement(); } if ( _textDepth < 0 && !_firstElement && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } _firstElement = false; Print( "", 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 ) { const XMLElement* parentElem = element.Parent()->ToElement(); bool compactMode = parentElem ? CompactMode(*parentElem) : _compactMode; OpenElement( element.Name(), compactMode ); while ( attribute ) { PushAttribute( attribute->Name(), attribute->Value() ); attribute = attribute->Next(); } return true; } bool XMLPrinter::VisitExit( const XMLElement& element ) { CloseElement( CompactMode(element) ); 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; } } // namespace tinyxml2 MediaInfoLib/Source/ThirdParty/tinyxml2/tinyxml2.h0000664000000000000000000017204612652076434021142 0ustar rootroot/* 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 defined(ANDROID_NDK) || defined(__BORLANDC__) # include # include # include # include # include # include #else # include # include # include # include # include # include #endif /* TODO: intern strings instead of allocation. */ /* gcc: g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe Formatting, Artistic Style: AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h */ #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) # ifndef DEBUG # define DEBUG # endif #endif #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4251) #endif #ifdef _WIN32 # ifdef TINYXML2_EXPORT # define TINYXML2_LIB __declspec(dllexport) # elif defined(TINYXML2_IMPORT) # define TINYXML2_LIB __declspec(dllimport) # else # define TINYXML2_LIB # endif #else # define TINYXML2_LIB #endif #if defined(DEBUG) # if defined(_MSC_VER) # define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak() # elif defined (ANDROID_NDK) # include # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } # else # include # define TIXMLASSERT assert # endif # else # define TIXMLASSERT( x ) {} #endif #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) // 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 #elif defined WINCE #define TIXML_SNPRINTF _snprintf #define TIXML_SSCANF sscanf #else // GCC version 3 and higher //#warning( "Using sn* functions." ) #define TIXML_SNPRINTF snprintf #define TIXML_SSCANF sscanf #endif /* Versioning, past 1.0.14: http://semver.org/ */ static const int TIXML2_MAJOR_VERSION = 2; static const int TIXML2_MINOR_VERSION = 1; static const int TIXML2_PATCH_VERSION = 0; namespace tinyxml2 { class XMLDocument; class XMLElement; class XMLAttribute; class XMLComment; 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, COLLAPSE_WHITESPACE = 0x04, 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(); _start = start; _end = end; _flags = flags | NEEDS_FLUSH; } const char* GetStr(); bool Empty() const { return _start == _end; } void SetInternedStr( const char* str ) { Reset(); _start = const_cast(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(); void CollapseWhitespace(); 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 DynArray { public: DynArray< T, INIT >() { _mem = _pool; _allocated = INIT; _size = 0; } ~DynArray() { if ( _mem != _pool ) { delete [] _mem; } } void Clear() { _size = 0; } 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]; } const T& PeekTop() const { TIXMLASSERT( _size > 0 ); return _mem[ _size - 1]; } 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 of 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; virtual void SetTracked() = 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), _nUntracked(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; ichunk[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++; _nUntracked++; return result; } virtual void Free( void* mem ) { if ( !mem ) { return; } --_currentAllocs; Chunk* chunk = static_cast( mem ); #ifdef DEBUG memset( chunk, 0xfe, sizeof(Chunk) ); #endif 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() ); } void SetTracked() { _nUntracked--; } int Untracked() const { return _nUntracked; } // This number is perf sensitive. 4k seems like a good tradeoff on my machine. // The test file is large, 170k. // Release: VS2010 gcc(no opt) // 1k: 4000 // 2k: 4000 // 4k: 3900 21000 // 16k: 5200 // 32k: 4300 // 64k: 4000 21000 enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private private: union Chunk { Chunk* next; char mem[SIZE]; }; struct Block { Chunk chunk[COUNT]; }; DynArray< Block*, 10 > _blockPtrs; Chunk* _root; int _currentAllocs; int _nAllocs; int _maxAllocs; int _nUntracked; }; /** 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 leafs are simply called with Visit(). If you return 'true' from a Visit method, recursive parsing will continue. If you return false, no children of this node or its siblings 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 XMLDocument, although all nodes support visiting. You should never change the document from a callback. @sa XMLNode::Accept() */ class TINYXML2_LIB 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 ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { ++p; } return p; } static char* SkipWhiteSpace( char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { ++p; } return p; } static bool IsWhiteSpace( char p ) { return !IsUTF8Continuation(p) && isspace( static_cast(p) ); } inline static bool IsNameStartChar( unsigned char ch ) { return ( ( ch < 128 ) ? isalpha( ch ) : 1 ) || ch == ':' || ch == '_'; } inline static bool IsNameChar( unsigned char ch ) { return IsNameStartChar( ch ) || isdigit( ch ) || ch == '.' || ch == '-'; } 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(const_cast(this)->FirstChildElement( value )); } /// Get the last child node, or null if none exists. const XMLNode* LastChild() const { return _lastChild; } XMLNode* LastChild() { return const_cast(const_cast(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(const_cast(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 optionally supplied name. const XMLElement* PreviousSiblingElement( const char* value=0 ) const ; XMLElement* PreviousSiblingElement( const char* value=0 ) { return const_cast(const_cast(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 optionally supplied name. const XMLElement* NextSiblingElement( const char* value=0 ) const; XMLElement* NextSiblingElement( const char* value=0 ) { return const_cast(const_cast(this)->NextSiblingElement( value ) ); } /** Add a child node as the last (right) child. If the child node is already part of the document, it is moved from its old location to the new location. Returns the addThis argument or 0 if the node does not belong to the same document. */ XMLNode* InsertEndChild( XMLNode* addThis ); XMLNode* LinkEndChild( XMLNode* addThis ) { return InsertEndChild( addThis ); } /** Add a child node as the first (left) child. If the child node is already part of the document, it is moved from its old location to the new location. Returns the addThis argument or 0 if the node does not belong to the same document. */ XMLNode* InsertFirstChild( XMLNode* addThis ); /** Add a node after the specified child node. If the child node is already part of the document, it is moved from its old location to the new location. Returns the addThis argument or 0 if the afterThis node is not a child of this node, or if the node does not belong to the same document. */ 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 hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the XMLVisitor interface. This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML-2 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 XMLPrinter 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 XMLNode& 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 This is bold @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 TINYXML2_LIB 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 ) { _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 XMLText& operator=( const XMLText& ); // not supported private: bool _isCData; }; /** An XML Comment. */ class TINYXML2_LIB 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 XMLComment& operator=( const XMLComment& ); // not supported private: }; /** In correct XML the declaration is the first entry in the file. @verbatim @endverbatim TinyXML-2 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 TINYXML2_LIB 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 XMLDeclaration& operator=( const XMLDeclaration& ); // not supported }; /** Any tag that TinyXML-2 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 XMLUnknowns. */ class TINYXML2_LIB 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 XMLUnknown& operator=( const XMLUnknown& ); // not supported }; enum XMLError { 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_FILE_READ_ERROR, 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, XML_CAN_NOT_CONVERT_TEXT, XML_NO_TEXT_NODE }; /** 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 TINYXML2_LIB XMLAttribute { friend class XMLElement; public: /// The name of the attribute. const char* Name() const; /// The value of the attribute. const char* Value() const; /// The next attribute in the list. const XMLAttribute* Next() const { return _next; } /** IntValue 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 QueryIntValue() if you need error checking. */ int IntValue() const { int i=0; QueryIntValue( &i ); return i; } /// Query as an unsigned integer. See IntValue() unsigned UnsignedValue() const { unsigned i=0; QueryUnsignedValue( &i ); return i; } /// Query as a boolean. See IntValue() bool BoolValue() const { bool b=false; QueryBoolValue( &b ); return b; } /// Query as a double. See IntValue() double DoubleValue() const { double d=0; QueryDoubleValue( &d ); return d; } /// Query as a float. See IntValue() float FloatValue() const { float f=0; QueryFloatValue( &f ); return f; } /** QueryIntValue interprets the attribute as an integer, and returns the value in the provided parameter. The function will return XML_NO_ERROR on success, and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. */ XMLError QueryIntValue( int* value ) const; /// See QueryIntValue XMLError QueryUnsignedValue( unsigned int* value ) const; /// See QueryIntValue XMLError QueryBoolValue( bool* value ) const; /// See QueryIntValue XMLError QueryDoubleValue( double* value ) const; /// See QueryIntValue XMLError 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 ), _memPool( 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 TINYXML2_LIB 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 */ XMLError QueryIntAttribute( const char* name, int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryIntValue( value ); } /// See QueryIntAttribute() XMLError 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() XMLError QueryBoolAttribute( const char* name, bool* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryBoolValue( value ); } /// See QueryIntAttribute() XMLError QueryDoubleAttribute( const char* name, double* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryDoubleValue( value ); } /// See QueryIntAttribute() XMLError QueryFloatAttribute( const char* name, float* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryFloatValue( value ); } /** Given an attribute name, QueryAttribute() 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. It is overloaded for the primitive types, and is a generally more convenient replacement of QueryIntAttribute() and related functions. 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; QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 @endverbatim */ int QueryAttribute( const char* name, int* value ) const { return QueryIntAttribute( name, value ); } int QueryAttribute( const char* name, unsigned int* value ) const { return QueryUnsignedAttribute( name, value ); } int QueryAttribute( const char* name, bool* value ) const { return QueryBoolAttribute( name, value ); } int QueryAttribute( const char* name, double* value ) const { return QueryDoubleAttribute( name, value ); } int QueryAttribute( const char* name, float* value ) const { return QueryFloatAttribute( name, 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 ); } /// Sets the named attribute to value. void SetAttribute( const char* name, float 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 XMLText child and accessing it directly. If the first child of 'this' is a XMLText, 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 This is text 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 This is text @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 This is text @endverbatim GetText() will return "This is ". */ const char* GetText() const; /** Convenience function for easy access to the text inside an element. Although easy and concise, SetText() is limited compared to creating an XMLText child and mutating it directly. If the first child of 'this' is a XMLText, SetText() sets its value to the given string, otherwise it will create a first child that is an XMLText. This is a convenient method for setting the text of simple contained text: @verbatim This is text fooElement->SetText( "Hullaballoo!" ); Hullaballoo! @endverbatim Note that this function can be misleading. If the element foo was created from this XML: @verbatim This is text @endverbatim then it will not change "This is text", but rather prefix it with a text element: @verbatim Hullaballoo!This is text @endverbatim For this XML: @verbatim @endverbatim SetText() will generate @verbatim Hullaballoo! @endverbatim */ void SetText( const char* inText ); /// Convenience method for setting text inside and element. See SetText() for important limitations. void SetText( int value ); /// Convenience method for setting text inside and element. See SetText() for important limitations. void SetText( unsigned value ); /// Convenience method for setting text inside and element. See SetText() for important limitations. void SetText( bool value ); /// Convenience method for setting text inside and element. See SetText() for important limitations. void SetText( double value ); /// Convenience method for setting text inside and element. See SetText() for important limitations. void SetText( float value ); /** Convenience method to query the value of a child text node. This is probably best shown by example. Given you have a document is this form: @verbatim 1 1.4 @endverbatim The QueryIntText() and similar functions provide a safe and easier way to get to the "value" of x and y. @verbatim int x = 0; float y = 0; // types of x and y are contrived for example const XMLElement* xElement = pointElement->FirstChildElement( "x" ); const XMLElement* yElement = pointElement->FirstChildElement( "y" ); xElement->QueryIntText( &x ); yElement->QueryFloatText( &y ); @endverbatim @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. */ XMLError QueryIntText( int* ival ) const; /// See QueryIntText() XMLError QueryUnsignedText( unsigned* uval ) const; /// See QueryIntText() XMLError QueryBoolText( bool* bval ) const; /// See QueryIntText() XMLError QueryDoubleText( double* dval ) const; /// See QueryIntText() XMLError QueryFloatText( float* fval ) const; // internal: enum { OPEN, // CLOSED, // CLOSING // }; 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 ); enum { BUF_SIZE = 200 }; int _closingType; // The attribute list is ordered; there is no 'lastAttribute' // because the list needs to be scanned for dupes before adding // a new attribute. XMLAttribute* _rootAttribute; }; enum Whitespace { PRESERVE_WHITESPACE, COLLAPSE_WHITESPACE }; /** 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 TINYXML2_LIB XMLDocument : public XMLNode { friend class XMLElement; public: /// constructor XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); ~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. You may optionally pass in the 'nBytes', which is the number of bytes which will be parsed. If not specified, TinyXML-2 will assume 'xml' points to a null terminated string. */ XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); /** Load an XML file from disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ XMLError 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. */ XMLError LoadFile( FILE* ); /** Save the XML file to disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ XMLError SaveFile( const char* filename, bool compact = false ); /** 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. */ XMLError SaveFile( FILE* fp, bool compact = false ); bool ProcessEntities() const { return _processEntities; } Whitespace WhitespaceMode() const { return _whitespace; } /** Returns true if this document has a leading Byte Order Mark of UTF8. */ bool HasBOM() const { return _writeBOM; } /** Sets whether to write the BOM when writing the file. */ void SetBOM( bool useBOM ) { _writeBOM = useBOM; } /** 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 ) const; 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. If the 'text' param is null, the standard declaration is used.: @verbatim @endverbatim */ XMLDeclaration* NewDeclaration( const char* text=0 ); /** 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 document. It will be unlinked from the DOM. */ void DeleteNode( XMLNode* node ) { node->_parent->DeleteChild( node ); } void SetError( XMLError 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. XMLError ErrorID() const { return _errorID; } /// Return a possibly helpful diagnostic location or string. const char* GetErrorStr1() const { return _errorStr1; } /// Return a 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; /// Clear the document, resetting it to the initial state. void Clear(); // 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 bool _writeBOM; bool _processEntities; XMLError _errorID; Whitespace _whitespace; 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-2 DOM structure. It is a separate utility class. Take an example: @verbatim @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 TINYXML2_LIB 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 == 0 ) ? 0 : _node->ToElement() ); } /// Safe cast to XMLText. This can return null. XMLText* ToText() { return ( ( _node == 0 ) ? 0 : _node->ToText() ); } /// Safe cast to XMLUnknown. This can return null. XMLUnknown* ToUnknown() { return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); } /// Safe cast to XMLDeclaration. This can return null. XMLDeclaration* ToDeclaration() { return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); } 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 TINYXML2_LIB 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 == 0 ) ? 0 : _node->ToElement() ); } const XMLText* ToText() const { return ( ( _node == 0 ) ? 0 : _node->ToText() ); } const XMLUnknown* ToUnknown() const { return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); } const XMLDeclaration* ToDeclaration() const { return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); } 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 ); SomeFunction( 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 TINYXML2_LIB 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(). If 'compact' is set to true, then output is created with only required whitespace and newlines. */ XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); virtual ~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, bool compactMode=false ); /// 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. virtual void CloseElement( bool compactMode=false ); /// Add a text node. void PushText( const char* text, bool cdata=false ); /// Add a text node from an integer. void PushText( int value ); /// Add a text node from an unsigned. void PushText( unsigned value ); /// Add a text node from a bool. void PushText( bool value ); /// Add a text node from a float. void PushText( float value ); /// Add a text node from a double. void PushText( double value ); /// 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(); } /** If in print to memory mode, return the size of the XML file in memory. (Note the size returned includes the terminating null.) */ int CStrSize() const { return _buffer.Size(); } /** If in print to memory mode, reset the buffer to the beginning. */ void ClearBuffer() { _buffer.Clear(); _buffer.Push(0); } protected: virtual bool CompactMode( const XMLElement& ) { return _compactMode; } /** Prints out the space before an element. You may override to change the space and tabs used. A PrintSpace() override should call Print(). */ virtual void PrintSpace( int depth ); void Print( const char* format, ... ); void SealElement(); bool _elementJustOpened; DynArray< const char*, 10 > _stack; private: void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. bool _firstElement; FILE* _fp; int _depth; int _textDepth; bool _processEntities; bool _compactMode; enum { ENTITY_RANGE = 64, BUF_SIZE = 200 }; bool _entityFlag[ENTITY_RANGE]; bool _restrictedEntityFlag[ENTITY_RANGE]; DynArray< char, 20 > _buffer; }; } // tinyxml2 #if defined(_MSC_VER) # pragma warning(pop) #endif #endif // TINYXML2_INCLUDED MediaInfoLib/Source/ThirdParty/hmac-gladman/0000775000000000000000000000000012652076434017714 5ustar rootrootMediaInfoLib/Source/ThirdParty/hmac-gladman/hmac.h0000664000000000000000000000574312652076434021006 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 26/08/2003 This is an implementation of HMAC, the FIPS standard keyed hash function */ #ifndef _HMAC_H #define _HMAC_H #include #if defined(__cplusplus) extern "C" { #endif #define USE_SHA1 #if !defined(USE_SHA1) && !defined(USE_SHA256) #error define USE_SHA1 or USE_SHA256 to set the HMAC hash algorithm #endif #ifdef USE_SHA1 #include "sha1.h" #define HASH_INPUT_SIZE SHA1_BLOCK_SIZE #define HASH_OUTPUT_SIZE SHA1_DIGEST_SIZE #define sha_ctx sha1_ctx #define sha_begin sha1_begin #define sha_hash sha1_hash #define sha_end sha1_end #endif #ifdef USE_SHA256 #include "sha2.h" #define HASH_INPUT_SIZE SHA256_BLOCK_SIZE #define HASH_OUTPUT_SIZE SHA256_DIGEST_SIZE #define sha_ctx sha256_ctx #define sha_begin sha256_begin #define sha_hash sha256_hash #define sha_end sha256_end #endif #define HMAC_OK 0 #define HMAC_BAD_MODE -1 #define HMAC_IN_DATA 0xffffffff typedef struct { unsigned char key[HASH_INPUT_SIZE]; sha_ctx ctx[1]; unsigned long klen; } hmac_ctx; void hmac_sha_begin(hmac_ctx cx[1]); int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]); void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]); void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]); void hmac_sha(const unsigned char key[], unsigned long key_len, const unsigned char data[], unsigned long data_len, unsigned char mac[], unsigned long mac_len); #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/hmac-gladman/pwd2key.c0000664000000000000000000001410312652076434021444 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 26/08/2003 This is an implementation of RFC2898, which specifies key derivation from a password and a salt value. */ #include #include "hmac.h" #if defined(__cplusplus) extern "C" { #endif void derive_key(const unsigned char pwd[], /* the PASSWORD */ unsigned int pwd_len, /* and its length */ const unsigned char salt[], /* the SALT and its */ unsigned int salt_len, /* length */ unsigned int iter, /* the number of iterations */ unsigned char key[], /* space for the output key */ unsigned int key_len)/* and its required length */ { unsigned int i, j, k, n_blk; unsigned char uu[HASH_OUTPUT_SIZE], ux[HASH_OUTPUT_SIZE]; hmac_ctx c1[1], c2[1], c3[1]; /* set HMAC context (c1) for password */ hmac_sha_begin(c1); hmac_sha_key(pwd, pwd_len, c1); /* set HMAC context (c2) for password and salt */ memcpy(c2, c1, sizeof(hmac_ctx)); hmac_sha_data(salt, salt_len, c2); /* find the number of SHA blocks in the key */ n_blk = 1 + (key_len - 1) / HASH_OUTPUT_SIZE; for(i = 0; i < n_blk; ++i) /* for each block in key */ { /* ux[] holds the running xor value */ memset(ux, 0, HASH_OUTPUT_SIZE); /* set HMAC context (c3) for password and salt */ memcpy(c3, c2, sizeof(hmac_ctx)); /* enter additional data for 1st block into uu */ uu[0] = (unsigned char)((i + 1) >> 24); uu[1] = (unsigned char)((i + 1) >> 16); uu[2] = (unsigned char)((i + 1) >> 8); uu[3] = (unsigned char)(i + 1); /* this is the key mixing iteration */ for(j = 0, k = 4; j < iter; ++j) { /* add previous round data to HMAC */ hmac_sha_data(uu, k, c3); /* obtain HMAC for uu[] */ hmac_sha_end(uu, HASH_OUTPUT_SIZE, c3); /* xor into the running xor block */ for(k = 0; k < HASH_OUTPUT_SIZE; ++k) ux[k] ^= uu[k]; /* set HMAC context (c3) for password */ memcpy(c3, c1, sizeof(hmac_ctx)); } /* compile key blocks into the key output */ j = 0; k = i * HASH_OUTPUT_SIZE; while(j < HASH_OUTPUT_SIZE && k < key_len) key[k++] = ux[j++]; } } #ifdef TEST #include struct { unsigned int pwd_len; unsigned int salt_len; unsigned int it_count; unsigned char *pwd; unsigned char salt[32]; unsigned char key[32]; } tests[] = { { 8, 4, 5, (unsigned char*)"password", { 0x12, 0x34, 0x56, 0x78 }, { 0x5c, 0x75, 0xce, 0xf0, 0x1a, 0x96, 0x0d, 0xf7, 0x4c, 0xb6, 0xb4, 0x9b, 0x9e, 0x38, 0xe6, 0xb5 } }, { 8, 8, 5, (unsigned char*)"password", { 0x12, 0x34, 0x56, 0x78, 0x78, 0x56, 0x34, 0x12 }, { 0xd1, 0xda, 0xa7, 0x86, 0x15, 0xf2, 0x87, 0xe6, 0xa1, 0xc8, 0xb1, 0x20, 0xd7, 0x06, 0x2a, 0x49 } }, { 8, 21, 1, (unsigned char*)"password", { "ATHENA.MIT.EDUraeburn" }, { 0xcd, 0xed, 0xb5, 0x28, 0x1b, 0xb2, 0xf8, 0x01, 0x56, 0x5a, 0x11, 0x22, 0xb2, 0x56, 0x35, 0x15 } }, { 8, 21, 2, (unsigned char*)"password", { "ATHENA.MIT.EDUraeburn" }, { 0x01, 0xdb, 0xee, 0x7f, 0x4a, 0x9e, 0x24, 0x3e, 0x98, 0x8b, 0x62, 0xc7, 0x3c, 0xda, 0x93, 0x5d } }, { 8, 21, 1200, (unsigned char*)"password", { "ATHENA.MIT.EDUraeburn" }, { 0x5c, 0x08, 0xeb, 0x61, 0xfd, 0xf7, 0x1e, 0x4e, 0x4e, 0xc3, 0xcf, 0x6b, 0xa1, 0xf5, 0x51, 0x2b } } }; int main() { unsigned int i, j, key_len = 256; unsigned char key[256]; printf("\nTest of RFC2898 Password Based Key Derivation"); for(i = 0; i < 5; ++i) { derive_key(tests[i].pwd, tests[i].pwd_len, tests[i].salt, tests[i].salt_len, tests[i].it_count, key, key_len); printf("\ntest %i: ", i + 1); printf("key %s", memcmp(tests[i].key, key, 16) ? "is bad" : "is good"); for(j = 0; j < key_len && j < 64; j += 4) { if(j % 16 == 0) printf("\n"); printf("0x%02x%02x%02x%02x ", key[j], key[j + 1], key[j + 2], key[j + 3]); } printf(j < key_len ? " ... \n" : "\n"); } printf("\n"); return 0; } #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/hmac-gladman/hmac.c0000664000000000000000000001214712652076434020775 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 26/08/2003 This is an implementation of HMAC, the FIPS standard keyed hash function */ #include "hmac.h" #if defined(__cplusplus) extern "C" { #endif /* initialise the HMAC context to zero */ void hmac_sha_begin(hmac_ctx cx[1]) { memset(cx, 0, sizeof(hmac_ctx)); } /* input the HMAC key (can be called multiple times) */ int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]) { if(cx->klen == HMAC_IN_DATA) /* error if further key input */ return HMAC_BAD_MODE; /* is attempted in data mode */ if(cx->klen + key_len > HASH_INPUT_SIZE) /* if the key has to be hashed */ { if(cx->klen <= HASH_INPUT_SIZE) /* if the hash has not yet been */ { /* started, initialise it and */ sha_begin(cx->ctx); /* hash stored key characters */ sha_hash(cx->key, cx->klen, cx->ctx); } sha_hash(key, key_len, cx->ctx); /* hash long key data into hash */ } else /* otherwise store key data */ memcpy(cx->key + cx->klen, key, key_len); cx->klen += key_len; /* update the key length count */ return HMAC_OK; } /* input the HMAC data (can be called multiple times) - */ /* note that this call terminates the key input phase */ void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]) { unsigned int i; if(cx->klen != HMAC_IN_DATA) /* if not yet in data phase */ { if(cx->klen > HASH_INPUT_SIZE) /* if key is being hashed */ { /* complete the hash and */ sha_end(cx->key, cx->ctx); /* store the result as the */ cx->klen = HASH_OUTPUT_SIZE; /* key and set new length */ } /* pad the key if necessary */ memset(cx->key + cx->klen, 0, HASH_INPUT_SIZE - cx->klen); /* xor ipad into key value */ for(i = 0; i < (HASH_INPUT_SIZE >> 2); ++i) ((uint32_t*)cx->key)[i] ^= 0x36363636; /* and start hash operation */ sha_begin(cx->ctx); sha_hash(cx->key, HASH_INPUT_SIZE, cx->ctx); /* mark as now in data mode */ cx->klen = HMAC_IN_DATA; } /* hash the data (if any) */ if(data_len) sha_hash(data, data_len, cx->ctx); } /* compute and output the MAC value */ void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]) { unsigned char dig[HASH_OUTPUT_SIZE]; unsigned int i; /* if no data has been entered perform a null data phase */ if(cx->klen != HMAC_IN_DATA) hmac_sha_data((const unsigned char*)0, 0, cx); sha_end(dig, cx->ctx); /* complete the inner hash */ /* set outer key value using opad and removing ipad */ for(i = 0; i < (HASH_INPUT_SIZE >> 2); ++i) ((uint32_t*)cx->key)[i] ^= 0x36363636 ^ 0x5c5c5c5c; /* perform the outer hash operation */ sha_begin(cx->ctx); sha_hash(cx->key, HASH_INPUT_SIZE, cx->ctx); sha_hash(dig, HASH_OUTPUT_SIZE, cx->ctx); sha_end(dig, cx->ctx); /* output the hash value */ for(i = 0; i < mac_len; ++i) mac[i] = dig[i]; } /* 'do it all in one go' subroutine */ void hmac_sha(const unsigned char key[], unsigned long key_len, const unsigned char data[], unsigned long data_len, unsigned char mac[], unsigned long mac_len) { hmac_ctx cx[1]; hmac_sha_begin(cx); hmac_sha_key(key, key_len, cx); hmac_sha_data(data, data_len, cx); hmac_sha_end(mac, mac_len, cx); } #if defined(__cplusplus) } #endif MediaInfoLib/Source/ThirdParty/hmac-gladman/pwd2key.h0000664000000000000000000000400512652076434021451 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 26/08/2003 This is an implementation of RFC2898, which specifies key derivation from a password and a salt value. */ #ifndef PWD2KEY_H #define PWD2KEY_H #if defined(__cplusplus) extern "C" { #endif void derive_key( const unsigned char pwd[], /* the PASSWORD, and */ unsigned int pwd_len, /* its length */ const unsigned char salt[], /* the SALT and its */ unsigned int salt_len, /* length */ unsigned int iter, /* the number of iterations */ unsigned char key[], /* space for the output key */ unsigned int key_len); /* and its required length */ #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/0000775000000000000000000000000012652076434017554 5ustar rootrootMediaInfoLib/Source/ThirdParty/aes-gladman/aes_x86_v1.asm0000664000000000000000000003653412652076434022154 0ustar rootroot ; --------------------------------------------------------------------------- ; Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. ; ; The redistribution and use of this software (with or without changes) ; is allowed without the payment of fees or royalties provided that: ; ; source code distributions include the above copyright notice, this ; list of conditions and the following disclaimer; ; ; binary distributions include the above copyright notice, this list ; of conditions and the following disclaimer in their documentation. ; ; This software is provided 'as is' with no explicit or implied warranties ; in respect of its operation, including, but not limited to, correctness ; and fitness for purpose. ; --------------------------------------------------------------------------- ; Issue 13/08/2008 ; ; This code requires ASM_X86_V1C to be set in aesopt.h. It requires the C files ; aeskey.c and aestab.c for support. ; An AES implementation for x86 processors using the YASM (or NASM) assembler. ; This is an assembler implementation that covers encryption and decryption ; only and is intended as a replacement of the C file aescrypt.c. It hence ; requires the file aeskey.c for keying and aestab.c for the AES tables. It ; employs full tables rather than compressed tables. ; This code provides the standard AES block size (128 bits, 16 bytes) and the ; three standard AES key sizes (128, 192 and 256 bits). It has the same call ; interface as my C implementation. The ebx, esi, edi and ebp registers are ; preserved across calls but eax, ecx and edx and the artihmetic status flags ; are not. It is also important that the defines below match those used in the ; C code. This code uses the VC++ register saving conentions; if it is used ; with another compiler, conventions for using and saving registers may need to ; be checked (and calling conventions). The YASM command line for the VC++ ; custom build step is: ; ; yasm -Xvc -f win32 -o "$(TargetDir)\$(InputName).obj" "$(InputPath)" ; ; The calling intefaces are: ; ; AES_RETURN aes_encrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; where is 128, 102 or 256. In the last two calls the length can be in ; either bits or bytes. ; ; Comment in/out the following lines to obtain the desired subroutines. These ; selections MUST match those in the C header file aes.h %define AES_128 ; define if AES with 128 bit keys is needed %define AES_192 ; define if AES with 192 bit keys is needed %define AES_256 ; define if AES with 256 bit keys is needed %define AES_VAR ; define if a variable key size is needed %define ENCRYPTION ; define if encryption is needed %define DECRYPTION ; define if decryption is needed %define AES_REV_DKS ; define if key decryption schedule is reversed %define LAST_ROUND_TABLES ; define if tables are to be used for last round ; offsets to parameters in_blk equ 4 ; input byte array address parameter out_blk equ 8 ; output byte array address parameter ctx equ 12 ; AES context structure stk_spc equ 20 ; stack space %define parms 12 ; parameter space on stack ; The encryption key schedule has the following in memory layout where N is the ; number of rounds (10, 12 or 14): ; ; lo: | input key (round 0) | ; each round is four 32-bit words ; | encryption round 1 | ; | encryption round 2 | ; .... ; | encryption round N-1 | ; hi: | encryption round N | ; ; The decryption key schedule is normally set up so that it has the same ; layout as above by actually reversing the order of the encryption key ; schedule in memory (this happens when AES_REV_DKS is set): ; ; lo: | decryption round 0 | = | encryption round N | ; | decryption round 1 | = INV_MIX_COL[ | encryption round N-1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round N-2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round 1 | ] ; hi: | decryption round N | = | input key (round 0) | ; ; with rounds except the first and last modified using inv_mix_column() ; But if AES_REV_DKS is NOT set the order of keys is left as it is for ; encryption so that it has to be accessed in reverse when used for ; decryption (although the inverse mix column modifications are done) ; ; lo: | decryption round 0 | = | input key (round 0) | ; | decryption round 1 | = INV_MIX_COL[ | encryption round 1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round 2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round N-1 | ] ; hi: | decryption round N | = | encryption round N | ; ; This layout is faster when the assembler key scheduling provided here ; is used. ; ; The DLL interface must use the _stdcall convention in which the number ; of bytes of parameter space is added after an @ to the sutine's name. ; We must also remove our parameters from the stack before return (see ; the do_exit macro). Define DLL_EXPORT for the Dynamic Link Library version. ;%define DLL_EXPORT ; End of user defines %ifdef AES_VAR %ifndef AES_128 %define AES_128 %endif %ifndef AES_192 %define AES_192 %endif %ifndef AES_256 %define AES_256 %endif %endif %ifdef AES_VAR %define KS_LENGTH 60 %elifdef AES_256 %define KS_LENGTH 60 %elifdef AES_192 %define KS_LENGTH 52 %else %define KS_LENGTH 44 %endif ; These macros implement stack based local variables %macro save 2 mov [esp+4*%1],%2 %endmacro %macro restore 2 mov %1,[esp+4*%2] %endmacro ; the DLL has to implement the _stdcall calling interface on return ; In this case we have to take our parameters (3 4-byte pointers) ; off the stack %macro do_name 1-2 parms %ifndef DLL_EXPORT global %1 %1: %else global %1@%2 export %1@%2 %1@%2: %endif %endmacro %macro do_call 1-2 parms %ifndef DLL_EXPORT call %1 add esp,%2 %else call %1@%2 %endif %endmacro %macro do_exit 0-1 parms %ifdef DLL_EXPORT ret %1 %else ret %endif %endmacro %ifdef ENCRYPTION extern _t_fn %define etab_0(x) [_t_fn+4*x] %define etab_1(x) [_t_fn+1024+4*x] %define etab_2(x) [_t_fn+2048+4*x] %define etab_3(x) [_t_fn+3072+4*x] %ifdef LAST_ROUND_TABLES extern _t_fl %define eltab_0(x) [_t_fl+4*x] %define eltab_1(x) [_t_fl+1024+4*x] %define eltab_2(x) [_t_fl+2048+4*x] %define eltab_3(x) [_t_fl+3072+4*x] %else %define etab_b(x) byte [_t_fn+3072+4*x] %endif ; ROUND FUNCTION. Build column[2] on ESI and column[3] on EDI that have the ; round keys pre-loaded. Build column[0] in EBP and column[1] in EBX. ; ; Input: ; ; EAX column[0] ; EBX column[1] ; ECX column[2] ; EDX column[3] ; ESI column key[round][2] ; EDI column key[round][3] ; EBP scratch ; ; Output: ; ; EBP column[0] unkeyed ; EBX column[1] unkeyed ; ESI column[2] keyed ; EDI column[3] keyed ; EAX scratch ; ECX scratch ; EDX scratch %macro rnd_fun 2 rol ebx,16 %1 esi, cl, 0, ebp %1 esi, dh, 1, ebp %1 esi, bh, 3, ebp %1 edi, dl, 0, ebp %1 edi, ah, 1, ebp %1 edi, bl, 2, ebp %2 ebp, al, 0, ebp shr ebx,16 and eax,0xffff0000 or eax,ebx shr edx,16 %1 ebp, ah, 1, ebx %1 ebp, dh, 3, ebx %2 ebx, dl, 2, ebx %1 ebx, ch, 1, edx %1 ebx, al, 0, edx shr eax,16 shr ecx,16 %1 ebp, cl, 2, edx %1 edi, ch, 3, edx %1 esi, al, 2, edx %1 ebx, ah, 3, edx %endmacro ; Basic MOV and XOR Operations for normal rounds %macro nr_xor 4 movzx %4,%2 xor %1,etab_%3(%4) %endmacro %macro nr_mov 4 movzx %4,%2 mov %1,etab_%3(%4) %endmacro ; Basic MOV and XOR Operations for last round %ifdef LAST_ROUND_TABLES %macro lr_xor 4 movzx %4,%2 xor %1,eltab_%3(%4) %endmacro %macro lr_mov 4 movzx %4,%2 mov %1,eltab_%3(%4) %endmacro %else %macro lr_xor 4 movzx %4,%2 movzx %4,etab_b(%4) %if %3 != 0 shl %4,8*%3 %endif xor %1,%4 %endmacro %macro lr_mov 4 movzx %4,%2 movzx %1,etab_b(%4) %if %3 != 0 shl %1,8*%3 %endif %endmacro %endif %macro enc_round 0 add ebp,16 save 0,ebp mov esi,[ebp+8] mov edi,[ebp+12] rnd_fun nr_xor, nr_mov mov eax,ebp mov ecx,esi mov edx,edi restore ebp,0 xor eax,[ebp] xor ebx,[ebp+4] %endmacro %macro enc_last_round 0 add ebp,16 save 0,ebp mov esi,[ebp+8] mov edi,[ebp+12] rnd_fun lr_xor, lr_mov mov eax,ebp restore ebp,0 xor eax,[ebp] xor ebx,[ebp+4] %endmacro section .text align=32 ; AES Encryption Subroutine align 32 do_name _aes_encrypt sub esp,stk_spc mov [esp+16],ebp mov [esp+12],ebx mov [esp+ 8],esi mov [esp+ 4],edi mov esi,[esp+in_blk+stk_spc] ; input pointer mov eax,[esi ] mov ebx,[esi+ 4] mov ecx,[esi+ 8] mov edx,[esi+12] mov ebp,[esp+ctx+stk_spc] ; key pointer movzx edi,byte [ebp+4*KS_LENGTH] xor eax,[ebp ] xor ebx,[ebp+ 4] xor ecx,[ebp+ 8] xor edx,[ebp+12] ; determine the number of rounds cmp edi,10*16 je .3 cmp edi,12*16 je .2 cmp edi,14*16 je .1 mov eax,-1 jmp .5 .1: enc_round enc_round .2: enc_round enc_round .3: enc_round enc_round enc_round enc_round enc_round enc_round enc_round enc_round enc_round enc_last_round mov edx,[esp+out_blk+stk_spc] mov [edx],eax mov [edx+4],ebx mov [edx+8],esi mov [edx+12],edi xor eax,eax .5: mov ebp,[esp+16] mov ebx,[esp+12] mov esi,[esp+ 8] mov edi,[esp+ 4] add esp,stk_spc do_exit %endif %ifdef DECRYPTION extern _t_in %define dtab_0(x) [_t_in+4*x] %define dtab_1(x) [_t_in+1024+4*x] %define dtab_2(x) [_t_in+2048+4*x] %define dtab_3(x) [_t_in+3072+4*x] %ifdef LAST_ROUND_TABLES extern _t_il %define dltab_0(x) [_t_il+4*x] %define dltab_1(x) [_t_il+1024+4*x] %define dltab_2(x) [_t_il+2048+4*x] %define dltab_3(x) [_t_il+3072+4*x] %else extern _t_ibox %define dtab_x(x) byte [_t_ibox+x] %endif %macro irn_fun 2 rol eax,16 %1 esi, cl, 0, ebp %1 esi, bh, 1, ebp %1 esi, al, 2, ebp %1 edi, dl, 0, ebp %1 edi, ch, 1, ebp %1 edi, ah, 3, ebp %2 ebp, bl, 0, ebp shr eax,16 and ebx,0xffff0000 or ebx,eax shr ecx,16 %1 ebp, bh, 1, eax %1 ebp, ch, 3, eax %2 eax, cl, 2, ecx %1 eax, bl, 0, ecx %1 eax, dh, 1, ecx shr ebx,16 shr edx,16 %1 esi, dh, 3, ecx %1 ebp, dl, 2, ecx %1 eax, bh, 3, ecx %1 edi, bl, 2, ecx %endmacro ; Basic MOV and XOR Operations for normal rounds %macro ni_xor 4 movzx %4,%2 xor %1,dtab_%3(%4) %endmacro %macro ni_mov 4 movzx %4,%2 mov %1,dtab_%3(%4) %endmacro ; Basic MOV and XOR Operations for last round %ifdef LAST_ROUND_TABLES %macro li_xor 4 movzx %4,%2 xor %1,dltab_%3(%4) %endmacro %macro li_mov 4 movzx %4,%2 mov %1,dltab_%3(%4) %endmacro %else %macro li_xor 4 movzx %4,%2 movzx %4,dtab_x(%4) %if %3 != 0 shl %4,8*%3 %endif xor %1,%4 %endmacro %macro li_mov 4 movzx %4,%2 movzx %1,dtab_x(%4) %if %3 != 0 shl %1,8*%3 %endif %endmacro %endif %macro dec_round 0 %ifdef AES_REV_DKS add ebp,16 %else sub ebp,16 %endif save 0,ebp mov esi,[ebp+8] mov edi,[ebp+12] irn_fun ni_xor, ni_mov mov ebx,ebp mov ecx,esi mov edx,edi restore ebp,0 xor eax,[ebp] xor ebx,[ebp+4] %endmacro %macro dec_last_round 0 %ifdef AES_REV_DKS add ebp,16 %else sub ebp,16 %endif save 0,ebp mov esi,[ebp+8] mov edi,[ebp+12] irn_fun li_xor, li_mov mov ebx,ebp restore ebp,0 xor eax,[ebp] xor ebx,[ebp+4] %endmacro section .text align=32 ; AES Decryption Subroutine align 32 do_name _aes_decrypt sub esp,stk_spc mov [esp+16],ebp mov [esp+12],ebx mov [esp+ 8],esi mov [esp+ 4],edi ; input four columns and xor in first round key mov esi,[esp+in_blk+stk_spc] ; input pointer mov eax,[esi ] mov ebx,[esi+ 4] mov ecx,[esi+ 8] mov edx,[esi+12] lea esi,[esi+16] mov ebp,[esp+ctx+stk_spc] ; key pointer movzx edi,byte[ebp+4*KS_LENGTH] %ifndef AES_REV_DKS ; if decryption key schedule is not reversed lea ebp,[ebp+edi] ; we have to access it from the top down %endif xor eax,[ebp ] ; key schedule xor ebx,[ebp+ 4] xor ecx,[ebp+ 8] xor edx,[ebp+12] ; determine the number of rounds cmp edi,10*16 je .3 cmp edi,12*16 je .2 cmp edi,14*16 je .1 mov eax,-1 jmp .5 .1: dec_round dec_round .2: dec_round dec_round .3: dec_round dec_round dec_round dec_round dec_round dec_round dec_round dec_round dec_round dec_last_round ; move final values to the output array. mov ebp,[esp+out_blk+stk_spc] mov [ebp],eax mov [ebp+4],ebx mov [ebp+8],esi mov [ebp+12],edi xor eax,eax .5: mov ebp,[esp+16] mov ebx,[esp+12] mov esi,[esp+ 8] mov edi,[esp+ 4] add esp,stk_spc do_exit %endif end MediaInfoLib/Source/ThirdParty/aes-gladman/aescpp.h0000664000000000000000000001156712652076434021212 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the definitions required to use AES (Rijndael) in C++. */ #ifndef _AESCPP_H #define _AESCPP_H #include "aes.h" #if defined( AES_ENCRYPT ) class AESencrypt { public: aes_encrypt_ctx cx[1]; AESencrypt(void) { aes_init(); }; #if defined(AES_128) AESencrypt(const unsigned char key[]) { aes_encrypt_key128(key, cx); } AES_RETURN key128(const unsigned char key[]) { return aes_encrypt_key128(key, cx); } #endif #if defined(AES_192) AES_RETURN key192(const unsigned char key[]) { return aes_encrypt_key192(key, cx); } #endif #if defined(AES_256) AES_RETURN key256(const unsigned char key[]) { return aes_encrypt_key256(key, cx); } #endif #if defined(AES_VAR) AES_RETURN key(const unsigned char key[], int key_len) { return aes_encrypt_key(key, key_len, cx); } #endif AES_RETURN encrypt(const unsigned char in[], unsigned char out[]) const { return aes_encrypt(in, out, cx); } #ifndef AES_MODES AES_RETURN ecb_encrypt(const unsigned char in[], unsigned char out[], int nb) const { while(nb--) { aes_encrypt(in, out, cx), in += AES_BLOCK_SIZE, out += AES_BLOCK_SIZE; } } #endif #ifdef AES_MODES AES_RETURN mode_reset(void) { return aes_mode_reset(cx); } AES_RETURN ecb_encrypt(const unsigned char in[], unsigned char out[], int nb) const { return aes_ecb_encrypt(in, out, nb, cx); } AES_RETURN cbc_encrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) const { return aes_cbc_encrypt(in, out, nb, iv, cx); } AES_RETURN cfb_encrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) { return aes_cfb_encrypt(in, out, nb, iv, cx); } AES_RETURN cfb_decrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) { return aes_cfb_decrypt(in, out, nb, iv, cx); } AES_RETURN ofb_crypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) { return aes_ofb_crypt(in, out, nb, iv, cx); } typedef void ctr_fn(unsigned char ctr[]); AES_RETURN ctr_crypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[], ctr_fn cf) { return aes_ctr_crypt(in, out, nb, iv, cf, cx); } #endif }; #endif #if defined( AES_DECRYPT ) class AESdecrypt { public: aes_decrypt_ctx cx[1]; AESdecrypt(void) { aes_init(); }; #if defined(AES_128) AESdecrypt(const unsigned char key[]) { aes_decrypt_key128(key, cx); } AES_RETURN key128(const unsigned char key[]) { return aes_decrypt_key128(key, cx); } #endif #if defined(AES_192) AES_RETURN key192(const unsigned char key[]) { return aes_decrypt_key192(key, cx); } #endif #if defined(AES_256) AES_RETURN key256(const unsigned char key[]) { return aes_decrypt_key256(key, cx); } #endif #if defined(AES_VAR) AES_RETURN key(const unsigned char key[], int key_len) { return aes_decrypt_key(key, key_len, cx); } #endif AES_RETURN decrypt(const unsigned char in[], unsigned char out[]) const { return aes_decrypt(in, out, cx); } #ifndef AES_MODES AES_RETURN ecb_decrypt(const unsigned char in[], unsigned char out[], int nb) const { while(nb--) { aes_decrypt(in, out, cx), in += AES_BLOCK_SIZE, out += AES_BLOCK_SIZE; } } #endif #ifdef AES_MODES AES_RETURN ecb_decrypt(const unsigned char in[], unsigned char out[], int nb) const { return aes_ecb_decrypt(in, out, nb, cx); } AES_RETURN cbc_decrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) const { return aes_cbc_decrypt(in, out, nb, iv, cx); } #endif }; #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes_ni.h0000664000000000000000000000501412652076434021163 0ustar rootroot/* Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 13/11/2013 */ #ifndef AES_NI_H #define AES_NI_H #include #include "aesopt.h" #if defined( USE_INTEL_AES_IF_PRESENT ) /* map names in C code to make them internal ('name' -> 'aes_name_i') */ #define aes_xi(x) aes_ ## x ## _i /* map names here to provide the external API ('name' -> 'aes_name') */ #define aes_ni(x) aes_ ## x AES_RETURN aes_ni(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_ni(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_ni(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_ni(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_ni(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_ni(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_ni(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); AES_RETURN aes_ni(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes_ni.c0000664000000000000000000003221712652076434021163 0ustar rootroot/* Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 13/11/2013 */ #include #include "aes_ni.h" #if defined( USE_INTEL_AES_IF_PRESENT ) #pragma intrinsic(__cpuid) __inline int has_aes_ni() { static int test = -1; int cpu_info[4]; if(test < 0) { __cpuid(cpu_info, 1); test = cpu_info[2] & 0x02000000; } return test; } __inline __m128i aes_128_assist(__m128i t1, __m128i t2) { __m128i t3; t2 = _mm_shuffle_epi32(t2, 0xff); t3 = _mm_slli_si128(t1, 0x4); t1 = _mm_xor_si128(t1, t3); t3 = _mm_slli_si128(t3, 0x4); t1 = _mm_xor_si128(t1, t3); t3 = _mm_slli_si128(t3, 0x4); t1 = _mm_xor_si128(t1, t3); t1 = _mm_xor_si128(t1, t2); return t1; } AES_RETURN aes_ni(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]) { __m128i t1, t2; __m128i *ks = (__m128i*)cx->ks; if(!has_aes_ni()) { aes_xi(encrypt_key128)(key, cx); return EXIT_SUCCESS; } t1 = _mm_loadu_si128((__m128i*)key); ks[0] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x1); t1 = aes_128_assist(t1, t2); ks[1] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x2); t1 = aes_128_assist(t1, t2); ks[2] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x4); t1 = aes_128_assist(t1, t2); ks[3] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x8); t1 = aes_128_assist(t1, t2); ks[4] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x10); t1 = aes_128_assist(t1, t2); ks[5] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x20); t1 = aes_128_assist(t1, t2); ks[6] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x40); t1 = aes_128_assist(t1, t2); ks[7] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x80); t1 = aes_128_assist(t1, t2); ks[8] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x1b); t1 = aes_128_assist(t1, t2); ks[9] = t1; t2 = _mm_aeskeygenassist_si128(t1, 0x36); t1 = aes_128_assist(t1, t2); ks[10] = t1; cx->inf.l = 0; cx->inf.b[0] = 10 * 16; return EXIT_SUCCESS; } __inline void aes_192_assist(__m128i* t1, __m128i * t2, __m128i * t3) { __m128i t4; *t2 = _mm_shuffle_epi32(*t2, 0x55); t4 = _mm_slli_si128(*t1, 0x4); *t1 = _mm_xor_si128(*t1, t4); t4 = _mm_slli_si128(t4, 0x4); *t1 = _mm_xor_si128(*t1, t4); t4 = _mm_slli_si128(t4, 0x4); *t1 = _mm_xor_si128(*t1, t4); *t1 = _mm_xor_si128(*t1, *t2); *t2 = _mm_shuffle_epi32(*t1, 0xff); t4 = _mm_slli_si128(*t3, 0x4); *t3 = _mm_xor_si128(*t3, t4); *t3 = _mm_xor_si128(*t3, *t2); } AES_RETURN aes_ni(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]) { __m128i t1, t2, t3; __m128i *ks = (__m128i*)cx->ks; if(!has_aes_ni()) { aes_xi(encrypt_key192)(key, cx); return EXIT_SUCCESS; } t1 = _mm_loadu_si128((__m128i*)key); t3 = _mm_loadu_si128((__m128i*)(key + 16)); ks[0] = t1; ks[1] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x1); aes_192_assist(&t1, &t2, &t3); ks[1] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(ks[1]), _mm_castsi128_pd(t1), 0)); ks[2] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(t1), _mm_castsi128_pd(t3), 1)); t2 = _mm_aeskeygenassist_si128(t3, 0x2); aes_192_assist(&t1, &t2, &t3); ks[3] = t1; ks[4] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x4); aes_192_assist(&t1, &t2, &t3); ks[4] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(ks[4]), _mm_castsi128_pd(t1), 0)); ks[5] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(t1), _mm_castsi128_pd(t3), 1)); t2 = _mm_aeskeygenassist_si128(t3, 0x8); aes_192_assist(&t1, &t2, &t3); ks[6] = t1; ks[7] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x10); aes_192_assist(&t1, &t2, &t3); ks[7] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(ks[7]), _mm_castsi128_pd(t1), 0)); ks[8] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(t1), _mm_castsi128_pd(t3), 1)); t2 = _mm_aeskeygenassist_si128(t3, 0x20); aes_192_assist(&t1, &t2, &t3); ks[9] = t1; ks[10] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x40); aes_192_assist(&t1, &t2, &t3); ks[10] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(ks[10]), _mm_castsi128_pd(t1), 0)); ks[11] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(t1), _mm_castsi128_pd(t3), 1)); t2 = _mm_aeskeygenassist_si128(t3, 0x80); aes_192_assist(&t1, &t2, &t3); ks[12] = t1; cx->inf.l = 0; cx->inf.b[0] = 12 * 16; return EXIT_SUCCESS; } __inline void aes_256_assist1(__m128i* t1, __m128i * t2) { __m128i t4; *t2 = _mm_shuffle_epi32(*t2, 0xff); t4 = _mm_slli_si128(*t1, 0x4); *t1 = _mm_xor_si128(*t1, t4); t4 = _mm_slli_si128(t4, 0x4); *t1 = _mm_xor_si128(*t1, t4); t4 = _mm_slli_si128(t4, 0x4); *t1 = _mm_xor_si128(*t1, t4); *t1 = _mm_xor_si128(*t1, *t2); } __inline void aes_256_assist2(__m128i* t1, __m128i * t3) { __m128i t2, t4; t4 = _mm_aeskeygenassist_si128(*t1, 0x0); t2 = _mm_shuffle_epi32(t4, 0xaa); t4 = _mm_slli_si128(*t3, 0x4); *t3 = _mm_xor_si128(*t3, t4); t4 = _mm_slli_si128(t4, 0x4); *t3 = _mm_xor_si128(*t3, t4); t4 = _mm_slli_si128(t4, 0x4); *t3 = _mm_xor_si128(*t3, t4); *t3 = _mm_xor_si128(*t3, t2); } AES_RETURN aes_ni(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]) { __m128i t1, t2, t3; __m128i *ks = (__m128i*)cx->ks; if(!has_aes_ni()) { aes_xi(encrypt_key256)(key, cx); return EXIT_SUCCESS; } t1 = _mm_loadu_si128((__m128i*)key); t3 = _mm_loadu_si128((__m128i*)(key + 16)); ks[0] = t1; ks[1] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x01); aes_256_assist1(&t1, &t2); ks[2] = t1; aes_256_assist2(&t1, &t3); ks[3] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x02); aes_256_assist1(&t1, &t2); ks[4] = t1; aes_256_assist2(&t1, &t3); ks[5] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x04); aes_256_assist1(&t1, &t2); ks[6] = t1; aes_256_assist2(&t1, &t3); ks[7] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x08); aes_256_assist1(&t1, &t2); ks[8] = t1; aes_256_assist2(&t1, &t3); ks[9] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x10); aes_256_assist1(&t1, &t2); ks[10] = t1; aes_256_assist2(&t1, &t3); ks[11] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x20); aes_256_assist1(&t1, &t2); ks[12] = t1; aes_256_assist2(&t1, &t3); ks[13] = t3; t2 = _mm_aeskeygenassist_si128(t3, 0x40); aes_256_assist1(&t1, &t2); ks[14] = t1; cx->inf.l = 0; cx->inf.b[0] = 14 * 16; return EXIT_SUCCESS; } __inline void enc_to_dec(aes_decrypt_ctx cx[1]) { __m128i *ks = (__m128i*)cx->ks; int j; for( j = 1 ; j < (cx->inf.b[0] >> 4) ; ++j ) ks[j] = _mm_aesimc_si128(ks[j]); } AES_RETURN aes_ni(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]) { if(!has_aes_ni()) { aes_xi(decrypt_key128)(key, cx); return EXIT_SUCCESS; } if(aes_ni(encrypt_key128)(key, (aes_encrypt_ctx*)cx) == EXIT_SUCCESS) { enc_to_dec(cx); return EXIT_SUCCESS; } else return EXIT_FAILURE; } AES_RETURN aes_ni(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]) { if(!has_aes_ni()) { aes_xi(decrypt_key192)(key, cx); return EXIT_SUCCESS; } if(aes_ni(encrypt_key192)(key, (aes_encrypt_ctx*)cx) == EXIT_SUCCESS) { enc_to_dec(cx); return EXIT_SUCCESS; } else return EXIT_FAILURE; } AES_RETURN aes_ni(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]) { if(!has_aes_ni()) { aes_xi(decrypt_key256)(key, cx); return EXIT_SUCCESS; } if(aes_ni(encrypt_key256)(key, (aes_encrypt_ctx*)cx) == EXIT_SUCCESS) { enc_to_dec(cx); return EXIT_SUCCESS; } else return EXIT_FAILURE; } AES_RETURN aes_ni(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) { __m128i *key = (__m128i*)cx->ks, t; if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16) return EXIT_FAILURE; if(!has_aes_ni()) { aes_xi(encrypt)(in, out, cx); return EXIT_SUCCESS; } t = _mm_xor_si128(_mm_loadu_si128((__m128i*)in), *(__m128i*)key); switch(cx->inf.b[0]) { case 14 * 16: t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); case 12 * 16: t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); case 10 * 16: t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenc_si128(t, *(__m128i*)++key); t = _mm_aesenclast_si128(t, *(__m128i*)++key); } _mm_storeu_si128(&((__m128i*)out)[0], t); return EXIT_SUCCESS; } AES_RETURN aes_ni(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) { __m128i *key = (__m128i*)cx->ks + (cx->inf.b[0] >> 4), t; if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16) return EXIT_FAILURE; if(!has_aes_ni()) { aes_xi(decrypt)(in, out, cx); return EXIT_SUCCESS; } t = _mm_xor_si128(_mm_loadu_si128((__m128i*)in), *(__m128i*)key); switch(cx->inf.b[0]) { case 14 * 16: t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); case 12 * 16: t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); case 10 * 16: t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdec_si128(t, *(__m128i*)--key); t = _mm_aesdeclast_si128(t, *(__m128i*)--key); } _mm_storeu_si128((__m128i*)out, t); return EXIT_SUCCESS; } void aes_CBC_encrypt(const unsigned char *in, unsigned char *out, unsigned char ivec[16], unsigned long length, unsigned char *key, int number_of_rounds) { __m128i feedback, data; int i, j; if(length % 16) length = length / 16 + 1; else length /= 16; feedback = _mm_loadu_si128((__m128i*)ivec); for(i = 0; i < length; i++) { data = _mm_loadu_si128(&((__m128i*)in)[i]); feedback = _mm_xor_si128(data, feedback); feedback = _mm_xor_si128(feedback, ((__m128i*)key)[0]); for(j = 1; j #include "aesopt.h" #define sb_data(w) {\ w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } #define isb_data(w) {\ w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\ w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\ w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\ w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\ w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\ w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\ w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\ w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\ w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\ w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\ w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\ w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\ w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\ w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\ w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\ w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\ w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\ w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\ w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\ w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\ w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\ w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\ w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\ w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\ w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\ w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\ w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\ w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\ w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\ w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\ w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\ w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d) } #define mm_data(w) {\ w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\ w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\ w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\ w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\ w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\ w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\ w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\ w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\ w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\ w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\ w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\ w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\ w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\ w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\ w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\ w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\ w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\ w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\ w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\ w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\ w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\ w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\ w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\ w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\ w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\ w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\ w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\ w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\ w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\ w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\ w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\ w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff) } #define rc_data(w) {\ w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\ w(0x1b), w(0x36) } #define h0(x) (x) #define w0(p) bytes2word(p, 0, 0, 0) #define w1(p) bytes2word(0, p, 0, 0) #define w2(p) bytes2word(0, 0, p, 0) #define w3(p) bytes2word(0, 0, 0, p) #define u0(p) bytes2word(f2(p), p, p, f3(p)) #define u1(p) bytes2word(f3(p), f2(p), p, p) #define u2(p) bytes2word(p, f3(p), f2(p), p) #define u3(p) bytes2word(p, p, f3(p), f2(p)) #define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p)) #define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p)) #define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p)) #define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p)) #define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY)) #define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY)) #define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \ ^ (((x>>5) & 4) * WPOLY)) #define f3(x) (f2(x) ^ x) #define f9(x) (f8(x) ^ x) #define fb(x) (f8(x) ^ f2(x) ^ x) #define fd(x) (f8(x) ^ f4(x) ^ x) #define fe(x) (f8(x) ^ f4(x) ^ f2(x)) #include "aestab.h" #define t_parm(m,n) "t_"#m#n, t_##m##n void rtab(FILE *f, unsigned char *h, const unsigned int t[RC_LENGTH]) { int i; fprintf(f, "\nuint32_t %s[RC_LENGTH] = \n{", h); for(i = 0; i < RC_LENGTH; ++i) { if(i % 4 == 0) fprintf(f, "\n "); if(i != RC_LENGTH - 1) fprintf(f, "0x%08x, ", t[i]); else fprintf(f, "0x%08x ", t[i]); } fprintf(f, "\n};\n"); } void btab_1(FILE *f, unsigned char *h, const unsigned char t[256]) { int i; fprintf(f, "\nuint8_t %s[256] = \n{", h); for(i = 0; i < 256; ++i) { if(i % 8 == 0) fprintf(f, "\n "); if(i != 255) fprintf(f, "0x%02x, ", t[i]); else fprintf(f, "0x%02x ", t[i]); } fprintf(f, "\n};\n"); } void wtab_1(FILE *f, unsigned char *h, const unsigned int t[256]) { int i; fprintf(f, "\nuint32_t %s[256] = \n{", h); for(i = 0; i < 256; ++i) { if(i % 4 == 0) fprintf(f, "\n "); if(i != 255) fprintf(f, "0x%08x, ", t[i]); else fprintf(f, "0x%08x ", t[i]); } fprintf(f, "\n};\n"); } void wtab_4(FILE *f, unsigned char *h, const unsigned int t[4][256]) { int i, j; fprintf(f, "\nuint32_t %s[4][256] = \n{", h); for(i = 0; i < 4; ++i) { fprintf(f, "\n {"); for(j = 0; j < 256; ++j) { if(j % 4 == 0) fprintf(f, "\n "); if(j != 255) fprintf(f, "0x%08x, ", t[i][j]); else fprintf(f, "0x%08x ", t[i][j]); } if(i != 3) fprintf(f, "\n },"); else fprintf(f, "\n }"); } fprintf(f, "\n};\n"); } int main(void) { FILE *f; f = fopen("aestab2.c", "w"); fprintf(f, "\n#include \"aes.h\"\n"); fprintf(f, "\n#define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2))\n"); fprintf(f, "\nvoid aes_init() \n{ \n}\n"); rtab(f, t_parm(r,c)); #if defined( SBX_SET ) btab_1(f, t_parm(s,box)); #endif #if defined( ISB_SET ) btab_1(f, t_parm(i,box)); #endif #if defined( FT1_SET ) wtab_1(f, t_parm(f,n)); #endif #if defined( FT4_SET ) wtab_4(f, t_parm(f,n)); #endif #if defined( FL1_SET ) wtab_1(f, t_parm(f,l)); #endif #if defined( FL4_SET ) wtab_4(f, t_parm(f,l)); #endif #if defined( IT1_SET ) wtab_1(f, t_parm(i,n)); #endif #if defined( IT4_SET ) wtab_4(f, t_parm(i,n)); #endif #if defined( IL1_SET ) wtab_1(f, t_parm(i,l)); #endif #if defined( IL4_SET ) wtab_4(f, t_parm(i,l)); #endif #if defined( LS1_SET ) #if !defined( FL1_SET ) wtab_1(f, t_parm(l,s)); #endif #endif #if defined( LS4_SET ) #if !defined( FL4_SET ) wtab_4(f, t_parm(l,s)); #endif #endif #if defined( IM1_SET ) wtab_1(f, t_parm(i,m)); #endif #if defined( IM4_SET ) wtab_4(f, t_parm(i,m)); #endif fclose(f); return 0; } MediaInfoLib/Source/ThirdParty/aes-gladman/aesopt.h0000664000000000000000000006670212652076434021233 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the compilation options for AES (Rijndael) and code that is common across encryption, key scheduling and table generation. OPERATION These source code files implement the AES algorithm Rijndael designed by Joan Daemen and Vincent Rijmen. This version is designed for the standard block size of 16 bytes and for key sizes of 128, 192 and 256 bits (16, 24 and 32 bytes). This version is designed for flexibility and speed using operations on 32-bit words rather than operations on bytes. It can be compiled with either big or little endian internal byte order but is faster when the native byte order for the processor is used. THE CIPHER INTERFACE The cipher interface is implemented as an array of bytes in which lower AES bit sequence indexes map to higher numeric significance within bytes. uint8_t (an unsigned 8-bit type) uint32_t (an unsigned 32-bit type) struct aes_encrypt_ctx (structure for the cipher encryption context) struct aes_decrypt_ctx (structure for the cipher decryption context) AES_RETURN the function return type C subroutine calls: AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); IMPORTANT NOTE: If you are using this C interface with dynamic tables make sure that you call aes_init() before AES is used so that the tables are initialised. C++ aes class subroutines: Class AESencrypt for encryption Construtors: AESencrypt(void) AESencrypt(const unsigned char *key) - 128 bit key Members: AES_RETURN key128(const unsigned char *key) AES_RETURN key192(const unsigned char *key) AES_RETURN key256(const unsigned char *key) AES_RETURN encrypt(const unsigned char *in, unsigned char *out) const Class AESdecrypt for encryption Construtors: AESdecrypt(void) AESdecrypt(const unsigned char *key) - 128 bit key Members: AES_RETURN key128(const unsigned char *key) AES_RETURN key192(const unsigned char *key) AES_RETURN key256(const unsigned char *key) AES_RETURN decrypt(const unsigned char *in, unsigned char *out) const */ #if !defined( _AESOPT_H ) #define _AESOPT_H #if defined( __cplusplus ) #include "aescpp.h" #else #include "aes.h" #endif /* PLATFORM SPECIFIC INCLUDES */ #include "brg_endian.h" /* CONFIGURATION - THE USE OF DEFINES Later in this section there are a number of defines that control the operation of the code. In each section, the purpose of each define is explained so that the relevant form can be included or excluded by setting either 1's or 0's respectively on the branches of the related #if clauses. The following local defines should not be changed. */ #define ENCRYPTION_IN_C 1 #define DECRYPTION_IN_C 2 #define ENC_KEYING_IN_C 4 #define DEC_KEYING_IN_C 8 #define NO_TABLES 0 #define ONE_TABLE 1 #define FOUR_TABLES 4 #define NONE 0 #define PARTIAL 1 #define FULL 2 /* --- START OF USER CONFIGURED OPTIONS --- */ /* 1. BYTE ORDER WITHIN 32 BIT WORDS The fundamental data processing units in Rijndael are 8-bit bytes. The input, output and key input are all enumerated arrays of bytes in which bytes are numbered starting at zero and increasing to one less than the number of bytes in the array in question. This enumeration is only used for naming bytes and does not imply any adjacency or order relationship from one byte to another. When these inputs and outputs are considered as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte. In this implementation bits are numbered from 0 to 7 starting at the numerically least significant end of each byte (bit n represents 2^n). However, Rijndael can be implemented more efficiently using 32-bit words by packing bytes into words so that bytes 4*n to 4*n+3 are placed into word[n]. While in principle these bytes can be assembled into words in any positions, this implementation only supports the two formats in which bytes in adjacent positions within words also have adjacent byte numbers. This order is called big-endian if the lowest numbered bytes in words have the highest numeric significance and little-endian if the opposite applies. This code can work in either order irrespective of the order used by the machine on which it runs. Normally the internal byte order will be set to the order of the processor on which the code is to be run but this define can be used to reverse this in special situations WARNING: Assembler code versions rely on PLATFORM_BYTE_ORDER being set. This define will hence be redefined later (in section 4) if necessary */ #if 1 # define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER #elif 0 # define ALGORITHM_BYTE_ORDER IS_LITTLE_ENDIAN #elif 0 # define ALGORITHM_BYTE_ORDER IS_BIG_ENDIAN #else # error The algorithm byte order is not defined #endif /* 2. Intel AES AND VIA ACE SUPPORT */ #if defined( __GNUC__ ) && defined( __i386__ ) \ || defined(_WIN32) && defined(_M_IX86) \ && !(defined(_WIN64) || defined(_WIN32_WCE) || defined(_MSC_VER) && (_MSC_VER <= 800)) # define VIA_ACE_POSSIBLE #endif /* Define this option if support for the Intel AESNI is required (not currently available with GCC). If AESNI is known to be present, then defining ASSUME_INTEL_AES_VIA_PRESENT will replace the ordinary encryption/decryption. If USE_INTEL_AES_IF_PRESENT is defined then AESNI will be used if it is detected (both present and enabled). AESNI uses a decryption key schedule with the first decryption round key at the high end of the key scedule with the following round keys at lower positions in memory. So AES_REV_DKS must NOT be defined when AESNI will be used. ALthough it is unlikely that assembler code will be used with an AESNI build, if it is then AES_REV_DKS must NOT be defined when such assembler files are built */ #if 1 && defined( _WIN64 ) && defined( _MSC_VER ) # define INTEL_AES_POSSIBLE #endif #if defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT ) # define USE_INTEL_AES_IF_PRESENT #endif /* Define this option if support for the VIA ACE is required. This uses inline assembler instructions and is only implemented for the Microsoft, Intel and GCC compilers. If VIA ACE is known to be present, then defining ASSUME_VIA_ACE_PRESENT will remove the ordinary encryption/decryption code. If USE_VIA_ACE_IF_PRESENT is defined then VIA ACE will be used if it is detected (both present and enabled) but the normal AES code will also be present. When VIA ACE is to be used, all AES encryption contexts MUST be 16 byte aligned; other input/output buffers do not need to be 16 byte aligned but there are very large performance gains if this can be arranged. VIA ACE also requires the decryption key schedule to be in reverse order (which later checks below ensure). AES_REV_DKS must be set for assembler code used with a VIA ACE build */ #if 1 && defined( VIA_ACE_POSSIBLE ) && !defined( USE_VIA_ACE_IF_PRESENT ) # define USE_VIA_ACE_IF_PRESENT #endif #if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( ASSUME_VIA_ACE_PRESENT ) # define ASSUME_VIA_ACE_PRESENT # endif /* 3. ASSEMBLER SUPPORT This define (which can be on the command line) enables the use of the assembler code routines for encryption, decryption and key scheduling as follows: ASM_X86_V1C uses the assembler (aes_x86_v1.asm) with large tables for encryption and decryption and but with key scheduling in C ASM_X86_V2 uses assembler (aes_x86_v2.asm) with compressed tables for encryption, decryption and key scheduling ASM_X86_V2C uses assembler (aes_x86_v2.asm) with compressed tables for encryption and decryption and but with key scheduling in C ASM_AMD64_C uses assembler (aes_amd64.asm) with compressed tables for encryption and decryption and but with key scheduling in C Change one 'if 0' below to 'if 1' to select the version or define as a compilation option. */ #if 0 && !defined( ASM_X86_V1C ) # define ASM_X86_V1C #elif 0 && !defined( ASM_X86_V2 ) # define ASM_X86_V2 #elif 0 && !defined( ASM_X86_V2C ) # define ASM_X86_V2C #elif 0 && !defined( ASM_AMD64_C ) # define ASM_AMD64_C #endif #if (defined ( ASM_X86_V1C ) || defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) \ && !defined( _M_IX86 ) || defined( ASM_AMD64_C ) && !defined( _M_X64 ) # error Assembler code is only available for x86 and AMD64 systems #endif /* 4. FAST INPUT/OUTPUT OPERATIONS. On some machines it is possible to improve speed by transferring the bytes in the input and output arrays to and from the internal 32-bit variables by addressing these arrays as if they are arrays of 32-bit words. On some machines this will always be possible but there may be a large performance penalty if the byte arrays are not aligned on the normal word boundaries. On other machines this technique will lead to memory access errors when such 32-bit word accesses are not properly aligned. The option SAFE_IO avoids such problems but will often be slower on those machines that support misaligned access (especially so if care is taken to align the input and output byte arrays on 32-bit word boundaries). If SAFE_IO is not defined it is assumed that access to byte arrays as if they are arrays of 32-bit words will not cause problems when such accesses are misaligned. */ #if 1 && !defined( _MSC_VER ) # define SAFE_IO #endif /* 5. LOOP UNROLLING The code for encryption and decrytpion cycles through a number of rounds that can be implemented either in a loop or by expanding the code into a long sequence of instructions, the latter producing a larger program but one that will often be much faster. The latter is called loop unrolling. There are also potential speed advantages in expanding two iterations in a loop with half the number of iterations, which is called partial loop unrolling. The following options allow partial or full loop unrolling to be set independently for encryption and decryption */ #if 1 # define ENC_UNROLL FULL #elif 0 # define ENC_UNROLL PARTIAL #else # define ENC_UNROLL NONE #endif #if 1 # define DEC_UNROLL FULL #elif 0 # define DEC_UNROLL PARTIAL #else # define DEC_UNROLL NONE #endif #if 1 # define ENC_KS_UNROLL #endif #if 1 # define DEC_KS_UNROLL #endif /* 6. FAST FINITE FIELD OPERATIONS If this section is included, tables are used to provide faster finite field arithmetic (this has no effect if FIXED_TABLES is defined). */ #if 1 # define FF_TABLES #endif /* 7. INTERNAL STATE VARIABLE FORMAT The internal state of Rijndael is stored in a number of local 32-bit word varaibles which can be defined either as an array or as individual names variables. Include this section if you want to store these local varaibles in arrays. Otherwise individual local variables will be used. */ #if 1 # define ARRAYS #endif /* 8. FIXED OR DYNAMIC TABLES When this section is included the tables used by the code are compiled statically into the binary file. Otherwise the subroutine aes_init() must be called to compute them before the code is first used. */ #if 1 && !(defined( _MSC_VER ) && ( _MSC_VER <= 800 )) # define FIXED_TABLES #endif /* 9. MASKING OR CASTING FROM LONGER VALUES TO BYTES In some systems it is better to mask longer values to extract bytes rather than using a cast. This option allows this choice. */ #if 0 # define to_byte(x) ((uint8_t)(x)) #else # define to_byte(x) ((x) & 0xff) #endif /* 10. TABLE ALIGNMENT On some sytsems speed will be improved by aligning the AES large lookup tables on particular boundaries. This define should be set to a power of two giving the desired alignment. It can be left undefined if alignment is not needed. This option is specific to the Microsft VC++ compiler - it seems to sometimes cause trouble for the VC++ version 6 compiler. */ #if 1 && defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) # define TABLE_ALIGN 32 #endif /* 11. REDUCE CODE AND TABLE SIZE This replaces some expanded macros with function calls if AES_ASM_V2 or AES_ASM_V2C are defined */ #if 1 && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) # define REDUCE_CODE_SIZE #endif /* 12. TABLE OPTIONS This cipher proceeds by repeating in a number of cycles known as 'rounds' which are implemented by a round function which can optionally be speeded up using tables. The basic tables are each 256 32-bit words, with either one or four tables being required for each round function depending on how much speed is required. The encryption and decryption round functions are different and the last encryption and decrytpion round functions are different again making four different round functions in all. This means that: 1. Normal encryption and decryption rounds can each use either 0, 1 or 4 tables and table spaces of 0, 1024 or 4096 bytes each. 2. The last encryption and decryption rounds can also use either 0, 1 or 4 tables and table spaces of 0, 1024 or 4096 bytes each. Include or exclude the appropriate definitions below to set the number of tables used by this implementation. */ #if 1 /* set tables for the normal encryption round */ # define ENC_ROUND FOUR_TABLES #elif 0 # define ENC_ROUND ONE_TABLE #else # define ENC_ROUND NO_TABLES #endif #if 1 /* set tables for the last encryption round */ # define LAST_ENC_ROUND FOUR_TABLES #elif 0 # define LAST_ENC_ROUND ONE_TABLE #else # define LAST_ENC_ROUND NO_TABLES #endif #if 1 /* set tables for the normal decryption round */ # define DEC_ROUND FOUR_TABLES #elif 0 # define DEC_ROUND ONE_TABLE #else # define DEC_ROUND NO_TABLES #endif #if 1 /* set tables for the last decryption round */ # define LAST_DEC_ROUND FOUR_TABLES #elif 0 # define LAST_DEC_ROUND ONE_TABLE #else # define LAST_DEC_ROUND NO_TABLES #endif /* The decryption key schedule can be speeded up with tables in the same way that the round functions can. Include or exclude the following defines to set this requirement. */ #if 1 # define KEY_SCHED FOUR_TABLES #elif 0 # define KEY_SCHED ONE_TABLE #else # define KEY_SCHED NO_TABLES #endif /* ---- END OF USER CONFIGURED OPTIONS ---- */ /* VIA ACE support is only available for VC++ and GCC */ #if !defined( _MSC_VER ) && !defined( __GNUC__ ) # if defined( ASSUME_VIA_ACE_PRESENT ) # undef ASSUME_VIA_ACE_PRESENT # endif # if defined( USE_VIA_ACE_IF_PRESENT ) # undef USE_VIA_ACE_IF_PRESENT # endif #endif #if defined( ASSUME_VIA_ACE_PRESENT ) && !defined( USE_VIA_ACE_IF_PRESENT ) # define USE_VIA_ACE_IF_PRESENT #endif /* define to reverse decryption key schedule */ #if 1 || defined( USE_VIA_ACE_IF_PRESENT ) && !defined ( AES_REV_DKS ) # define AES_REV_DKS #endif /* Intel AESNI uses a decryption key schedule in the encryption order */ #if defined( USE_INTEL_AES_IF_PRESENT ) && defined ( AES_REV_DKS ) # undef AES_REV_DKS #endif /* Assembler support requires the use of platform byte order */ #if ( defined( ASM_X86_V1C ) || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) ) \ && (ALGORITHM_BYTE_ORDER != PLATFORM_BYTE_ORDER) # undef ALGORITHM_BYTE_ORDER # define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER #endif /* In this implementation the columns of the state array are each held in 32-bit words. The state array can be held in various ways: in an array of words, in a number of individual word variables or in a number of processor registers. The following define maps a variable name x and a column number c to the way the state array variable is to be held. The first define below maps the state into an array x[c] whereas the second form maps the state into a number of individual variables x0, x1, etc. Another form could map individual state colums to machine register names. */ #if defined( ARRAYS ) # define s(x,c) x[c] #else # define s(x,c) x##c #endif /* This implementation provides subroutines for encryption, decryption and for setting the three key lengths (separately) for encryption and decryption. Since not all functions are needed, masks are set up here to determine which will be implemented in C */ #if !defined( AES_ENCRYPT ) # define EFUNCS_IN_C 0 #elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \ || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) # define EFUNCS_IN_C ENC_KEYING_IN_C #elif !defined( ASM_X86_V2 ) # define EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C ) #else # define EFUNCS_IN_C 0 #endif #if !defined( AES_DECRYPT ) # define DFUNCS_IN_C 0 #elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \ || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) # define DFUNCS_IN_C DEC_KEYING_IN_C #elif !defined( ASM_X86_V2 ) # define DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C ) #else # define DFUNCS_IN_C 0 #endif #define FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C ) /* END OF CONFIGURATION OPTIONS */ #define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2)) /* Disable or report errors on some combinations of options */ #if ENC_ROUND == NO_TABLES && LAST_ENC_ROUND != NO_TABLES # undef LAST_ENC_ROUND # define LAST_ENC_ROUND NO_TABLES #elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES # undef LAST_ENC_ROUND # define LAST_ENC_ROUND ONE_TABLE #endif #if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE # undef ENC_UNROLL # define ENC_UNROLL NONE #endif #if DEC_ROUND == NO_TABLES && LAST_DEC_ROUND != NO_TABLES # undef LAST_DEC_ROUND # define LAST_DEC_ROUND NO_TABLES #elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES # undef LAST_DEC_ROUND # define LAST_DEC_ROUND ONE_TABLE #endif #if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE # undef DEC_UNROLL # define DEC_UNROLL NONE #endif #if defined( bswap32 ) # define aes_sw32 bswap32 #elif defined( bswap_32 ) # define aes_sw32 bswap_32 #else # define brot(x,n) (((uint32_t)(x) << n) | ((uint32_t)(x) >> (32 - n))) # define aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00)) #endif /* upr(x,n): rotates bytes within words by n positions, moving bytes to higher index positions with wrap around into low positions ups(x,n): moves bytes by n positions to higher index positions in words but without wrap around bval(x,n): extracts a byte from a word WARNING: The definitions given here are intended only for use with unsigned variables and with shift counts that are compile time constants */ #if ( ALGORITHM_BYTE_ORDER == IS_LITTLE_ENDIAN ) # define upr(x,n) (((uint32_t)(x) << (8 * (n))) | ((uint32_t)(x) >> (32 - 8 * (n)))) # define ups(x,n) ((uint32_t) (x) << (8 * (n))) # define bval(x,n) to_byte((x) >> (8 * (n))) # define bytes2word(b0, b1, b2, b3) \ (((uint32_t)(b3) << 24) | ((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0)) #endif #if ( ALGORITHM_BYTE_ORDER == IS_BIG_ENDIAN ) # define upr(x,n) (((uint32_t)(x) >> (8 * (n))) | ((uint32_t)(x) << (32 - 8 * (n)))) # define ups(x,n) ((uint32_t) (x) >> (8 * (n))) # define bval(x,n) to_byte((x) >> (24 - 8 * (n))) # define bytes2word(b0, b1, b2, b3) \ (((uint32_t)(b0) << 24) | ((uint32_t)(b1) << 16) | ((uint32_t)(b2) << 8) | (b3)) #endif #if defined( SAFE_IO ) # define word_in(x,c) bytes2word(((const uint8_t*)(x)+4*c)[0], ((const uint8_t*)(x)+4*c)[1], \ ((const uint8_t*)(x)+4*c)[2], ((const uint8_t*)(x)+4*c)[3]) # define word_out(x,c,v) { ((uint8_t*)(x)+4*c)[0] = bval(v,0); ((uint8_t*)(x)+4*c)[1] = bval(v,1); \ ((uint8_t*)(x)+4*c)[2] = bval(v,2); ((uint8_t*)(x)+4*c)[3] = bval(v,3); } #elif ( ALGORITHM_BYTE_ORDER == PLATFORM_BYTE_ORDER ) # define word_in(x,c) (*((uint32_t*)(x)+(c))) # define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = (v)) #else # define word_in(x,c) aes_sw32(*((uint32_t*)(x)+(c))) # define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = aes_sw32(v)) #endif /* the finite field modular polynomial and elements */ #define WPOLY 0x011b #define BPOLY 0x1b /* multiply four bytes in GF(2^8) by 'x' {02} in parallel */ #define gf_c1 0x80808080 #define gf_c2 0x7f7f7f7f #define gf_mulx(x) ((((x) & gf_c2) << 1) ^ ((((x) & gf_c1) >> 7) * BPOLY)) /* The following defines provide alternative definitions of gf_mulx that might give improved performance if a fast 32-bit multiply is not available. Note that a temporary variable u needs to be defined where gf_mulx is used. #define gf_mulx(x) (u = (x) & gf_c1, u |= (u >> 1), ((x) & gf_c2) << 1) ^ ((u >> 3) | (u >> 6)) #define gf_c4 (0x01010101 * BPOLY) #define gf_mulx(x) (u = (x) & gf_c1, ((x) & gf_c2) << 1) ^ ((u - (u >> 7)) & gf_c4) */ /* Work out which tables are needed for the different options */ #if defined( ASM_X86_V1C ) # if defined( ENC_ROUND ) # undef ENC_ROUND # endif # define ENC_ROUND FOUR_TABLES # if defined( LAST_ENC_ROUND ) # undef LAST_ENC_ROUND # endif # define LAST_ENC_ROUND FOUR_TABLES # if defined( DEC_ROUND ) # undef DEC_ROUND # endif # define DEC_ROUND FOUR_TABLES # if defined( LAST_DEC_ROUND ) # undef LAST_DEC_ROUND # endif # define LAST_DEC_ROUND FOUR_TABLES # if defined( KEY_SCHED ) # undef KEY_SCHED # define KEY_SCHED FOUR_TABLES # endif #endif #if ( FUNCS_IN_C & ENCRYPTION_IN_C ) || defined( ASM_X86_V1C ) # if ENC_ROUND == ONE_TABLE # define FT1_SET # elif ENC_ROUND == FOUR_TABLES # define FT4_SET # else # define SBX_SET # endif # if LAST_ENC_ROUND == ONE_TABLE # define FL1_SET # elif LAST_ENC_ROUND == FOUR_TABLES # define FL4_SET # elif !defined( SBX_SET ) # define SBX_SET # endif #endif #if ( FUNCS_IN_C & DECRYPTION_IN_C ) || defined( ASM_X86_V1C ) # if DEC_ROUND == ONE_TABLE # define IT1_SET # elif DEC_ROUND == FOUR_TABLES # define IT4_SET # else # define ISB_SET # endif # if LAST_DEC_ROUND == ONE_TABLE # define IL1_SET # elif LAST_DEC_ROUND == FOUR_TABLES # define IL4_SET # elif !defined(ISB_SET) # define ISB_SET # endif #endif #if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))) # if ((FUNCS_IN_C & ENC_KEYING_IN_C) || (FUNCS_IN_C & DEC_KEYING_IN_C)) # if KEY_SCHED == ONE_TABLE # if !defined( FL1_SET ) && !defined( FL4_SET ) # define LS1_SET # endif # elif KEY_SCHED == FOUR_TABLES # if !defined( FL4_SET ) # define LS4_SET # endif # elif !defined( SBX_SET ) # define SBX_SET # endif # endif # if (FUNCS_IN_C & DEC_KEYING_IN_C) # if KEY_SCHED == ONE_TABLE # define IM1_SET # elif KEY_SCHED == FOUR_TABLES # define IM4_SET # elif !defined( SBX_SET ) # define SBX_SET # endif # endif #endif /* generic definitions of Rijndael macros that use tables */ #define no_table(x,box,vf,rf,c) bytes2word( \ box[bval(vf(x,0,c),rf(0,c))], \ box[bval(vf(x,1,c),rf(1,c))], \ box[bval(vf(x,2,c),rf(2,c))], \ box[bval(vf(x,3,c),rf(3,c))]) #define one_table(x,op,tab,vf,rf,c) \ ( tab[bval(vf(x,0,c),rf(0,c))] \ ^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \ ^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \ ^ op(tab[bval(vf(x,3,c),rf(3,c))],3)) #define four_tables(x,tab,vf,rf,c) \ ( tab[0][bval(vf(x,0,c),rf(0,c))] \ ^ tab[1][bval(vf(x,1,c),rf(1,c))] \ ^ tab[2][bval(vf(x,2,c),rf(2,c))] \ ^ tab[3][bval(vf(x,3,c),rf(3,c))]) #define vf1(x,r,c) (x) #define rf1(r,c) (r) #define rf2(r,c) ((8+r-c)&3) /* perform forward and inverse column mix operation on four bytes in long word x in */ /* parallel. NOTE: x must be a simple variable, NOT an expression in these macros. */ #if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))) #if defined( FM4_SET ) /* not currently used */ # define fwd_mcol(x) four_tables(x,t_use(f,m),vf1,rf1,0) #elif defined( FM1_SET ) /* not currently used */ # define fwd_mcol(x) one_table(x,upr,t_use(f,m),vf1,rf1,0) #else # define dec_fmvars uint32_t g2 # define fwd_mcol(x) (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1)) #endif #if defined( IM4_SET ) # define inv_mcol(x) four_tables(x,t_use(i,m),vf1,rf1,0) #elif defined( IM1_SET ) # define inv_mcol(x) one_table(x,upr,t_use(i,m),vf1,rf1,0) #else # define dec_imvars uint32_t g2, g4, g9 # define inv_mcol(x) (g2 = gf_mulx(x), g4 = gf_mulx(g2), g9 = (x) ^ gf_mulx(g4), g4 ^= g9, \ (x) ^ g2 ^ g4 ^ upr(g2 ^ g9, 3) ^ upr(g4, 2) ^ upr(g9, 1)) #endif #if defined( FL4_SET ) # define ls_box(x,c) four_tables(x,t_use(f,l),vf1,rf2,c) #elif defined( LS4_SET ) # define ls_box(x,c) four_tables(x,t_use(l,s),vf1,rf2,c) #elif defined( FL1_SET ) # define ls_box(x,c) one_table(x,upr,t_use(f,l),vf1,rf2,c) #elif defined( LS1_SET ) # define ls_box(x,c) one_table(x,upr,t_use(l,s),vf1,rf2,c) #else # define ls_box(x,c) no_table(x,t_use(s,box),vf1,rf2,c) #endif #endif #if defined( ASM_X86_V1C ) && defined( AES_DECRYPT ) && !defined( ISB_SET ) # define ISB_SET #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes_amd64.asm0000664000000000000000000006631212652076434022031 0ustar rootroot ; --------------------------------------------------------------------------- ; Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. ; ; The redistribution and use of this software (with or without changes) ; is allowed without the payment of fees or royalties provided that: ; ; source code distributions include the above copyright notice, this ; list of conditions and the following disclaimer; ; ; binary distributions include the above copyright notice, this list ; of conditions and the following disclaimer in their documentation. ; ; This software is provided 'as is' with no explicit or implied warranties ; in respect of its operation, including, but not limited to, correctness ; and fitness for purpose. ; --------------------------------------------------------------------------- ; Issue Date: 20/12/2007 ; ; I am grateful to Dag Arne Osvik for many discussions of the techniques that ; can be used to optimise AES assembler code on AMD64/EM64T architectures. ; Some of the techniques used in this implementation are the result of ; suggestions made by him for which I am most grateful. ; An AES implementation for AMD64 processors using the YASM assembler. This ; implemetation provides only encryption, decryption and hence requires key ; scheduling support in C. It uses 8k bytes of tables but its encryption and ; decryption performance is very close to that obtained using large tables. ; It can use either Windows or Gnu/Linux calling conventions, which are as ; follows: ; windows gnu/linux ; ; in_blk rcx rdi ; out_blk rdx rsi ; context (cx) r8 rdx ; ; preserved rsi - + rbx, rbp, rsp, r12, r13, r14 & r15 ; registers rdi - on both ; ; destroyed - rsi + rax, rcx, rdx, r8, r9, r10 & r11 ; registers - rdi on both ; ; The default convention is that for windows, the gnu/linux convention being ; used if __GNUC__ is defined. ; ; Define _SEH_ to include support for Win64 structured exception handling ; (this requires YASM version 0.6 or later). ; ; This code provides the standard AES block size (128 bits, 16 bytes) and the ; three standard AES key sizes (128, 192 and 256 bits). It has the same call ; interface as my C implementation. It uses the Microsoft C AMD64 calling ; conventions in which the three parameters are placed in rcx, rdx and r8 ; respectively. The rbx, rsi, rdi, rbp and r12..r15 registers are preserved. ; ; AES_RETURN aes_encrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; where is 128, 102 or 256. In the last two calls the length can be in ; either bits or bytes. ; ; Comment in/out the following lines to obtain the desired subroutines. These ; selections MUST match those in the C header files aes.h and aesopt.h %define USE_INTEL_AES_IF_AVAILABLE %define AES_128 ; define if AES with 128 bit keys is needed %define AES_192 ; define if AES with 192 bit keys is needed %define AES_256 ; define if AES with 256 bit keys is needed %define AES_VAR ; define if a variable key size is needed %define ENCRYPTION ; define if encryption is needed %define DECRYPTION ; define if decryption is needed %ifdef USE_INTEL_AES_IF_AVAILABLE %define aes_ni(x) aes_ %+ x %+ _i %undef AES_REV_DKS %else %define aes_ni(x) aes_ %+ x %define AES_REV_DKS %endif %define LAST_ROUND_TABLES ; define for the faster version using extra tables ; The encryption key schedule has the following in memory layout where N is the ; number of rounds (10, 12 or 14): ; ; lo: | input key (round 0) | ; each round is four 32-bit words ; | encryption round 1 | ; | encryption round 2 | ; .... ; | encryption round N-1 | ; hi: | encryption round N | ; ; The decryption key schedule is normally set up so that it has the same ; layout as above by actually reversing the order of the encryption key ; schedule in memory (this happens when AES_REV_DKS is set): ; ; lo: | decryption round 0 | = | encryption round N | ; | decryption round 1 | = INV_MIX_COL[ | encryption round N-1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round N-2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round 1 | ] ; hi: | decryption round N | = | input key (round 0) | ; ; with rounds except the first and last modified using inv_mix_column() ; But if AES_REV_DKS is NOT set the order of keys is left as it is for ; encryption so that it has to be accessed in reverse when used for ; decryption (although the inverse mix column modifications are done) ; ; lo: | decryption round 0 | = | input key (round 0) | ; | decryption round 1 | = INV_MIX_COL[ | encryption round 1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round 2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round N-1 | ] ; hi: | decryption round N | = | encryption round N | ; ; This layout is faster when the assembler key scheduling provided here ; is used. ; ; The DLL interface must use the _stdcall convention in which the number ; of bytes of parameter space is added after an @ to the sutine's name. ; We must also remove our parameters from the stack before return (see ; the do_exit macro). Define DLL_EXPORT for the Dynamic Link Library version. ;%define DLL_EXPORT ; End of user defines %ifdef AES_VAR %ifndef AES_128 %define AES_128 %endif %ifndef AES_192 %define AES_192 %endif %ifndef AES_256 %define AES_256 %endif %endif %ifdef AES_VAR %define KS_LENGTH 60 %elifdef AES_256 %define KS_LENGTH 60 %elifdef AES_192 %define KS_LENGTH 52 %else %define KS_LENGTH 44 %endif %define r0 rax %define r1 rdx %define r2 rcx %define r3 rbx %define r4 rsi %define r5 rdi %define r6 rbp %define r7 rsp %define raxd eax %define rdxd edx %define rcxd ecx %define rbxd ebx %define rsid esi %define rdid edi %define rbpd ebp %define rspd esp %define raxb al %define rdxb dl %define rcxb cl %define rbxb bl %define rsib sil %define rdib dil %define rbpb bpl %define rspb spl %define r0h ah %define r1h dh %define r2h ch %define r3h bh %define r0d eax %define r1d edx %define r2d ecx %define r3d ebx ; finite field multiplies by {02}, {04} and {08} %define f2(x) ((x<<1)^(((x>>7)&1)*0x11b)) %define f4(x) ((x<<2)^(((x>>6)&1)*0x11b)^(((x>>6)&2)*0x11b)) %define f8(x) ((x<<3)^(((x>>5)&1)*0x11b)^(((x>>5)&2)*0x11b)^(((x>>5)&4)*0x11b)) ; finite field multiplies required in table generation %define f3(x) (f2(x) ^ x) %define f9(x) (f8(x) ^ x) %define fb(x) (f8(x) ^ f2(x) ^ x) %define fd(x) (f8(x) ^ f4(x) ^ x) %define fe(x) (f8(x) ^ f4(x) ^ f2(x)) ; macro for expanding S-box data %macro enc_vals 1 db %1(0x63),%1(0x7c),%1(0x77),%1(0x7b),%1(0xf2),%1(0x6b),%1(0x6f),%1(0xc5) db %1(0x30),%1(0x01),%1(0x67),%1(0x2b),%1(0xfe),%1(0xd7),%1(0xab),%1(0x76) db %1(0xca),%1(0x82),%1(0xc9),%1(0x7d),%1(0xfa),%1(0x59),%1(0x47),%1(0xf0) db %1(0xad),%1(0xd4),%1(0xa2),%1(0xaf),%1(0x9c),%1(0xa4),%1(0x72),%1(0xc0) db %1(0xb7),%1(0xfd),%1(0x93),%1(0x26),%1(0x36),%1(0x3f),%1(0xf7),%1(0xcc) db %1(0x34),%1(0xa5),%1(0xe5),%1(0xf1),%1(0x71),%1(0xd8),%1(0x31),%1(0x15) db %1(0x04),%1(0xc7),%1(0x23),%1(0xc3),%1(0x18),%1(0x96),%1(0x05),%1(0x9a) db %1(0x07),%1(0x12),%1(0x80),%1(0xe2),%1(0xeb),%1(0x27),%1(0xb2),%1(0x75) db %1(0x09),%1(0x83),%1(0x2c),%1(0x1a),%1(0x1b),%1(0x6e),%1(0x5a),%1(0xa0) db %1(0x52),%1(0x3b),%1(0xd6),%1(0xb3),%1(0x29),%1(0xe3),%1(0x2f),%1(0x84) db %1(0x53),%1(0xd1),%1(0x00),%1(0xed),%1(0x20),%1(0xfc),%1(0xb1),%1(0x5b) db %1(0x6a),%1(0xcb),%1(0xbe),%1(0x39),%1(0x4a),%1(0x4c),%1(0x58),%1(0xcf) db %1(0xd0),%1(0xef),%1(0xaa),%1(0xfb),%1(0x43),%1(0x4d),%1(0x33),%1(0x85) db %1(0x45),%1(0xf9),%1(0x02),%1(0x7f),%1(0x50),%1(0x3c),%1(0x9f),%1(0xa8) db %1(0x51),%1(0xa3),%1(0x40),%1(0x8f),%1(0x92),%1(0x9d),%1(0x38),%1(0xf5) db %1(0xbc),%1(0xb6),%1(0xda),%1(0x21),%1(0x10),%1(0xff),%1(0xf3),%1(0xd2) db %1(0xcd),%1(0x0c),%1(0x13),%1(0xec),%1(0x5f),%1(0x97),%1(0x44),%1(0x17) db %1(0xc4),%1(0xa7),%1(0x7e),%1(0x3d),%1(0x64),%1(0x5d),%1(0x19),%1(0x73) db %1(0x60),%1(0x81),%1(0x4f),%1(0xdc),%1(0x22),%1(0x2a),%1(0x90),%1(0x88) db %1(0x46),%1(0xee),%1(0xb8),%1(0x14),%1(0xde),%1(0x5e),%1(0x0b),%1(0xdb) db %1(0xe0),%1(0x32),%1(0x3a),%1(0x0a),%1(0x49),%1(0x06),%1(0x24),%1(0x5c) db %1(0xc2),%1(0xd3),%1(0xac),%1(0x62),%1(0x91),%1(0x95),%1(0xe4),%1(0x79) db %1(0xe7),%1(0xc8),%1(0x37),%1(0x6d),%1(0x8d),%1(0xd5),%1(0x4e),%1(0xa9) db %1(0x6c),%1(0x56),%1(0xf4),%1(0xea),%1(0x65),%1(0x7a),%1(0xae),%1(0x08) db %1(0xba),%1(0x78),%1(0x25),%1(0x2e),%1(0x1c),%1(0xa6),%1(0xb4),%1(0xc6) db %1(0xe8),%1(0xdd),%1(0x74),%1(0x1f),%1(0x4b),%1(0xbd),%1(0x8b),%1(0x8a) db %1(0x70),%1(0x3e),%1(0xb5),%1(0x66),%1(0x48),%1(0x03),%1(0xf6),%1(0x0e) db %1(0x61),%1(0x35),%1(0x57),%1(0xb9),%1(0x86),%1(0xc1),%1(0x1d),%1(0x9e) db %1(0xe1),%1(0xf8),%1(0x98),%1(0x11),%1(0x69),%1(0xd9),%1(0x8e),%1(0x94) db %1(0x9b),%1(0x1e),%1(0x87),%1(0xe9),%1(0xce),%1(0x55),%1(0x28),%1(0xdf) db %1(0x8c),%1(0xa1),%1(0x89),%1(0x0d),%1(0xbf),%1(0xe6),%1(0x42),%1(0x68) db %1(0x41),%1(0x99),%1(0x2d),%1(0x0f),%1(0xb0),%1(0x54),%1(0xbb),%1(0x16) %endmacro %macro dec_vals 1 db %1(0x52),%1(0x09),%1(0x6a),%1(0xd5),%1(0x30),%1(0x36),%1(0xa5),%1(0x38) db %1(0xbf),%1(0x40),%1(0xa3),%1(0x9e),%1(0x81),%1(0xf3),%1(0xd7),%1(0xfb) db %1(0x7c),%1(0xe3),%1(0x39),%1(0x82),%1(0x9b),%1(0x2f),%1(0xff),%1(0x87) db %1(0x34),%1(0x8e),%1(0x43),%1(0x44),%1(0xc4),%1(0xde),%1(0xe9),%1(0xcb) db %1(0x54),%1(0x7b),%1(0x94),%1(0x32),%1(0xa6),%1(0xc2),%1(0x23),%1(0x3d) db %1(0xee),%1(0x4c),%1(0x95),%1(0x0b),%1(0x42),%1(0xfa),%1(0xc3),%1(0x4e) db %1(0x08),%1(0x2e),%1(0xa1),%1(0x66),%1(0x28),%1(0xd9),%1(0x24),%1(0xb2) db %1(0x76),%1(0x5b),%1(0xa2),%1(0x49),%1(0x6d),%1(0x8b),%1(0xd1),%1(0x25) db %1(0x72),%1(0xf8),%1(0xf6),%1(0x64),%1(0x86),%1(0x68),%1(0x98),%1(0x16) db %1(0xd4),%1(0xa4),%1(0x5c),%1(0xcc),%1(0x5d),%1(0x65),%1(0xb6),%1(0x92) db %1(0x6c),%1(0x70),%1(0x48),%1(0x50),%1(0xfd),%1(0xed),%1(0xb9),%1(0xda) db %1(0x5e),%1(0x15),%1(0x46),%1(0x57),%1(0xa7),%1(0x8d),%1(0x9d),%1(0x84) db %1(0x90),%1(0xd8),%1(0xab),%1(0x00),%1(0x8c),%1(0xbc),%1(0xd3),%1(0x0a) db %1(0xf7),%1(0xe4),%1(0x58),%1(0x05),%1(0xb8),%1(0xb3),%1(0x45),%1(0x06) db %1(0xd0),%1(0x2c),%1(0x1e),%1(0x8f),%1(0xca),%1(0x3f),%1(0x0f),%1(0x02) db %1(0xc1),%1(0xaf),%1(0xbd),%1(0x03),%1(0x01),%1(0x13),%1(0x8a),%1(0x6b) db %1(0x3a),%1(0x91),%1(0x11),%1(0x41),%1(0x4f),%1(0x67),%1(0xdc),%1(0xea) db %1(0x97),%1(0xf2),%1(0xcf),%1(0xce),%1(0xf0),%1(0xb4),%1(0xe6),%1(0x73) db %1(0x96),%1(0xac),%1(0x74),%1(0x22),%1(0xe7),%1(0xad),%1(0x35),%1(0x85) db %1(0xe2),%1(0xf9),%1(0x37),%1(0xe8),%1(0x1c),%1(0x75),%1(0xdf),%1(0x6e) db %1(0x47),%1(0xf1),%1(0x1a),%1(0x71),%1(0x1d),%1(0x29),%1(0xc5),%1(0x89) db %1(0x6f),%1(0xb7),%1(0x62),%1(0x0e),%1(0xaa),%1(0x18),%1(0xbe),%1(0x1b) db %1(0xfc),%1(0x56),%1(0x3e),%1(0x4b),%1(0xc6),%1(0xd2),%1(0x79),%1(0x20) db %1(0x9a),%1(0xdb),%1(0xc0),%1(0xfe),%1(0x78),%1(0xcd),%1(0x5a),%1(0xf4) db %1(0x1f),%1(0xdd),%1(0xa8),%1(0x33),%1(0x88),%1(0x07),%1(0xc7),%1(0x31) db %1(0xb1),%1(0x12),%1(0x10),%1(0x59),%1(0x27),%1(0x80),%1(0xec),%1(0x5f) db %1(0x60),%1(0x51),%1(0x7f),%1(0xa9),%1(0x19),%1(0xb5),%1(0x4a),%1(0x0d) db %1(0x2d),%1(0xe5),%1(0x7a),%1(0x9f),%1(0x93),%1(0xc9),%1(0x9c),%1(0xef) db %1(0xa0),%1(0xe0),%1(0x3b),%1(0x4d),%1(0xae),%1(0x2a),%1(0xf5),%1(0xb0) db %1(0xc8),%1(0xeb),%1(0xbb),%1(0x3c),%1(0x83),%1(0x53),%1(0x99),%1(0x61) db %1(0x17),%1(0x2b),%1(0x04),%1(0x7e),%1(0xba),%1(0x77),%1(0xd6),%1(0x26) db %1(0xe1),%1(0x69),%1(0x14),%1(0x63),%1(0x55),%1(0x21),%1(0x0c),%1(0x7d) %endmacro %define u8(x) f2(x), x, x, f3(x), f2(x), x, x, f3(x) %define v8(x) fe(x), f9(x), fd(x), fb(x), fe(x), f9(x), fd(x), x %define w8(x) x, 0, 0, 0, x, 0, 0, 0 %define tptr rbp ; table pointer %define kptr r8 ; key schedule pointer %define fofs 128 ; adjust offset in key schedule to keep |disp| < 128 %define fk_ref(x,y) [kptr-16*x+fofs+4*y] %ifdef AES_REV_DKS %define rofs 128 %define ik_ref(x,y) [kptr-16*x+rofs+4*y] %else %define rofs -128 %define ik_ref(x,y) [kptr+16*x+rofs+4*y] %endif %define tab_0(x) [tptr+8*x] %define tab_1(x) [tptr+8*x+3] %define tab_2(x) [tptr+8*x+2] %define tab_3(x) [tptr+8*x+1] %define tab_f(x) byte [tptr+8*x+1] %define tab_i(x) byte [tptr+8*x+7] %define t_ref(x,r) tab_ %+ x(r) %macro ff_rnd 5 ; normal forward round mov %1d, fk_ref(%5,0) mov %2d, fk_ref(%5,1) mov %3d, fk_ref(%5,2) mov %4d, fk_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) mov eax,%1d mov ebx,%2d mov ecx,%3d mov edx,%4d %endmacro %ifdef LAST_ROUND_TABLES %macro fl_rnd 5 ; last forward round add tptr, 2048 mov %1d, fk_ref(%5,0) mov %2d, fk_ref(%5,1) mov %3d, fk_ref(%5,2) mov %4d, fk_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) %endmacro %else %macro fl_rnd 5 ; last forward round mov %1d, fk_ref(%5,0) mov %2d, fk_ref(%5,1) mov %3d, fk_ref(%5,2) mov %4d, fk_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) xor %1d, esi rol edi, 8 xor %4d, edi movzx esi, al movzx edi, ah movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %3d, esi xor %2d, edi movzx esi, bl movzx edi, bh shr ebx, 16 movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) xor %2d, esi rol edi, 8 xor %1d, edi movzx esi, bl movzx edi, bh movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %4d, esi xor %3d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) shr ecx, 16 xor %3d, esi rol edi, 8 xor %2d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %1d, esi xor %4d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) shr edx, 16 xor %4d, esi rol edi, 8 xor %3d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %2d, esi xor %1d, edi %endmacro %endif %macro ii_rnd 5 ; normal inverse round mov %1d, ik_ref(%5,0) mov %2d, ik_ref(%5,1) mov %3d, ik_ref(%5,2) mov %4d, ik_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) mov eax,%1d mov ebx,%2d mov ecx,%3d mov edx,%4d %endmacro %ifdef LAST_ROUND_TABLES %macro il_rnd 5 ; last inverse round add tptr, 2048 mov %1d, ik_ref(%5,0) mov %2d, ik_ref(%5,1) mov %3d, ik_ref(%5,2) mov %4d, ik_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) %endmacro %else %macro il_rnd 5 ; last inverse round mov %1d, ik_ref(%5,0) mov %2d, ik_ref(%5,1) mov %3d, ik_ref(%5,2) mov %4d, ik_ref(%5,3) movzx esi, al movzx edi, ah movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr eax, 16 xor %1d, esi rol edi, 8 xor %2d, edi movzx esi, al movzx edi, ah movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %3d, esi xor %4d, edi movzx esi, bl movzx edi, bh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr ebx, 16 xor %2d, esi rol edi, 8 xor %3d, edi movzx esi, bl movzx edi, bh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %4d, esi xor %1d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr ecx, 16 xor %3d, esi rol edi, 8 xor %4d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %1d, esi xor %2d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr edx, 16 xor %4d, esi rol edi, 8 xor %1d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %2d, esi xor %3d, edi %endmacro %endif %ifdef ENCRYPTION global aes_ni(encrypt) %ifdef DLL_EXPORT export aes_ni(encrypt) %endif section .data align=64 align 64 enc_tab: enc_vals u8 %ifdef LAST_ROUND_TABLES enc_vals w8 %endif section .text align=16 align 16 %ifdef _SEH_ proc_frame aes_ni(encrypt) alloc_stack 7*8 ; 7 to align stack to 16 bytes save_reg rsi,4*8 save_reg rdi,5*8 save_reg rbx,1*8 save_reg rbp,2*8 save_reg r12,3*8 end_prologue mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %else aes_ni(encrypt): %ifdef __GNUC__ sub rsp, 4*8 ; gnu/linux binary interface mov [rsp+0*8], rsi ; output pointer mov r8, rdx ; context %else sub rsp, 6*8 ; windows binary interface mov [rsp+4*8], rsi mov [rsp+5*8], rdi mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %endif mov [rsp+1*8], rbx ; input pointer in rdi mov [rsp+2*8], rbp ; output pointer in [rsp] mov [rsp+3*8], r12 ; context in r8 %endif movzx esi, byte [kptr+4*KS_LENGTH] lea tptr, [rel enc_tab] sub kptr, fofs mov eax, [rdi+0*4] mov ebx, [rdi+1*4] mov ecx, [rdi+2*4] mov edx, [rdi+3*4] xor eax, [kptr+fofs] xor ebx, [kptr+fofs+4] xor ecx, [kptr+fofs+8] xor edx, [kptr+fofs+12] lea kptr,[kptr+rsi] cmp esi, 10*16 je .3 cmp esi, 12*16 je .2 cmp esi, 14*16 je .1 mov rax, -1 jmp .4 .1: ff_rnd r9, r10, r11, r12, 13 ff_rnd r9, r10, r11, r12, 12 .2: ff_rnd r9, r10, r11, r12, 11 ff_rnd r9, r10, r11, r12, 10 .3: ff_rnd r9, r10, r11, r12, 9 ff_rnd r9, r10, r11, r12, 8 ff_rnd r9, r10, r11, r12, 7 ff_rnd r9, r10, r11, r12, 6 ff_rnd r9, r10, r11, r12, 5 ff_rnd r9, r10, r11, r12, 4 ff_rnd r9, r10, r11, r12, 3 ff_rnd r9, r10, r11, r12, 2 ff_rnd r9, r10, r11, r12, 1 fl_rnd r9, r10, r11, r12, 0 mov rbx, [rsp] mov [rbx], r9d mov [rbx+4], r10d mov [rbx+8], r11d mov [rbx+12], r12d xor rax, rax .4: mov rbx, [rsp+1*8] mov rbp, [rsp+2*8] mov r12, [rsp+3*8] %ifdef __GNUC__ add rsp, 4*8 ret %else mov rsi, [rsp+4*8] mov rdi, [rsp+5*8] %ifdef _SEH_ add rsp, 7*8 ret endproc_frame %else add rsp, 6*8 ret %endif %endif %endif %ifdef DECRYPTION global aes_ni(decrypt) %ifdef DLL_EXPORT export aes_ni(decrypt) %endif section .data align 64 dec_tab: dec_vals v8 %ifdef LAST_ROUND_TABLES dec_vals w8 %endif section .text align 16 %ifdef _SEH_ proc_frame aes_ni(decrypt) alloc_stack 7*8 ; 7 to align stack to 16 bytes save_reg rsi,4*8 save_reg rdi,5*8 save_reg rbx,1*8 save_reg rbp,2*8 save_reg r12,3*8 end_prologue mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %else aes_ni(decrypt): %ifdef __GNUC__ sub rsp, 4*8 ; gnu/linux binary interface mov [rsp+0*8], rsi ; output pointer mov r8, rdx ; context %else sub rsp, 6*8 ; windows binary interface mov [rsp+4*8], rsi mov [rsp+5*8], rdi mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %endif mov [rsp+1*8], rbx ; input pointer in rdi mov [rsp+2*8], rbp ; output pointer in [rsp] mov [rsp+3*8], r12 ; context in r8 %endif movzx esi, byte[kptr+4*KS_LENGTH] lea tptr, [rel dec_tab] sub kptr, rofs mov eax, [rdi+0*4] mov ebx, [rdi+1*4] mov ecx, [rdi+2*4] mov edx, [rdi+3*4] %ifdef AES_REV_DKS mov rdi, kptr lea kptr,[kptr+rsi] %else lea rdi,[kptr+rsi] %endif xor eax, [rdi+rofs] xor ebx, [rdi+rofs+4] xor ecx, [rdi+rofs+8] xor edx, [rdi+rofs+12] cmp esi, 10*16 je .3 cmp esi, 12*16 je .2 cmp esi, 14*16 je .1 mov rax, -1 jmp .4 .1: ii_rnd r9, r10, r11, r12, 13 ii_rnd r9, r10, r11, r12, 12 .2: ii_rnd r9, r10, r11, r12, 11 ii_rnd r9, r10, r11, r12, 10 .3: ii_rnd r9, r10, r11, r12, 9 ii_rnd r9, r10, r11, r12, 8 ii_rnd r9, r10, r11, r12, 7 ii_rnd r9, r10, r11, r12, 6 ii_rnd r9, r10, r11, r12, 5 ii_rnd r9, r10, r11, r12, 4 ii_rnd r9, r10, r11, r12, 3 ii_rnd r9, r10, r11, r12, 2 ii_rnd r9, r10, r11, r12, 1 il_rnd r9, r10, r11, r12, 0 mov rbx, [rsp] mov [rbx], r9d mov [rbx+4], r10d mov [rbx+8], r11d mov [rbx+12], r12d xor rax, rax .4: mov rbx, [rsp+1*8] mov rbp, [rsp+2*8] mov r12, [rsp+3*8] %ifdef __GNUC__ add rsp, 4*8 ret %else mov rsi, [rsp+4*8] mov rdi, [rsp+5*8] %ifdef _SEH_ add rsp, 7*8 ret endproc_frame %else add rsp, 6*8 ret %endif %endif %endif end MediaInfoLib/Source/ThirdParty/aes-gladman/aesxam.c0000664000000000000000000003642112652076434021204 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ // An example of the use of AES (Rijndael) for file encryption. This code // implements AES in CBC mode with ciphertext stealing when the file length // is greater than one block (16 bytes). This code is an example of how to // use AES and is not intended for real use since it does not provide any // file integrity checking. // // The Command line is: // // aesxam input_file_name output_file_name [D|E] hexadecimalkey // // where E gives encryption and D decryption of the input file into the // output file using the given hexadecimal key string. The later is a // hexadecimal sequence of 32, 48 or 64 digits. Examples to encrypt or // decrypt aes.c into aes.enc are: // // aesxam file.c file.enc E 0123456789abcdeffedcba9876543210 // // aesxam file.enc file2.c D 0123456789abcdeffedcba9876543210 // // which should return a file 'file2.c' identical to 'file.c' // // CIPHERTEXT STEALING // // Ciphertext stealing modifies the encryption of the last two CBC // blocks. It can be applied invariably to the last two plaintext // blocks or only applied when the last block is a partial one. In // this code it is only applied if there is a partial block. For // a plaintext consisting of N blocks, with the last block possibly // a partial one, ciphertext stealing works as shown below (note the // reversal of the last two ciphertext blocks). During decryption // the part of the C:N-1 block that is not transmitted (X) can be // obtained from the decryption of the penultimate ciphertext block // since the bytes in X are xored with the zero padding appended to // the last plaintext block. // // This is a picture of the processing of the last // plaintext blocks during encryption: // // +---------+ +---------+ +---------+ +-------+-+ // | P:N-4 | | P:N-3 | | P:N-2 | | P:N-1 |0| // +---------+ +---------+ +---------+ +-------+-+ // | | | | // v v v v // +----->x +----->x +----->x +----->x x = xor // | | | | | | | | // | v | v | v | v // | +---+ | +---+ | +---+ | +---+ // | | E | | | E | | | E | | | E | // | +---+ | +---+ | +---+ | +---+ // | | | | | | | | // | | | | | v | +---+ // | | | | | +-------+-+ | | // | | | | | | C:N-1 |X| | | // | | | | | +-------+-+ ^ | // | | | | | || | | // | | | | | |+------+ | // | | | | | +----------|--+ // | | | | | | | // | | | | | +---------+ | // | | | | | | | // | v | v | v v // | +---------+ | +---------+ | +---------+ +-------+ // -+ | C:N-4 |-+ | C:N-3 |-+ | C:N-2 | | C:N-1 | // +---------+ +---------+ +---------+ +-------+ // // And this is a picture of the processing of the last // ciphertext blocks during decryption: // // +---------+ +---------+ +---------+ +-------+ // -+ | C:N-4 |-+ | C:N-3 |-+ | C:N-2 | | C:N-1 | // | +---------+ | +---------+ | +---------+ +-------+ // | | | | | | | // | v | v | v +--------|----+ // | +---+ | +---+ | +---+ | +--<--+ | // | | D | | | D | | | D | | | | | // | +---+ | +---+ | +---+ | | v v // | | | | | | ^ | +-------+-+ // | v | v | v | | | C:N-1 |X| // +----->x +----->x | +-------+-+ | +-------+-+ // | | | | |X| | | // | | | +-------+-+ | v // | | | | | +---+ // | | | | v | D | // | | | +------>x +---+ // | | | | | // | | +----->x<-----|------+ x = xor // | | | +-----+ // | | | | // v v v v // +---------+ +---------+ +---------+ +-------+ // | P:N-4 | | P:N-3 | | P:N-2 | | P:N-1 | // +---------+ +---------+ +---------+ +-------+ #include #include #include "aes.h" #include "rdtsc.h" #define BLOCK_LEN 16 #define OK 0 #define READ_ERROR -7 #define WRITE_ERROR -8 // A Pseudo Random Number Generator (PRNG) used for the // Initialisation Vector. The PRNG is George Marsaglia's // Multiply-With-Carry (MWC) PRNG that concatenates two // 16-bit MWC generators: // x(n)=36969 * x(n-1) + carry mod 2^16 // y(n)=18000 * y(n-1) + carry mod 2^16 // to produce a combined PRNG with a period of about 2^60. // The Pentium cycle counter is used to initialise it. This // is crude but the IV does not really need to be secret. #define RAND(a,b) (((a = 36969 * (a & 65535) + (a >> 16)) << 16) + \ (b = 18000 * (b & 65535) + (b >> 16)) ) void fillrand(unsigned char *buf, const int len) { static unsigned long a[2], mt = 1, count = 4; static unsigned char r[4]; int i; if(mt) { mt = 0; *(unsigned long long*)a = read_tsc(); } for(i = 0; i < len; ++i) { if(count == 4) { *(unsigned long*)r = RAND(a[0], a[1]); count = 0; } buf[i] = r[count++]; } } int encfile(FILE *fin, FILE *fout, aes_encrypt_ctx ctx[1]) { unsigned char dbuf[3 * BLOCK_LEN]; unsigned long i, len, wlen = BLOCK_LEN; // When ciphertext stealing is used, we three ciphertext blocks so // we use a buffer that is three times the block length. The buffer // pointers b1, b2 and b3 point to the buffer positions of three // ciphertext blocks, b3 being the most recent and b1 being the // oldest. We start with the IV in b1 and the block to be decrypted // in b2. // set a random IV fillrand(dbuf, BLOCK_LEN); // read the first file block len = (unsigned long) fread((char*)dbuf + BLOCK_LEN, 1, BLOCK_LEN, fin); if(len < BLOCK_LEN) { // if the file length is less than one block // xor the file bytes with the IV bytes for(i = 0; i < len; ++i) dbuf[i + BLOCK_LEN] ^= dbuf[i]; // encrypt the top 16 bytes of the buffer aes_encrypt(dbuf + len, dbuf + len, ctx); len += BLOCK_LEN; // write the IV and the encrypted file bytes if(fwrite((char*)dbuf, 1, len, fout) != len) return WRITE_ERROR; return OK; } else // if the file length is more 16 bytes { unsigned char *b1 = dbuf, *b2 = b1 + BLOCK_LEN, *b3 = b2 + BLOCK_LEN, *bt; // write the IV if(fwrite((char*)dbuf, 1, BLOCK_LEN, fout) != BLOCK_LEN) return WRITE_ERROR; for( ; ; ) { // read the next block to see if ciphertext stealing is needed len = (unsigned long)fread((char*)b3, 1, BLOCK_LEN, fin); // do CBC chaining prior to encryption for current block (in b2) for(i = 0; i < BLOCK_LEN; ++i) b1[i] ^= b2[i]; // encrypt the block (now in b1) aes_encrypt(b1, b1, ctx); if(len != 0 && len != BLOCK_LEN) // use ciphertext stealing { // set the length of the last block wlen = len; // xor ciphertext into last block for(i = 0; i < len; ++i) b3[i] ^= b1[i]; // move 'stolen' ciphertext into last block for(i = len; i < BLOCK_LEN; ++i) b3[i] = b1[i]; // encrypt this block aes_encrypt(b3, b3, ctx); // and write it as the second to last encrypted block if(fwrite((char*)b3, 1, BLOCK_LEN, fout) != BLOCK_LEN) return WRITE_ERROR; } // write the encrypted block if(fwrite((char*)b1, 1, wlen, fout) != wlen) return WRITE_ERROR; if(len != BLOCK_LEN) return OK; // advance the buffer pointers bt = b3, b3 = b2, b2 = b1, b1 = bt; } } } int decfile(FILE *fin, FILE *fout, aes_decrypt_ctx ctx[1]) { unsigned char dbuf[3 * BLOCK_LEN], buf[BLOCK_LEN]; unsigned long i, len, wlen = BLOCK_LEN; // When ciphertext stealing is used, we three ciphertext blocks so // we use a buffer that is three times the block length. The buffer // pointers b1, b2 and b3 point to the buffer positions of three // ciphertext blocks, b3 being the most recent and b1 being the // oldest. We start with the IV in b1 and the block to be decrypted // in b2. len = (unsigned long)fread((char*)dbuf, 1, 2 * BLOCK_LEN, fin); if(len < 2 * BLOCK_LEN) // the original file is less than one block in length { len -= BLOCK_LEN; // decrypt from position len to position len + BLOCK_LEN aes_decrypt(dbuf + len, dbuf + len, ctx); // undo the CBC chaining for(i = 0; i < len; ++i) dbuf[i] ^= dbuf[i + BLOCK_LEN]; // output the decrypted bytes if(fwrite((char*)dbuf, 1, len, fout) != len) return WRITE_ERROR; return OK; } else { unsigned char *b1 = dbuf, *b2 = b1 + BLOCK_LEN, *b3 = b2 + BLOCK_LEN, *bt; for( ; ; ) // while some ciphertext remains, prepare to decrypt block b2 { // read in the next block to see if ciphertext stealing is needed len = fread((char*)b3, 1, BLOCK_LEN, fin); // decrypt the b2 block aes_decrypt(b2, buf, ctx); if(len == 0 || len == BLOCK_LEN) // no ciphertext stealing { // unchain CBC using the previous ciphertext block in b1 for(i = 0; i < BLOCK_LEN; ++i) buf[i] ^= b1[i]; } else // partial last block - use ciphertext stealing { wlen = len; // produce last 'len' bytes of plaintext by xoring with // the lowest 'len' bytes of next block b3 - C[N-1] for(i = 0; i < len; ++i) buf[i] ^= b3[i]; // reconstruct the C[N-1] block in b3 by adding in the // last (BLOCK_LEN - len) bytes of C[N-2] in b2 for(i = len; i < BLOCK_LEN; ++i) b3[i] = buf[i]; // decrypt the C[N-1] block in b3 aes_decrypt(b3, b3, ctx); // produce the last but one plaintext block by xoring with // the last but two ciphertext block for(i = 0; i < BLOCK_LEN; ++i) b3[i] ^= b1[i]; // write decrypted plaintext blocks if(fwrite((char*)b3, 1, BLOCK_LEN, fout) != BLOCK_LEN) return WRITE_ERROR; } // write the decrypted plaintext block if(fwrite((char*)buf, 1, wlen, fout) != wlen) return WRITE_ERROR; if(len != BLOCK_LEN) return OK; // advance the buffer pointers bt = b1, b1 = b2, b2 = b3, b3 = bt; } } } int main(int argc, char *argv[]) { FILE *fin = 0, *fout = 0; char *cp, ch, key[32]; int i, by = 0, key_len, err = 0; if(argc != 5 || toupper(*argv[3]) != 'D' && toupper(*argv[3]) != 'E') { printf("usage: aesxam in_filename out_filename [d/e] key_in_hex\n"); err = -1; goto exit; } aes_init(); // in case dynamic AES tables are being used cp = argv[4]; // this is a pointer to the hexadecimal key digits i = 0; // this is a count for the input digits processed while(i < 64 && *cp) // the maximum key length is 32 bytes and { // hence at most 64 hexadecimal digits ch = toupper(*cp++); // process a hexadecimal digit if(ch >= '0' && ch <= '9') by = (by << 4) + ch - '0'; else if(ch >= 'A' && ch <= 'F') by = (by << 4) + ch - 'A' + 10; else // error if not hexadecimal { printf("key must be in hexadecimal notation\n"); err = -2; goto exit; } // store a key byte for each pair of hexadecimal digits if(i++ & 1) key[i / 2 - 1] = by & 0xff; } if(*cp) { printf("The key value is too long\n"); err = -3; goto exit; } else if(i < 32 || (i & 15)) { printf("The key length must be 32, 48 or 64 hexadecimal digits\n"); err = -4; goto exit; } key_len = i / 2; if(!(fin = fopen(argv[1], "rb"))) // try to open the input file { printf("The input file: %s could not be opened\n", argv[1]); err = -5; goto exit; } if(!(fout = fopen(argv[2], "wb"))) // try to open the output file { printf("The output file: %s could not be opened\n", argv[2]); err = -6; goto exit; } if(toupper(*argv[3]) == 'E') // encryption in Cipher Block Chaining mode { aes_encrypt_ctx ctx[1]; aes_encrypt_key((unsigned char*)key, key_len, ctx); err = encfile(fin, fout, ctx); } else // decryption in Cipher Block Chaining mode { aes_decrypt_ctx ctx[1]; aes_decrypt_key((unsigned char*)key, key_len, ctx); err = decfile(fin, fout, ctx); } exit: if(err == READ_ERROR) printf("Error reading from input file: %s\n", argv[1]); if(err == WRITE_ERROR) printf("Error writing to output file: %s\n", argv[2]); if(fout) fclose(fout); if(fin) fclose(fin); return err; } MediaInfoLib/Source/ThirdParty/aes-gladman/aes_modes.c0000664000000000000000000007530012652076434021664 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 These subroutines implement multiple block AES modes for ECB, CBC, CFB, OFB and CTR encryption, The code provides support for the VIA Advanced Cryptography Engine (ACE). NOTE: In the following subroutines, the AES contexts (ctx) must be 16 byte aligned if VIA ACE is being used */ #include #include #include #include "aesopt.h" #if defined( AES_MODES ) #if defined(__cplusplus) extern "C" { #endif #if defined( _MSC_VER ) && ( _MSC_VER > 800 ) #pragma intrinsic(memcpy) #endif #define BFR_BLOCKS 8 /* These values are used to detect long word alignment in order to */ /* speed up some buffer operations. This facility may not work on */ /* some machines so this define can be commented out if necessary */ #define FAST_BUFFER_OPERATIONS #define lp32(x) ((uint32_t*)(x)) #if defined( USE_VIA_ACE_IF_PRESENT ) #include "aes_via_ace.h" #pragma pack(16) aligned_array(unsigned long, enc_gen_table, 12, 16) = NEH_ENC_GEN_DATA; aligned_array(unsigned long, enc_load_table, 12, 16) = NEH_ENC_LOAD_DATA; aligned_array(unsigned long, enc_hybrid_table, 12, 16) = NEH_ENC_HYBRID_DATA; aligned_array(unsigned long, dec_gen_table, 12, 16) = NEH_DEC_GEN_DATA; aligned_array(unsigned long, dec_load_table, 12, 16) = NEH_DEC_LOAD_DATA; aligned_array(unsigned long, dec_hybrid_table, 12, 16) = NEH_DEC_HYBRID_DATA; /* NOTE: These control word macros must only be used after */ /* a key has been set up because they depend on key size */ /* See the VIA ACE documentation for key type information */ /* and aes_via_ace.h for non-default NEH_KEY_TYPE values */ #ifndef NEH_KEY_TYPE # define NEH_KEY_TYPE NEH_HYBRID #endif #if NEH_KEY_TYPE == NEH_LOAD #define kd_adr(c) ((uint8_t*)(c)->ks) #elif NEH_KEY_TYPE == NEH_GENERATE #define kd_adr(c) ((uint8_t*)(c)->ks + (c)->inf.b[0]) #elif NEH_KEY_TYPE == NEH_HYBRID #define kd_adr(c) ((uint8_t*)(c)->ks + ((c)->inf.b[0] == 160 ? 160 : 0)) #else #error no key type defined for VIA ACE #endif #else #define aligned_array(type, name, no, stride) type name[no] #define aligned_auto(type, name, no, stride) type name[no] #endif #if defined( _MSC_VER ) && _MSC_VER > 1200 #define via_cwd(cwd, ty, dir, len) \ unsigned long* cwd = (dir##_##ty##_table + ((len - 128) >> 4)) #else #define via_cwd(cwd, ty, dir, len) \ aligned_auto(unsigned long, cwd, 4, 16); \ cwd[1] = cwd[2] = cwd[3] = 0; \ cwd[0] = neh_##dir##_##ty##_key(len) #endif /* test the code for detecting and setting pointer alignment */ AES_RETURN aes_test_alignment_detection(unsigned int n) /* 4 <= n <= 16 */ { uint8_t p[16]; uint32_t i, count_eq = 0, count_neq = 0; if(n < 4 || n > 16) return EXIT_FAILURE; for(i = 0; i < n; ++i) { uint8_t *qf = ALIGN_FLOOR(p + i, n), *qh = ALIGN_CEIL(p + i, n); if(qh == qf) ++count_eq; else if(qh == qf + n) ++count_neq; else return EXIT_FAILURE; } return (count_eq != 1 || count_neq != n - 1 ? EXIT_FAILURE : EXIT_SUCCESS); } AES_RETURN aes_mode_reset(aes_encrypt_ctx ctx[1]) { ctx->inf.b[2] = 0; return EXIT_SUCCESS; } AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_encrypt_ctx ctx[1]) { int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint8_t *ksp = (uint8_t*)(ctx->ks); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_ecb_op5(ksp, cwd, ibuf, obuf, nb); } else { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_ecb_op5(ksp, cwd, ip, op, m); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) while(nb--) { if(aes_encrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_decrypt_ctx ctx[1]) { int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint8_t *ksp = kd_adr(ctx); via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_ecb_op5(ksp, cwd, ibuf, obuf, nb); } else { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_ecb_op5(ksp, cwd, ip, op, m); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) while(nb--) { if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_encrypt_ctx ctx[1]) { int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 ) && !ALIGN_OFFSET( iv, 16 )) { via_cbc_op7(ksp, cwd, ibuf, obuf, nb, ivp, ivp); } else { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cbc_op7(ksp, cwd, ip, op, m, ivp, ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } if(iv != ivp) memcpy(iv, ivp, AES_BLOCK_SIZE); return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(nb--) { lp32(iv)[0] ^= lp32(ibuf)[0]; lp32(iv)[1] ^= lp32(ibuf)[1]; lp32(iv)[2] ^= lp32(ibuf)[2]; lp32(iv)[3] ^= lp32(ibuf)[3]; if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; memcpy(obuf, iv, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } else # endif while(nb--) { iv[ 0] ^= ibuf[ 0]; iv[ 1] ^= ibuf[ 1]; iv[ 2] ^= ibuf[ 2]; iv[ 3] ^= ibuf[ 3]; iv[ 4] ^= ibuf[ 4]; iv[ 5] ^= ibuf[ 5]; iv[ 6] ^= ibuf[ 6]; iv[ 7] ^= ibuf[ 7]; iv[ 8] ^= ibuf[ 8]; iv[ 9] ^= ibuf[ 9]; iv[10] ^= ibuf[10]; iv[11] ^= ibuf[11]; iv[12] ^= ibuf[12]; iv[13] ^= ibuf[13]; iv[14] ^= ibuf[14]; iv[15] ^= ibuf[15]; if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; memcpy(obuf, iv, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_decrypt_ctx ctx[1]) { unsigned char tmp[AES_BLOCK_SIZE]; int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint8_t *ksp = kd_adr(ctx), *ivp = iv; aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 ) && !ALIGN_OFFSET( iv, 16 )) { via_cbc_op6(ksp, cwd, ibuf, obuf, nb, ivp); } else { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cbc_op6(ksp, cwd, ip, op, m, ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } if(iv != ivp) memcpy(iv, ivp, AES_BLOCK_SIZE); return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(nb--) { memcpy(tmp, ibuf, AES_BLOCK_SIZE); if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; lp32(obuf)[0] ^= lp32(iv)[0]; lp32(obuf)[1] ^= lp32(iv)[1]; lp32(obuf)[2] ^= lp32(iv)[2]; lp32(obuf)[3] ^= lp32(iv)[3]; memcpy(iv, tmp, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } else # endif while(nb--) { memcpy(tmp, ibuf, AES_BLOCK_SIZE); if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; obuf[ 0] ^= iv[ 0]; obuf[ 1] ^= iv[ 1]; obuf[ 2] ^= iv[ 2]; obuf[ 3] ^= iv[ 3]; obuf[ 4] ^= iv[ 4]; obuf[ 5] ^= iv[ 5]; obuf[ 6] ^= iv[ 6]; obuf[ 7] ^= iv[ 7]; obuf[ 8] ^= iv[ 8]; obuf[ 9] ^= iv[ 9]; obuf[10] ^= iv[10]; obuf[11] ^= iv[11]; obuf[12] ^= iv[12]; obuf[13] ^= iv[13]; obuf[14] ^= iv[14]; obuf[15] ^= iv[15]; memcpy(iv, tmp, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) { int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; if(b_pos) /* complete any partial block */ { while(b_pos < AES_BLOCK_SIZE && cnt < len) { *obuf++ = (iv[b_pos++] ^= *ibuf++); cnt++; } b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ { #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { int m; uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_cfb_op7(ksp, cwd, ibuf, obuf, nb, ivp, ivp); ibuf += nb * AES_BLOCK_SIZE; obuf += nb * AES_BLOCK_SIZE; cnt += nb * AES_BLOCK_SIZE; } else /* input, output or both are unaligned */ { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cfb_op7(ksp, cwd, ip, op, m, ivp, ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; cnt += m * AES_BLOCK_SIZE; } } if(ivp != iv) memcpy(iv, ivp, AES_BLOCK_SIZE); } #else # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; lp32(obuf)[0] = lp32(iv)[0] ^= lp32(ibuf)[0]; lp32(obuf)[1] = lp32(iv)[1] ^= lp32(ibuf)[1]; lp32(obuf)[2] = lp32(iv)[2] ^= lp32(ibuf)[2]; lp32(obuf)[3] = lp32(iv)[3] ^= lp32(ibuf)[3]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } else # endif while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; obuf[ 0] = iv[ 0] ^= ibuf[ 0]; obuf[ 1] = iv[ 1] ^= ibuf[ 1]; obuf[ 2] = iv[ 2] ^= ibuf[ 2]; obuf[ 3] = iv[ 3] ^= ibuf[ 3]; obuf[ 4] = iv[ 4] ^= ibuf[ 4]; obuf[ 5] = iv[ 5] ^= ibuf[ 5]; obuf[ 6] = iv[ 6] ^= ibuf[ 6]; obuf[ 7] = iv[ 7] ^= ibuf[ 7]; obuf[ 8] = iv[ 8] ^= ibuf[ 8]; obuf[ 9] = iv[ 9] ^= ibuf[ 9]; obuf[10] = iv[10] ^= ibuf[10]; obuf[11] = iv[11] ^= ibuf[11]; obuf[12] = iv[12] ^= ibuf[12]; obuf[13] = iv[13] ^= ibuf[13]; obuf[14] = iv[14] ^= ibuf[14]; obuf[15] = iv[15] ^= ibuf[15]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } #endif } while(cnt < len) { if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(cnt < len && b_pos < AES_BLOCK_SIZE) { *obuf++ = (iv[b_pos++] ^= *ibuf++); cnt++; } b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } ctx->inf.b[2] = (uint8_t)b_pos; return EXIT_SUCCESS; } AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) { int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; if(b_pos) /* complete any partial block */ { uint8_t t; while(b_pos < AES_BLOCK_SIZE && cnt < len) { t = *ibuf++; *obuf++ = t ^ iv[b_pos]; iv[b_pos++] = t; cnt++; } b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ { #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { int m; uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_cfb_op6(ksp, cwd, ibuf, obuf, nb, ivp); ibuf += nb * AES_BLOCK_SIZE; obuf += nb * AES_BLOCK_SIZE; cnt += nb * AES_BLOCK_SIZE; } else /* input, output or both are unaligned */ { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) /* input buffer is not aligned */ memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cfb_op6(ksp, cwd, ip, op, m, ivp); if(op != obuf) /* output buffer is not aligned */ memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; cnt += m * AES_BLOCK_SIZE; } } if(ivp != iv) memcpy(iv, ivp, AES_BLOCK_SIZE); } #else # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) &&!ALIGN_OFFSET( iv, 4 )) while(cnt + AES_BLOCK_SIZE <= len) { uint32_t t; assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; t = lp32(ibuf)[0], lp32(obuf)[0] = t ^ lp32(iv)[0], lp32(iv)[0] = t; t = lp32(ibuf)[1], lp32(obuf)[1] = t ^ lp32(iv)[1], lp32(iv)[1] = t; t = lp32(ibuf)[2], lp32(obuf)[2] = t ^ lp32(iv)[2], lp32(iv)[2] = t; t = lp32(ibuf)[3], lp32(obuf)[3] = t ^ lp32(iv)[3], lp32(iv)[3] = t; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } else # endif while(cnt + AES_BLOCK_SIZE <= len) { uint8_t t; assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; t = ibuf[ 0], obuf[ 0] = t ^ iv[ 0], iv[ 0] = t; t = ibuf[ 1], obuf[ 1] = t ^ iv[ 1], iv[ 1] = t; t = ibuf[ 2], obuf[ 2] = t ^ iv[ 2], iv[ 2] = t; t = ibuf[ 3], obuf[ 3] = t ^ iv[ 3], iv[ 3] = t; t = ibuf[ 4], obuf[ 4] = t ^ iv[ 4], iv[ 4] = t; t = ibuf[ 5], obuf[ 5] = t ^ iv[ 5], iv[ 5] = t; t = ibuf[ 6], obuf[ 6] = t ^ iv[ 6], iv[ 6] = t; t = ibuf[ 7], obuf[ 7] = t ^ iv[ 7], iv[ 7] = t; t = ibuf[ 8], obuf[ 8] = t ^ iv[ 8], iv[ 8] = t; t = ibuf[ 9], obuf[ 9] = t ^ iv[ 9], iv[ 9] = t; t = ibuf[10], obuf[10] = t ^ iv[10], iv[10] = t; t = ibuf[11], obuf[11] = t ^ iv[11], iv[11] = t; t = ibuf[12], obuf[12] = t ^ iv[12], iv[12] = t; t = ibuf[13], obuf[13] = t ^ iv[13], iv[13] = t; t = ibuf[14], obuf[14] = t ^ iv[14], iv[14] = t; t = ibuf[15], obuf[15] = t ^ iv[15], iv[15] = t; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } #endif } while(cnt < len) { uint8_t t; if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(cnt < len && b_pos < AES_BLOCK_SIZE) { t = *ibuf++; *obuf++ = t ^ iv[b_pos]; iv[b_pos++] = t; cnt++; } b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } ctx->inf.b[2] = (uint8_t)b_pos; return EXIT_SUCCESS; } AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) { int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; if(b_pos) /* complete any partial block */ { while(b_pos < AES_BLOCK_SIZE && cnt < len) { *obuf++ = iv[b_pos++] ^ *ibuf++; cnt++; } b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ { #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { int m; uint8_t *ksp = (uint8_t*)(ctx->ks), *ivp = iv; aligned_auto(uint8_t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_ofb_op6(ksp, cwd, ibuf, obuf, nb, ivp); ibuf += nb * AES_BLOCK_SIZE; obuf += nb * AES_BLOCK_SIZE; cnt += nb * AES_BLOCK_SIZE; } else /* input, output or both are unaligned */ { aligned_auto(uint8_t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint8_t *ip, *op; while(nb) { m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_ofb_op6(ksp, cwd, ip, op, m, ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; cnt += m * AES_BLOCK_SIZE; } } if(ivp != iv) memcpy(iv, ivp, AES_BLOCK_SIZE); } #else # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; lp32(obuf)[0] = lp32(iv)[0] ^ lp32(ibuf)[0]; lp32(obuf)[1] = lp32(iv)[1] ^ lp32(ibuf)[1]; lp32(obuf)[2] = lp32(iv)[2] ^ lp32(ibuf)[2]; lp32(obuf)[3] = lp32(iv)[3] ^ lp32(ibuf)[3]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } else # endif while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; obuf[ 0] = iv[ 0] ^ ibuf[ 0]; obuf[ 1] = iv[ 1] ^ ibuf[ 1]; obuf[ 2] = iv[ 2] ^ ibuf[ 2]; obuf[ 3] = iv[ 3] ^ ibuf[ 3]; obuf[ 4] = iv[ 4] ^ ibuf[ 4]; obuf[ 5] = iv[ 5] ^ ibuf[ 5]; obuf[ 6] = iv[ 6] ^ ibuf[ 6]; obuf[ 7] = iv[ 7] ^ ibuf[ 7]; obuf[ 8] = iv[ 8] ^ ibuf[ 8]; obuf[ 9] = iv[ 9] ^ ibuf[ 9]; obuf[10] = iv[10] ^ ibuf[10]; obuf[11] = iv[11] ^ ibuf[11]; obuf[12] = iv[12] ^ ibuf[12]; obuf[13] = iv[13] ^ ibuf[13]; obuf[14] = iv[14] ^ ibuf[14]; obuf[15] = iv[15] ^ ibuf[15]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } #endif } while(cnt < len) { if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(cnt < len && b_pos < AES_BLOCK_SIZE) { *obuf++ = iv[b_pos++] ^ *ibuf++; cnt++; } b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } ctx->inf.b[2] = (uint8_t)b_pos; return EXIT_SUCCESS; } #define BFR_LENGTH (BFR_BLOCKS * AES_BLOCK_SIZE) AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx ctx[1]) { unsigned char *ip; int i, blen, b_pos = (int)(ctx->inf.b[2]); #if defined( USE_VIA_ACE_IF_PRESENT ) aligned_auto(uint8_t, buf, BFR_LENGTH, 16); if(ctx->inf.b[1] == 0xff && ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; #else uint8_t buf[BFR_LENGTH]; #endif if(b_pos) { memcpy(buf, cbuf, AES_BLOCK_SIZE); if(aes_ecb_encrypt(buf, buf, AES_BLOCK_SIZE, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(b_pos < AES_BLOCK_SIZE && len) { *obuf++ = *ibuf++ ^ buf[b_pos++]; --len; } if(len) ctr_inc(cbuf), b_pos = 0; } while(len) { blen = (len > BFR_LENGTH ? BFR_LENGTH : len), len -= blen; for(i = 0, ip = buf; i < (blen >> 4); ++i) { memcpy(ip, cbuf, AES_BLOCK_SIZE); ctr_inc(cbuf); ip += AES_BLOCK_SIZE; } if(blen & (AES_BLOCK_SIZE - 1)) memcpy(ip, cbuf, AES_BLOCK_SIZE), i++; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); via_ecb_op5((ctx->ks), cwd, buf, buf, i); } else #endif if(aes_ecb_encrypt(buf, buf, i * AES_BLOCK_SIZE, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; i = 0; ip = buf; # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( ip, 4 )) while(i + AES_BLOCK_SIZE <= blen) { lp32(obuf)[0] = lp32(ibuf)[0] ^ lp32(ip)[0]; lp32(obuf)[1] = lp32(ibuf)[1] ^ lp32(ip)[1]; lp32(obuf)[2] = lp32(ibuf)[2] ^ lp32(ip)[2]; lp32(obuf)[3] = lp32(ibuf)[3] ^ lp32(ip)[3]; i += AES_BLOCK_SIZE; ip += AES_BLOCK_SIZE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } else #endif while(i + AES_BLOCK_SIZE <= blen) { obuf[ 0] = ibuf[ 0] ^ ip[ 0]; obuf[ 1] = ibuf[ 1] ^ ip[ 1]; obuf[ 2] = ibuf[ 2] ^ ip[ 2]; obuf[ 3] = ibuf[ 3] ^ ip[ 3]; obuf[ 4] = ibuf[ 4] ^ ip[ 4]; obuf[ 5] = ibuf[ 5] ^ ip[ 5]; obuf[ 6] = ibuf[ 6] ^ ip[ 6]; obuf[ 7] = ibuf[ 7] ^ ip[ 7]; obuf[ 8] = ibuf[ 8] ^ ip[ 8]; obuf[ 9] = ibuf[ 9] ^ ip[ 9]; obuf[10] = ibuf[10] ^ ip[10]; obuf[11] = ibuf[11] ^ ip[11]; obuf[12] = ibuf[12] ^ ip[12]; obuf[13] = ibuf[13] ^ ip[13]; obuf[14] = ibuf[14] ^ ip[14]; obuf[15] = ibuf[15] ^ ip[15]; i += AES_BLOCK_SIZE; ip += AES_BLOCK_SIZE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } while(i++ < blen) *obuf++ = *ibuf++ ^ ip[b_pos++]; } ctx->inf.b[2] = (uint8_t)b_pos; return EXIT_SUCCESS; } #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes_via_ace.h0000664000000000000000000004200112652076434022141 0ustar rootroot/* Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #ifndef AES_VIA_ACE_H #define AES_VIA_ACE_H #if defined( _MSC_VER ) # define INLINE __inline #elif defined( __GNUC__ ) # define INLINE static inline #else # error VIA ACE requires Microsoft or GNU C #endif #define NEH_GENERATE 1 #define NEH_LOAD 2 #define NEH_HYBRID 3 #define MAX_READ_ATTEMPTS 1000 /* VIA Nehemiah RNG and ACE Feature Mask Values */ #define NEH_CPU_IS_VIA 0x00000001 #define NEH_CPU_READ 0x00000010 #define NEH_CPU_MASK 0x00000011 #define NEH_RNG_PRESENT 0x00000004 #define NEH_RNG_ENABLED 0x00000008 #define NEH_ACE_PRESENT 0x00000040 #define NEH_ACE_ENABLED 0x00000080 #define NEH_RNG_FLAGS (NEH_RNG_PRESENT | NEH_RNG_ENABLED) #define NEH_ACE_FLAGS (NEH_ACE_PRESENT | NEH_ACE_ENABLED) #define NEH_FLAGS_MASK (NEH_RNG_FLAGS | NEH_ACE_FLAGS) /* VIA Nehemiah Advanced Cryptography Engine (ACE) Control Word Values */ #define NEH_GEN_KEY 0x00000000 /* generate key schedule */ #define NEH_LOAD_KEY 0x00000080 /* load schedule from memory */ #define NEH_ENCRYPT 0x00000000 /* encryption */ #define NEH_DECRYPT 0x00000200 /* decryption */ #define NEH_KEY128 0x00000000+0x0a /* 128 bit key */ #define NEH_KEY192 0x00000400+0x0c /* 192 bit key */ #define NEH_KEY256 0x00000800+0x0e /* 256 bit key */ #define NEH_ENC_GEN (NEH_ENCRYPT | NEH_GEN_KEY) #define NEH_DEC_GEN (NEH_DECRYPT | NEH_GEN_KEY) #define NEH_ENC_LOAD (NEH_ENCRYPT | NEH_LOAD_KEY) #define NEH_DEC_LOAD (NEH_DECRYPT | NEH_LOAD_KEY) #define NEH_ENC_GEN_DATA {\ NEH_ENC_GEN | NEH_KEY128, 0, 0, 0,\ NEH_ENC_GEN | NEH_KEY192, 0, 0, 0,\ NEH_ENC_GEN | NEH_KEY256, 0, 0, 0 } #define NEH_ENC_LOAD_DATA {\ NEH_ENC_LOAD | NEH_KEY128, 0, 0, 0,\ NEH_ENC_LOAD | NEH_KEY192, 0, 0, 0,\ NEH_ENC_LOAD | NEH_KEY256, 0, 0, 0 } #define NEH_ENC_HYBRID_DATA {\ NEH_ENC_GEN | NEH_KEY128, 0, 0, 0,\ NEH_ENC_LOAD | NEH_KEY192, 0, 0, 0,\ NEH_ENC_LOAD | NEH_KEY256, 0, 0, 0 } #define NEH_DEC_GEN_DATA {\ NEH_DEC_GEN | NEH_KEY128, 0, 0, 0,\ NEH_DEC_GEN | NEH_KEY192, 0, 0, 0,\ NEH_DEC_GEN | NEH_KEY256, 0, 0, 0 } #define NEH_DEC_LOAD_DATA {\ NEH_DEC_LOAD | NEH_KEY128, 0, 0, 0,\ NEH_DEC_LOAD | NEH_KEY192, 0, 0, 0,\ NEH_DEC_LOAD | NEH_KEY256, 0, 0, 0 } #define NEH_DEC_HYBRID_DATA {\ NEH_DEC_GEN | NEH_KEY128, 0, 0, 0,\ NEH_DEC_LOAD | NEH_KEY192, 0, 0, 0,\ NEH_DEC_LOAD | NEH_KEY256, 0, 0, 0 } #define neh_enc_gen_key(x) ((x) == 128 ? (NEH_ENC_GEN | NEH_KEY128) : \ (x) == 192 ? (NEH_ENC_GEN | NEH_KEY192) : (NEH_ENC_GEN | NEH_KEY256)) #define neh_enc_load_key(x) ((x) == 128 ? (NEH_ENC_LOAD | NEH_KEY128) : \ (x) == 192 ? (NEH_ENC_LOAD | NEH_KEY192) : (NEH_ENC_LOAD | NEH_KEY256)) #define neh_enc_hybrid_key(x) ((x) == 128 ? (NEH_ENC_GEN | NEH_KEY128) : \ (x) == 192 ? (NEH_ENC_LOAD | NEH_KEY192) : (NEH_ENC_LOAD | NEH_KEY256)) #define neh_dec_gen_key(x) ((x) == 128 ? (NEH_DEC_GEN | NEH_KEY128) : \ (x) == 192 ? (NEH_DEC_GEN | NEH_KEY192) : (NEH_DEC_GEN | NEH_KEY256)) #define neh_dec_load_key(x) ((x) == 128 ? (NEH_DEC_LOAD | NEH_KEY128) : \ (x) == 192 ? (NEH_DEC_LOAD | NEH_KEY192) : (NEH_DEC_LOAD | NEH_KEY256)) #define neh_dec_hybrid_key(x) ((x) == 128 ? (NEH_DEC_GEN | NEH_KEY128) : \ (x) == 192 ? (NEH_DEC_LOAD | NEH_KEY192) : (NEH_DEC_LOAD | NEH_KEY256)) #if defined( _MSC_VER ) && ( _MSC_VER > 1200 ) #define aligned_auto(type, name, no, stride) __declspec(align(stride)) type name[no] #else #define aligned_auto(type, name, no, stride) \ unsigned char _##name[no * sizeof(type) + stride]; \ type *name = (type*)(16 * ((((unsigned long)(_##name)) + stride - 1) / stride)) #endif #if defined( _MSC_VER ) && ( _MSC_VER > 1200 ) #define aligned_array(type, name, no, stride) __declspec(align(stride)) type name[no] #elif defined( __GNUC__ ) #define aligned_array(type, name, no, stride) type name[no] __attribute__ ((aligned(stride))) #else #define aligned_array(type, name, no, stride) type name[no] #endif /* VIA ACE codeword */ static unsigned char via_flags = 0; #if defined ( _MSC_VER ) && ( _MSC_VER > 800 ) #define NEH_REKEY __asm pushfd __asm popfd #define NEH_AES __asm _emit 0xf3 __asm _emit 0x0f __asm _emit 0xa7 #define NEH_ECB NEH_AES __asm _emit 0xc8 #define NEH_CBC NEH_AES __asm _emit 0xd0 #define NEH_CFB NEH_AES __asm _emit 0xe0 #define NEH_OFB NEH_AES __asm _emit 0xe8 #define NEH_RNG __asm _emit 0x0f __asm _emit 0xa7 __asm _emit 0xc0 INLINE int has_cpuid(void) { char ret_value; __asm { pushfd /* save EFLAGS register */ mov eax,[esp] /* copy it to eax */ mov edx,0x00200000 /* CPUID bit position */ xor eax,edx /* toggle the CPUID bit */ push eax /* attempt to set EFLAGS to */ popfd /* the new value */ pushfd /* get the new EFLAGS value */ pop eax /* into eax */ xor eax,[esp] /* xor with original value */ and eax,edx /* has CPUID bit changed? */ setne al /* set to 1 if we have been */ mov ret_value,al /* able to change it */ popfd /* restore original EFLAGS */ } return (int)ret_value; } INLINE int is_via_cpu(void) { char ret_value; __asm { push ebx xor eax,eax /* use CPUID to get vendor */ cpuid /* identity string */ xor eax,eax /* is it "CentaurHauls" ? */ sub ebx,0x746e6543 /* 'Cent' */ or eax,ebx sub edx,0x48727561 /* 'aurH' */ or eax,edx sub ecx,0x736c7561 /* 'auls' */ or eax,ecx sete al /* set to 1 if it is VIA ID */ mov dl,NEH_CPU_READ /* mark CPU type as read */ or dl,al /* & store result in flags */ mov [via_flags],dl /* set VIA detected flag */ mov ret_value,al /* able to change it */ pop ebx } return (int)ret_value; } INLINE int read_via_flags(void) { char ret_value = 0; __asm { mov eax,0xC0000000 /* Centaur extended CPUID */ cpuid mov edx,0xc0000001 /* >= 0xc0000001 if support */ cmp eax,edx /* for VIA extended feature */ jnae no_rng /* flags is available */ mov eax,edx /* read Centaur extended */ cpuid /* feature flags */ mov eax,NEH_FLAGS_MASK /* mask out and save */ and eax,edx /* the RNG and ACE flags */ or [via_flags],al /* present & enabled flags */ mov ret_value,al /* able to change it */ no_rng: } return (int)ret_value; } INLINE unsigned int via_rng_in(void *buf) { char ret_value = 0x1f; __asm { push edi mov edi,buf /* input buffer address */ xor edx,edx /* try to fetch 8 bytes */ NEH_RNG /* do RNG read operation */ and ret_value,al /* count of bytes returned */ pop edi } return (int)ret_value; } INLINE void via_ecb_op5( const void *k, const void *c, const void *s, void *d, int l) { __asm { push ebx NEH_REKEY mov ebx, (k) mov edx, (c) mov esi, (s) mov edi, (d) mov ecx, (l) NEH_ECB pop ebx } } INLINE void via_cbc_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) { __asm { push ebx NEH_REKEY mov ebx, (k) mov edx, (c) mov esi, (s) mov edi, (d) mov ecx, (l) mov eax, (v) NEH_CBC pop ebx } } INLINE void via_cbc_op7( const void *k, const void *c, const void *s, void *d, int l, void *v, void *w) { __asm { push ebx NEH_REKEY mov ebx, (k) mov edx, (c) mov esi, (s) mov edi, (d) mov ecx, (l) mov eax, (v) NEH_CBC mov esi, eax mov edi, (w) movsd movsd movsd movsd pop ebx } } INLINE void via_cfb_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) { __asm { push ebx NEH_REKEY mov ebx, (k) mov edx, (c) mov esi, (s) mov edi, (d) mov ecx, (l) mov eax, (v) NEH_CFB pop ebx } } INLINE void via_cfb_op7( const void *k, const void *c, const void *s, void *d, int l, void *v, void *w) { __asm { push ebx NEH_REKEY mov ebx, (k) mov edx, (c) mov esi, (s) mov edi, (d) mov ecx, (l) mov eax, (v) NEH_CFB mov esi, eax mov edi, (w) movsd movsd movsd movsd pop ebx } } INLINE void via_ofb_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) { __asm { push ebx NEH_REKEY mov ebx, (k) mov edx, (c) mov esi, (s) mov edi, (d) mov ecx, (l) mov eax, (v) NEH_OFB pop ebx } } #elif defined( __GNUC__ ) #define NEH_REKEY asm("pushfl\n popfl\n\t") #define NEH_ECB asm(".byte 0xf3, 0x0f, 0xa7, 0xc8\n\t") #define NEH_CBC asm(".byte 0xf3, 0x0f, 0xa7, 0xd0\n\t") #define NEH_CFB asm(".byte 0xf3, 0x0f, 0xa7, 0xe0\n\t") #define NEH_OFB asm(".byte 0xf3, 0x0f, 0xa7, 0xe8\n\t") #define NEH_RNG asm(".byte 0x0f, 0xa7, 0xc0\n\t"); INLINE int has_cpuid(void) { int val; asm("pushfl\n\t"); asm("movl 0(%esp),%eax\n\t"); asm("xor $0x00200000,%eax\n\t"); asm("pushl %eax\n\t"); asm("popfl\n\t"); asm("pushfl\n\t"); asm("popl %eax\n\t"); asm("xorl 0(%esp),%edx\n\t"); asm("andl $0x00200000,%eax\n\t"); asm("movl %%eax,%0\n\t" : "=m" (val)); asm("popfl\n\t"); return val ? 1 : 0; } INLINE int is_via_cpu(void) { int val; asm("pushl %ebx\n\t"); asm("xorl %eax,%eax\n\t"); asm("cpuid\n\t"); asm("xorl %eax,%eax\n\t"); asm("subl $0x746e6543,%ebx\n\t"); asm("orl %ebx,%eax\n\t"); asm("subl $0x48727561,%edx\n\t"); asm("orl %edx,%eax\n\t"); asm("subl $0x736c7561,%ecx\n\t"); asm("orl %ecx,%eax\n\t"); asm("movl %%eax,%0\n\t" : "=m" (val)); asm("popl %ebx\n\t"); val = (val ? 0 : 1); via_flags = (val | NEH_CPU_READ); return val; } INLINE int read_via_flags(void) { unsigned char val; asm("movl $0xc0000000,%eax\n\t"); asm("cpuid\n\t"); asm("movl $0xc0000001,%edx\n\t"); asm("cmpl %edx,%eax\n\t"); asm("setae %al\n\t"); asm("movb %%al,%0\n\t" : "=m" (val)); if(!val) return 0; asm("movl $0xc0000001,%eax\n\t"); asm("cpuid\n\t"); asm("movb %%dl,%0\n\t" : "=m" (val)); val &= NEH_FLAGS_MASK; via_flags |= val; return (int) val; } INLINE int via_rng_in(void *buf) { int val; asm("pushl %edi\n\t"); asm("movl %0,%%edi\n\t" : : "m" (buf)); asm("xorl %edx,%edx\n\t"); NEH_RNG asm("andl $0x0000001f,%eax\n\t"); asm("movl %%eax,%0\n\t" : "=m" (val)); asm("popl %edi\n\t"); return val; } INLINE volatile void via_ecb_op5( const void *k, const void *c, const void *s, void *d, int l) { asm("pushl %ebx\n\t"); NEH_REKEY; asm("movl %0, %%ebx\n\t" : : "m" (k)); asm("movl %0, %%edx\n\t" : : "m" (c)); asm("movl %0, %%esi\n\t" : : "m" (s)); asm("movl %0, %%edi\n\t" : : "m" (d)); asm("movl %0, %%ecx\n\t" : : "m" (l)); NEH_ECB; asm("popl %ebx\n\t"); } INLINE volatile void via_cbc_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) { asm("pushl %ebx\n\t"); NEH_REKEY; asm("movl %0, %%ebx\n\t" : : "m" (k)); asm("movl %0, %%edx\n\t" : : "m" (c)); asm("movl %0, %%esi\n\t" : : "m" (s)); asm("movl %0, %%edi\n\t" : : "m" (d)); asm("movl %0, %%ecx\n\t" : : "m" (l)); asm("movl %0, %%eax\n\t" : : "m" (v)); NEH_CBC; asm("popl %ebx\n\t"); } INLINE volatile void via_cbc_op7( const void *k, const void *c, const void *s, void *d, int l, void *v, void *w) { asm("pushl %ebx\n\t"); NEH_REKEY; asm("movl %0, %%ebx\n\t" : : "m" (k)); asm("movl %0, %%edx\n\t" : : "m" (c)); asm("movl %0, %%esi\n\t" : : "m" (s)); asm("movl %0, %%edi\n\t" : : "m" (d)); asm("movl %0, %%ecx\n\t" : : "m" (l)); asm("movl %0, %%eax\n\t" : : "m" (v)); NEH_CBC; asm("movl %eax,%esi\n\t"); asm("movl %0, %%edi\n\t" : : "m" (w)); asm("movsl; movsl; movsl; movsl\n\t"); asm("popl %ebx\n\t"); } INLINE volatile void via_cfb_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) { asm("pushl %ebx\n\t"); NEH_REKEY; asm("movl %0, %%ebx\n\t" : : "m" (k)); asm("movl %0, %%edx\n\t" : : "m" (c)); asm("movl %0, %%esi\n\t" : : "m" (s)); asm("movl %0, %%edi\n\t" : : "m" (d)); asm("movl %0, %%ecx\n\t" : : "m" (l)); asm("movl %0, %%eax\n\t" : : "m" (v)); NEH_CFB; asm("popl %ebx\n\t"); } INLINE volatile void via_cfb_op7( const void *k, const void *c, const void *s, void *d, int l, void *v, void *w) { asm("pushl %ebx\n\t"); NEH_REKEY; asm("movl %0, %%ebx\n\t" : : "m" (k)); asm("movl %0, %%edx\n\t" : : "m" (c)); asm("movl %0, %%esi\n\t" : : "m" (s)); asm("movl %0, %%edi\n\t" : : "m" (d)); asm("movl %0, %%ecx\n\t" : : "m" (l)); asm("movl %0, %%eax\n\t" : : "m" (v)); NEH_CFB; asm("movl %eax,%esi\n\t"); asm("movl %0, %%edi\n\t" : : "m" (w)); asm("movsl; movsl; movsl; movsl\n\t"); asm("popl %ebx\n\t"); } INLINE volatile void via_ofb_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) { asm("pushl %ebx\n\t"); NEH_REKEY; asm("movl %0, %%ebx\n\t" : : "m" (k)); asm("movl %0, %%edx\n\t" : : "m" (c)); asm("movl %0, %%esi\n\t" : : "m" (s)); asm("movl %0, %%edi\n\t" : : "m" (d)); asm("movl %0, %%ecx\n\t" : : "m" (l)); asm("movl %0, %%eax\n\t" : : "m" (v)); NEH_OFB; asm("popl %ebx\n\t"); } #else #error VIA ACE is not available with this compiler #endif INLINE int via_ace_test(void) { return has_cpuid() && is_via_cpu() && ((read_via_flags() & NEH_ACE_FLAGS) == NEH_ACE_FLAGS); } #define VIA_ACE_AVAILABLE (((via_flags & NEH_ACE_FLAGS) == NEH_ACE_FLAGS) \ || (via_flags & NEH_CPU_READ) && (via_flags & NEH_CPU_IS_VIA) || via_ace_test()) INLINE int via_rng_test(void) { return has_cpuid() && is_via_cpu() && ((read_via_flags() & NEH_RNG_FLAGS) == NEH_RNG_FLAGS); } #define VIA_RNG_AVAILABLE (((via_flags & NEH_RNG_FLAGS) == NEH_RNG_FLAGS) \ || (via_flags & NEH_CPU_READ) && (via_flags & NEH_CPU_IS_VIA) || via_rng_test()) INLINE int read_via_rng(void *buf, int count) { int nbr, max_reads, lcnt = count; unsigned char *p, *q; aligned_auto(unsigned char, bp, 64, 16); if(!VIA_RNG_AVAILABLE) return 0; do { max_reads = MAX_READ_ATTEMPTS; do nbr = via_rng_in(bp); while (nbr == 0 && --max_reads); lcnt -= nbr; p = (unsigned char*)buf; q = bp; while(nbr--) *p++ = *q++; } while (lcnt && max_reads); return count - lcnt; } #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aestab.h0000664000000000000000000001232412652076434021166 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the code for declaring the tables needed to implement AES. The file aesopt.h is assumed to be included before this header file. If there are no global variables, the definitions here can be used to put the AES tables in a structure so that a pointer can then be added to the AES context to pass them to the AES routines that need them. If this facility is used, the calling program has to ensure that this pointer is managed appropriately. In particular, the value of the t_dec(in,it) item in the table structure must be set to zero in order to ensure that the tables are initialised. In practice the three code sequences in aeskey.c that control the calls to aes_init() and the aes_init() routine itself will have to be changed for a specific implementation. If global variables are available it will generally be preferable to use them with the precomputed FIXED_TABLES option that uses static global tables. The following defines can be used to control the way the tables are defined, initialised and used in embedded environments that require special features for these purposes the 't_dec' construction is used to declare fixed table arrays the 't_set' construction is used to set fixed table values the 't_use' construction is used to access fixed table values 256 byte tables: t_xxx(s,box) => forward S box t_xxx(i,box) => inverse S box 256 32-bit word OR 4 x 256 32-bit word tables: t_xxx(f,n) => forward normal round t_xxx(f,l) => forward last round t_xxx(i,n) => inverse normal round t_xxx(i,l) => inverse last round t_xxx(l,s) => key schedule table t_xxx(i,m) => key schedule table Other variables and tables: t_xxx(r,c) => the rcon table */ #if !defined( _AESTAB_H ) #define _AESTAB_H #if defined(__cplusplus) extern "C" { #endif #define t_dec(m,n) t_##m##n #define t_set(m,n) t_##m##n #define t_use(m,n) t_##m##n #if defined(FIXED_TABLES) # if !defined( __GNUC__ ) && (defined( __MSDOS__ ) || defined( __WIN16__ )) /* make tables far data to avoid using too much DGROUP space (PG) */ # define CONST const far # else # define CONST const # endif #else # define CONST #endif #if defined(DO_TABLES) # define EXTERN #else # define EXTERN extern #endif #if defined(_MSC_VER) && defined(TABLE_ALIGN) #define ALIGN __declspec(align(TABLE_ALIGN)) #else #define ALIGN #endif #if defined( __WATCOMC__ ) && ( __WATCOMC__ >= 1100 ) # define XP_DIR __cdecl #else # define XP_DIR #endif #if defined(DO_TABLES) && defined(FIXED_TABLES) #define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] = b(e) #define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] = { b(e), b(f), b(g), b(h) } EXTERN ALIGN CONST uint32_t t_dec(r,c)[RC_LENGTH] = rc_data(w0); #else #define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] #define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] EXTERN ALIGN CONST uint32_t t_dec(r,c)[RC_LENGTH]; #endif #if defined( SBX_SET ) d_1(uint8_t, t_dec(s,box), sb_data, h0); #endif #if defined( ISB_SET ) d_1(uint8_t, t_dec(i,box), isb_data, h0); #endif #if defined( FT1_SET ) d_1(uint32_t, t_dec(f,n), sb_data, u0); #endif #if defined( FT4_SET ) d_4(uint32_t, t_dec(f,n), sb_data, u0, u1, u2, u3); #endif #if defined( FL1_SET ) d_1(uint32_t, t_dec(f,l), sb_data, w0); #endif #if defined( FL4_SET ) d_4(uint32_t, t_dec(f,l), sb_data, w0, w1, w2, w3); #endif #if defined( IT1_SET ) d_1(uint32_t, t_dec(i,n), isb_data, v0); #endif #if defined( IT4_SET ) d_4(uint32_t, t_dec(i,n), isb_data, v0, v1, v2, v3); #endif #if defined( IL1_SET ) d_1(uint32_t, t_dec(i,l), isb_data, w0); #endif #if defined( IL4_SET ) d_4(uint32_t, t_dec(i,l), isb_data, w0, w1, w2, w3); #endif #if defined( LS1_SET ) #if defined( FL1_SET ) #undef LS1_SET #else d_1(uint32_t, t_dec(l,s), sb_data, w0); #endif #endif #if defined( LS4_SET ) #if defined( FL4_SET ) #undef LS4_SET #else d_4(uint32_t, t_dec(l,s), sb_data, w0, w1, w2, w3); #endif #endif #if defined( IM1_SET ) d_1(uint32_t, t_dec(i,m), mm_data, v0); #endif #if defined( IM4_SET ) d_4(uint32_t, t_dec(i,m), mm_data, v0, v1, v2, v3); #endif #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aescrypt.c0000664000000000000000000002410312652076434021552 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #include "aesopt.h" #include "aestab.h" #if defined( USE_INTEL_AES_IF_PRESENT ) # include "aes_ni.h" #else /* map names here to provide the external API ('name' -> 'aes_name') */ # define aes_xi(x) aes_ ## x #endif #if defined(__cplusplus) extern "C" { #endif #define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c]) #define so(y,x,c) word_out(y, c, s(x,c)) #if defined(ARRAYS) #define locals(y,x) x[4],y[4] #else #define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3 #endif #define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \ s(y,2) = s(x,2); s(y,3) = s(x,3); #define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3) #define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3) #define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3) #if ( FUNCS_IN_C & ENCRYPTION_IN_C ) /* Visual C++ .Net v7.1 provides the fastest encryption code when using Pentium optimiation with small code but this is poor for decryption so we need to control this with the following VC++ pragmas */ #if defined( _MSC_VER ) && !defined( _WIN64 ) #pragma optimize( "s", on ) #endif /* Given the column (c) of the output state variable, the following macros give the input state variables which are needed in its computation for each row (r) of the state. All the alternative macros give the same end values but expand into different ways of calculating these values. In particular the complex macro used for dynamically variable block sizes is designed to expand to a compile time constant whenever possible but will expand to conditional clauses on some branches (I am grateful to Frank Yellin for this construction) */ #define fwd_var(x,r,c)\ ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ : r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\ : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ : ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))) #if defined(FT4_SET) #undef dec_fmvars #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c)) #elif defined(FT1_SET) #undef dec_fmvars #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c)) #else #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c))) #endif #if defined(FL4_SET) #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c)) #elif defined(FL1_SET) #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c)) #else #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c)) #endif AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) { uint32_t locals(b0, b1); const uint32_t *kp; #if defined( dec_fmvars ) dec_fmvars; /* declare variables for fwd_mcol() if needed */ #endif if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16) return EXIT_FAILURE; kp = cx->ks; state_in(b0, in, kp); #if (ENC_UNROLL == FULL) switch(cx->inf.b[0]) { case 14 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); kp += 2 * N_COLS; case 12 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); kp += 2 * N_COLS; case 10 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); round(fwd_rnd, b1, b0, kp + 3 * N_COLS); round(fwd_rnd, b0, b1, kp + 4 * N_COLS); round(fwd_rnd, b1, b0, kp + 5 * N_COLS); round(fwd_rnd, b0, b1, kp + 6 * N_COLS); round(fwd_rnd, b1, b0, kp + 7 * N_COLS); round(fwd_rnd, b0, b1, kp + 8 * N_COLS); round(fwd_rnd, b1, b0, kp + 9 * N_COLS); round(fwd_lrnd, b0, b1, kp +10 * N_COLS); } #else #if (ENC_UNROLL == PARTIAL) { uint32_t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd) { kp += N_COLS; round(fwd_rnd, b1, b0, kp); kp += N_COLS; round(fwd_rnd, b0, b1, kp); } kp += N_COLS; round(fwd_rnd, b1, b0, kp); #else { uint32_t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd) { kp += N_COLS; round(fwd_rnd, b1, b0, kp); l_copy(b0, b1); } #endif kp += N_COLS; round(fwd_lrnd, b0, b1, kp); } #endif state_out(out, b0); return EXIT_SUCCESS; } #endif #if ( FUNCS_IN_C & DECRYPTION_IN_C) /* Visual C++ .Net v7.1 provides the fastest encryption code when using Pentium optimiation with small code but this is poor for decryption so we need to control this with the following VC++ pragmas */ #if defined( _MSC_VER ) && !defined( _WIN64 ) #pragma optimize( "t", on ) #endif /* Given the column (c) of the output state variable, the following macros give the input state variables which are needed in its computation for each row (r) of the state. All the alternative macros give the same end values but expand into different ways of calculating these values. In particular the complex macro used for dynamically variable block sizes is designed to expand to a compile time constant whenever possible but will expand to conditional clauses on some branches (I am grateful to Frank Yellin for this construction) */ #define inv_var(x,r,c)\ ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ : r == 1 ? ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))\ : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ : ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))) #if defined(IT4_SET) #undef dec_imvars #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,n),inv_var,rf1,c)) #elif defined(IT1_SET) #undef dec_imvars #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c)) #else #define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))) #endif #if defined(IL4_SET) #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c)) #elif defined(IL1_SET) #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c)) #else #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)) #endif /* This code can work with the decryption key schedule in the */ /* order that is used for encrytpion (where the 1st decryption */ /* round key is at the high end ot the schedule) or with a key */ /* schedule that has been reversed to put the 1st decryption */ /* round key at the low end of the schedule in memory (when */ /* AES_REV_DKS is defined) */ #ifdef AES_REV_DKS #define key_ofs 0 #define rnd_key(n) (kp + n * N_COLS) #else #define key_ofs 1 #define rnd_key(n) (kp - n * N_COLS) #endif AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) { uint32_t locals(b0, b1); #if defined( dec_imvars ) dec_imvars; /* declare variables for inv_mcol() if needed */ #endif const uint32_t *kp; if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16) return EXIT_FAILURE; kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0); state_in(b0, in, kp); #if (DEC_UNROLL == FULL) kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2)); switch(cx->inf.b[0]) { case 14 * 16: round(inv_rnd, b1, b0, rnd_key(-13)); round(inv_rnd, b0, b1, rnd_key(-12)); case 12 * 16: round(inv_rnd, b1, b0, rnd_key(-11)); round(inv_rnd, b0, b1, rnd_key(-10)); case 10 * 16: round(inv_rnd, b1, b0, rnd_key(-9)); round(inv_rnd, b0, b1, rnd_key(-8)); round(inv_rnd, b1, b0, rnd_key(-7)); round(inv_rnd, b0, b1, rnd_key(-6)); round(inv_rnd, b1, b0, rnd_key(-5)); round(inv_rnd, b0, b1, rnd_key(-4)); round(inv_rnd, b1, b0, rnd_key(-3)); round(inv_rnd, b0, b1, rnd_key(-2)); round(inv_rnd, b1, b0, rnd_key(-1)); round(inv_lrnd, b0, b1, rnd_key( 0)); } #else #if (DEC_UNROLL == PARTIAL) { uint32_t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd) { kp = rnd_key(1); round(inv_rnd, b1, b0, kp); kp = rnd_key(1); round(inv_rnd, b0, b1, kp); } kp = rnd_key(1); round(inv_rnd, b1, b0, kp); #else { uint32_t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd) { kp = rnd_key(1); round(inv_rnd, b1, b0, kp); l_copy(b0, b1); } #endif kp = rnd_key(1); round(inv_lrnd, b0, b1, kp); } #endif state_out(out, b0); return EXIT_SUCCESS; } #endif #if defined(__cplusplus) } #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes.txt0000664000000000000000000005750112652076434021075 0ustar rootroot An AES (Rijndael) Implementation in C/C++ (as specified in FIPS-197) ==================================================================== Changes in this Version (14/11/2013) ==================================== 1. Added the ability to use Intel's hardware support for AES on Windows using Microsoft Visual Studio. 2. Added the include 'stdint.h' and used the uint_t instead of the old uint_t (e.g. uint_32t is now uint32_t). 3. Added a missing .text directive in aes_x86_v2.asm that caused runtime errors in one build configuration. Changes in this Version (16/04/2007) ==================================== These changes remove errors in the VC++ build files and add some improvements in file naming consitency and portability. There are no changes to overcome reported bugs in the code. 1. gen_tabs() has been renamed to aes_init() to better decribe its function to those not familiar with AES internals. 2. via_ace.h has been renamed to aes_via_ace.h. 3. Minor changes have been made to aestab.h and aestab.c to enable all the code to be compiled in either C or C++. 4. The code for detecting memory alignment in aesmdoes.c has been simplified and a new routine has been added: aes_test_alignment_detection() to check that the aligment test is likely to be correct. 5. The addition of support for Structured Exception Handling (SEH) to YASM (well done Peter and Michael!) has allowed the AMD64 x64 assembler code to be changed to comply with SEH requriements. 6. Corrections to build files (for win32 debug build). Overview ======== This code implements AES for both 32 and 64 bit systems with optional assembler support for x86 and AMD64/EM64T (but optimised for AMD64). The basic AES source code files are as follows: aes.h the header file needed to use AES in C aescpp.h the header file required with to use AES in C++ aesopt.h the header file for setting options (and some common code) aestab.h the header file for the AES table declaration aescrypt.c the main C source code file for encryption and decryption aeskey.c the main C source code file for the key schedule aestab.c the main file for the AES tables brg_types.h a header defining some standard types and DLL defines brg_endian.h a header containing code to detect or define endianness aes_x86_v1.asm x86 assembler (YASM) alternative to aescrypt.c using large tables aes_x86_v2.asm x86 assembler (YASM) alternative to aescrypt.c using compressed tables aes_amd64.asm AMD64 assembler (YASM) alternative to aescrypt.c using compressed tables In addition AES modes are implemented in the files: aes_modes.c AES modes with optional support for VIA ACE detection and use aes_via_ace.h the header file for VIA ACE support and Intel hardware support for AES (AES_NI) is implemented in the files aes_ni.h defines for AES_NI implementation aes_ni.c the AES_NI implementation Other associated files for testing and support are: aesaux.h header for auxilliary routines for testsing aesaux.c auxilliary routines for testsingt aestst.h header file for setting the testing environment rdtsc.h a header file that provides access to the Time Stamp Counter aestst.c a simple test program for quick tests of the AES code aesgav.c a program to generate and verify the test vector files aesrav.c a program to verify output against the test vector files aestmr.c a program to time the code on x86 systems modetest.c a program to test the AES modes support vbxam.doc a demonstration of AES DLL use from Visual Basic in Microsoft Word vb.txt Visual Basic code from the above example (win32 only) aesxam.c an example of AES use tablegen.c a program to generate a simplified 'aestab.c' file for use with compilers that find aestab.c too complex yasm.rules the YASM build rules file for Microsoft Visual Studio 2005 via_ace.txt describes support for the VIA ACE cryptography engine aes.txt this file Building The AES Libraries -------------------------- A. Versions ----------- The code can be used to build static and dynamic libraries, each in five versions: Key scheduling code in C, encrypt/decrypt in: C C source code (win32 and x64) ASM_X86_V1C large table x86 assembler code (win32) ASM_X86_V2C compressed table x86 assembler code (win32) ASM_AMD64 compressed table x64 assembler code (x64) Key scheduling and encrypt/decrypt code in assembler: ASM_X86_V2 compressed table x86 assembler (win32) The C version can be compiled for Win32 or x64 whereas the x86 and x64 assembler versions are for Win32 and x64 respectively. If Intel's hardware support for AES (AES_NI) is available, it can be used with either the C or the ASM_AMD64 version. If ASM_AMD64 is to be used, it is important that the define USE_INTEL_AES_IF_PRESENT in asm_amd64.asm is set to the same value as it has in aesopt.h B. YASM ------- If you wish to use the x86 assembler files you will also need the YASM open source x86 assembler (r1331 or later) for Windows which can be obtained from: http://www.tortall.net/projects/yasm/ This assembler should be placed in the bin directory used by VC++, which, for Visual Stduio 2005, is typically: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin You will also need to move the yasm.rules file from this distribution into the directory where Visual Studio 2005 expects to find it, which is typically: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\VCProjectDefaults Alternatively you can configure the path for rules files within Visual Studio. C. Configuration ---------------- The following configurations are available as projects for Visual Studio but the following descriptions should allow them to be built in other x86 environments lib_generic_c Win32 and x64 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h (+ aes_ni.h for AES_NI) C source: aescrypt.c, aeskey.c, aestab.c, aes_modes.c (+ aes_ni.c for AES_NI) defines dll_generic_c Win32 and x64 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h (+ aes_ni.h for AES_NI) C source: aescrypt.c, aeskey.c, aestab.c, aes_modes.c (+ aes_ni.c for AES_NI) defines DLL_EXPORT lib_asm_x86_v1c Win32 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h C source: aeskey.c, aestab.c, aes_modes.c x86 assembler: aes_x86_v1.asm defines ASM_X86_V1C (set for C and assembler files) dll_asm_x86_v1c Win32 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h C source: aeskey.c, aestab.c, aes_modes.c x86 assembler: aes_x86_v1.asm defines DLL_EXPORT, ASM_X86_V1C (set for C and assembler files) lib_asm_x86_v2c Win32 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h C source: aeskey.c, aestab.c, aes_modes.c x86 assembler: aes_x86_v2.asm defines ASM_X86_V2C (set for C and assembler files) dll_asm_x86_v2c Win32 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h C source: aeskey.c, aestab.c, aes_modes.c x86 assembler: aes_x86_v1.asm defines DLL_EXPORT, ASM_X86_V2C (set for C and assembler files) lib_asm_x86_v2 Win32 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h C source: aes_modes.c x86 assembler: aes_x86_v1.asm defines ASM_X86_V2 (set for C and assembler files) dll_asm_x86_v2 Win32 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h C source: aes_modes.c x86 assembler: aes_x86_v1.asm defines DLL_EXPORT, ASM_AMD64_C (set for C and assembler files) lib_asm_amd64_c x64 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h (+ aes_ni.h for AES_NI) C source: aes_modes.c (+ aes_ni.c for AES_NI) x86 assembler: aes_amd64.asm defines ASM_X86_V2 (set for C and assembler files) dll_asm_amd64_c x64 headers: aes.h, aesopt.h, aestab.h, brg_endian.h, tdefs.h (+ aes_ni.h for AES_NI) C source: aes_modes.c (+ aes_ni.c for AES_NI) x86 assembler: aes_amd64.asm defines DLL_EXPORT, ASM_AMD64_C (set for C and assembler files) Notes: ASM_X86_V1C is defined if using the version 1 assembler code (aescrypt1.asm). The defines in the assember file must match those in aes.h and aesopt.h). Also remember to include/exclude the right assembler and C files in the build to avoid undefined or multiply defined symbols - include aes_x86_v1.asm and exclude aescrypt.c ASM_X86_V2 is defined if using the version 2 assembler code (aes_x86_v2.asm). This version provides a full, self contained assembler version and does not use any C source code files except for the mutiple block encryption modes that are provided by aes_modes.c. The define ASM_X86_V2 must be set on the YASM command line (or in aes_x86_v2.asm) to use this version and all C files except aec_modes.c and, for the DLL build, aestab.c must be excluded from the build. ASM_X86_V2C is defined when using the version 2 assembler code (aes_x86_v2.asm) with faster key scheduling provided by the in C code (the options in the assember file must match those in aes.h and aesopt.h). In this case aeskey.c and aestab.c are needed with aes_x86_v2.asm and the define ASM_X86_V2C must be set for both the C files and for aes_x86_v2.asm in the build commands(or in aesopt.h and aes_x86_v2.asm). Include aes_x86_v2.asm, aeskey.c and aestab.c, exclude aescrypt.c for this option. ASM_AMD64_C is defined when using the AMD64 assembly code because the C key scheduling is used in this case. DLL_EXPORT must be defined to generate the DLL version of the code and to run tests on it DLL_IMPORT must be defined to use the DLL version of the code in an application program Directories the paths for the various directories for test vector input and output have to be set in aestst.h VIA ACE see the via_ace.txt for this item Static The static libraries are named: Libraries aes_lib_generic_c.lib aes_lib_asm_x86_v1c.lib aes_lib_asm_x86_v2.lib aes_lib_asm_x86_v2c.lib aes_lib_asm_amd64_c.lib and placed in one of the the directories: lib\win32\release\ lib\win32\debug\ lib\x64\release\ lib\x64\debug\ in the aes root directory depending on the platform(win32 or x64) and the build (release or debug). After any of these is built it is then copied into the aes\lib directory, which is the library location that is subsequently used for testing. Hence testing is always for the last static library built. Dynamic These libraries are named: Libraries aes_lib_generic_c.dll aes_lib_asm_x86_v1c.dll aes_lib_asm_x86_v2.dll aes_lib_asm_x86_v2c.dll aes_lib_asm_amd64_c.dll and placed in one of the the directories: dll\win32\release\ dll\win32\debug\ dll\x64\release\ dll\x64\debug\ in the aes root directory depending on the platform(win32 or x64) and the build (release or debug). Each DLL library: aes_.dll has three associated files: aes_dll_.lib the library file for implicit linking aes_dll_.exp the exports file aes_dll_.pdb the symbol file After any DLL is built it and its three related files are then copied to the aes\dll directory, which is the library location used in subsequent testing. Hence testing is always for the last DLL built. D. Testing ---------- These tests require that the test vector files are placed in the 'testvals' subdirectory. If the AES Algorithm Validation Suite tests are used then the *.fax files need to be put in the 'testvals\fax' subdirectory. This is covered in more detail below. The projects test_lib and time_lib are used to test and time the last static library built. They use the files: test_lib: Win32 (x64 for the C and AMD64 versions) headers: aes.h, aescpp.h, brg_types.h, aesaux.h and aestst.h C source: aesaux.c, aesrav.c defines: time_lib: Win32 (x64 for the C and AMD64 versions) headers: aes.h, aescpp.h, brg_types.h, aesaux.h, aestst.h and rdtsc.h C source: aesaux.c, aestmr.c defines: The projects test_dll and time_dll are used to test and time the last DLL built. These use the files: test_dll: Win32 (x64 for the C and AMD64 versions) headers: aes.h, aescpp.h, brg_types.h, aesaux.h and aestst.h C source: aesaux.c, aesrav.c defines: DLL_IMPORT time_dll: Win32 (x64 for the C and AMD64 versions) headers: aes.h, aescpp.h, brg_types.h, aesaux.h aestst.h and rdtsc.h C source: aesaux.c, aestmr.c defines: DLL_IMPORT and link to the DLL using dynamic (run-time) linking. However, if the lib file associated with the DLL is linked into this project and the symbol DYNAMIC_LINK in aestst.h is left undefined, then implicit linking will be used The above tests take command line arguments that determine which test are run as follows: test_lib /t:[knec] /k:[468] test_dll /t:[knec] /k:[468] where the symbols in square brackets can be used in any combination (without the brackets) and have the following meanings: /t:[knec] selects which tests are used /k:[468] selects the key lengths used /c compares output with reference (see later) k: generate ECB Known Answer Test files n: generate ECB Known Answer Test files (new) e: generate ECB Monte Carlo Test files c: generate CBC Monte Carlo Test files and the characters giving the lengths are digits representing the key lengths in 32-bit units (4, 6, 8 for lengths of 128, 192 or 256 bits respectively). The project test_modes tests the AES modes. It uses the files: test_modes: Win32 or x64 headers: aes.h, aescpp.h, brg_types.h, aesaux,h and aestst.h C source: aesaux.c, modetest.c defines: none for static library test, DLL_IMPORT for DLL test which again links to the last library built. E. Other Applications --------------------- These are: gen_tests builds the test_vector files. The commad line is gen_tests /t:knec /k:468 /c as described earlier test_aes_avs run the AES Algorithm Validation Suite tests for ECB, CBC, CFB and OFB modes gen_tables builds a simple version of aes_tab.c (in aestab2.c) for compilers that cannot handle the normal version aes_example provides an example of AES use These applications are linked to the last static library built or, if DLL_IMPORT is defined during compilation, to the last DLL built. F. Use of the VIA ACE Cryptography Engine (x86 only) ---------------------------------------------------- The use of the code with the VIA ACE cryptography engine in described in the file via_ace.txt. In outline aes_modes.c is used and USE_VIA_ACE_IF_PRESENT is defined either in section 2 of aesopt.h or as a compilation option in Visual Studio. If in addition ASSUME_VIA_ACE_PRESENT is also defined then all normal AES code will be removed if not needed to support VIA ACE use. If VIA ACE support is needed and AES assembler is being used only the ASM_X86_V1C and ASM_X86_V2C versions should be used since ASM_X86_V2 and ASM_AMD64 do not support the VIA ACE engine. G. The AES Test Vector Files ---------------------------- These files fall in the following groups (where is a two digit number): 1. ecbvk.txt ECB vectors with variable key 2. ecbvt.txt ECB vectors with variable text 3. ecbnk.txt new ECB vectors with variable key 4. ecbnt.txt new ECB vectors with variable text 5. ecbme.txt ECB monte carlo encryption test vectors 6. ecbmd.txt ECB monte carlo decryption test vectors 7. cbcme.txt CBC monte carlo encryption test vectors 8. cbcmd.txt CBC monte carlo decryption test vectors The first digit of the numeric suffix on the filename gives the block size in 32 bit units and the second numeric digit gives the key size. For example, the file ecbvk44.txt provides the test vectors for ECB encryption with a 128 bit block size and a 128 bit key size. The test routines expect to find these files in the 'testvals' subdirectory within the aes root directory. The 'outvals' subdirectory is used for outputs that are compared with the files in 'testvals'. Note that the monte carlo test vectors are the result of applying AES iteratively 10000 times, not just once. The AES Algorithm Validation Suite tests can be run for ECB, CBC, CFB and OFB modes (CFB1 and CFB8 are not implemented). The test routine uses the *.fax test files, which should be placed in the 'testvals\fax' subdirectory. H. The Basic AES Calling Interface ---------------------------------- The basic AES code keeps its state in a context, there being different contexts for encryption and decryption: aes_encrypt_ctx aes_decrypt_ctx The AES code is initialised with the call aes_init(void) although this is only essential if the option to generate the AES tables at run-time has been set in the options (i.e.fixed tables are not being used). The AES encryption key is set by one of the calls: aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]) aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]) aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]) or by: aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]) where the key length is set by 'key_len', which can be the length in bits or bytes. Similarly, the AES decryption key is set by one of: aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]) aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]) aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]) or by: aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]) Encryption and decryption for a single 16 byte block is then achieved using: aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) The above subroutines return a value of EXIT_SUCCESS or EXIT_FAILURE depending on whether the operation succeeded or failed. I. The Calling Interface for the AES Modes ------------------------------------------ The subroutines for the AES modes, ECB, CBC, CFB, OFB and CTR, each process blocks of variable length and can also be called several times to complete single mode operations incrementally on long messages (or those messages, not all of which are available at the same time). The calls: aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_encrypt_ctx cx[1]) aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_decrypt_ctx cx[1]) for ECB operations and those for CBC: aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_encrypt_ctx cx[1]) aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_decrypt_ctx cx[1]) can only process blocks whose lengths are multiples of 16 bytes but the calls for CFB, OFB and CTR mode operations: aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]) aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]) aes_ofb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]) aes_ofb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]) aes_ctr_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]) aes_ctr_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]) can process blocks of any length. Note also that CFB, OFB and CTR mode calls only use AES encryption contexts even during decryption operations. The calls CTR mode operations use a buffer (cbuf) which holds the counter value together with a function parameter: void cbuf_inc(unsigned char *cbuf); that is ued to update the counter value after each 16 byte AES operation. The counter buffer is updated appropriately to allow for incremental operations. Please note the following IMPORTANT points about the AES mode subroutines: 1. All modes are reset when a new AES key is set. 2. Incremental calls to the different modes cannot be mixed. If a change of mode is needed a new key must be set or a reset must be issued (see below). 3. For modes with IVs, the IV value is an input AND an ouTput since it is updated after each call to the value needed for any subsequent incremental call(s). If the mode is reset, the IV hence has to be set (or reset) as well. 4. ECB operations must be multiples of 16 bytes but do not need to be reset for new operations. 5. CBC operations must also be multiples of 16 bytes and are reset for a new operation by setting the IV. 6. CFB, OFB and CTR mode must be reset by setting a new IV value AND by calling: aes_mode_reset(aes_encrypt_ctx cx[1]) For CTR mode the cbuf value also has to be reset. 7. CFB, OFB and CTR modes only use AES encryption operations and contexts and do not need AES decrytpion operations. 8. AES keys remain valid across resets and changes of mode (but encryption and decryption keys must both be set if they are needed). Brian Gladman 14/11/2013 MediaInfoLib/Source/ThirdParty/aes-gladman/brg_endian.h0000664000000000000000000001225212652076434022017 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #ifndef _BRG_ENDIAN_H #define _BRG_ENDIAN_H #define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ #define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ /* Include files where endian defines and byteswap functions may reside */ #if defined( __sun ) # include #elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ ) # include #elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \ defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ ) # include #elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ ) # if !defined( __MINGW32__ ) && !defined( _AIX ) # include # if !defined( __BEOS__ ) # include # endif # endif #endif /* Now attempt to set the define for platform byte order using any */ /* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */ /* seem to encompass most endian symbol definitions */ #if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN ) # if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( BIG_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( LITTLE_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif #if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN ) # if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( _BIG_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( _LITTLE_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif #if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN ) # if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( __BIG_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( __LITTLE_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif #if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ ) # if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__ # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__ # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( __BIG_ENDIAN__ ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( __LITTLE_ENDIAN__ ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif /* if the platform byte order could not be determined, then try to */ /* set this define using common machine defines */ #if !defined(PLATFORM_BYTE_ORDER) #if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \ defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \ defined( vax ) || defined( vms ) || defined( VMS ) || \ defined( __VMS ) || defined( _M_X64 ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \ defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \ defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \ defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \ defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \ defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \ defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif 0 /* **** EDIT HERE IF NECESSARY **** */ # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #elif 0 /* **** EDIT HERE IF NECESSARY **** */ # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #else # error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order #endif #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/brg_types.h0000664000000000000000000001657012652076434021734 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 The unsigned integer types defined here are of the form uint_t where is the length of the type; for example, the unsigned 32-bit type is 'uint32_t'. These are NOT the same as the 'C99 integer types' that are defined in the inttypes.h and stdint.h headers since attempts to use these types have shown that support for them is still highly variable. However, since the latter are of the form uint_t, a regular expression search and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t') can be used to convert the types used here to the C99 standard types. */ #ifndef _BRG_TYPES_H #define _BRG_TYPES_H #if defined(__cplusplus) extern "C" { #endif #include #include #if defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) # include # define ptrint_t intptr_t #elif defined( __ECOS__ ) # define intptr_t unsigned int # define ptrint_t intptr_t #elif defined( __GNUC__ ) && ( __GNUC__ >= 3 ) # define ptrint_t intptr_t #else # define ptrint_t int #endif #ifndef BRG_UI32 # define BRG_UI32 # if UINT_MAX == 4294967295u # define li_32(h) 0x##h##u # elif ULONG_MAX == 4294967295u # define li_32(h) 0x##h##ul # elif defined( _CRAY ) # error This code needs 32-bit data types, which Cray machines do not provide # else # error Please define uint32_t as a 32-bit unsigned integer type in brg_types.h # endif #endif #ifndef BRG_UI64 # if defined( __BORLANDC__ ) && !defined( __MSDOS__ ) # define BRG_UI64 # define li_64(h) 0x##h##ui64 # elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */ # define BRG_UI64 # define li_64(h) 0x##h##ui64 # elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful # define BRG_UI64 # define li_64(h) 0x##h##ull # elif defined( __MVS__ ) # define BRG_UI64 # define li_64(h) 0x##h##ull # elif defined( UINT_MAX ) && UINT_MAX > 4294967295u # if UINT_MAX == 18446744073709551615u # define BRG_UI64 # define li_64(h) 0x##h##u # endif # elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u # if ULONG_MAX == 18446744073709551615ul # define BRG_UI64 # define li_64(h) 0x##h##ul # endif # elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u # if ULLONG_MAX == 18446744073709551615ull # define BRG_UI64 # define li_64(h) 0x##h##ull # endif # elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u # if ULONG_LONG_MAX == 18446744073709551615ull # define BRG_UI64 # define li_64(h) 0x##h##ull # endif # elif defined( UINT64_MAX ) && UINT64_MAX > 4294967295u # if UINT64_MAX == __UINT64_C(18446744073709551615) # define BRG_UI64 # define li_64(h) __UINT64_C(0x##h) # endif # endif #endif #if !defined( BRG_UI64 ) # if defined( NEED_UINT_64T ) # error Please define uint64_t as an unsigned 64 bit type in brg_types.h # endif #endif #ifndef RETURN_VALUES # define RETURN_VALUES # if defined( DLL_EXPORT ) # if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) # define VOID_RETURN __declspec( dllexport ) void __stdcall # define INT_RETURN __declspec( dllexport ) int __stdcall # elif defined( __GNUC__ ) # define VOID_RETURN __declspec( __dllexport__ ) void # define INT_RETURN __declspec( __dllexport__ ) int # else # error Use of the DLL is only available on the Microsoft, Intel and GCC compilers # endif # elif defined( DLL_IMPORT ) # if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) # define VOID_RETURN __declspec( dllimport ) void __stdcall # define INT_RETURN __declspec( dllimport ) int __stdcall # elif defined( __GNUC__ ) # define VOID_RETURN __declspec( __dllimport__ ) void # define INT_RETURN __declspec( __dllimport__ ) int # else # error Use of the DLL is only available on the Microsoft, Intel and GCC compilers # endif # elif defined( __WATCOMC__ ) # define VOID_RETURN void __cdecl # define INT_RETURN int __cdecl # else # define VOID_RETURN void # define INT_RETURN int # endif #endif /* These defines are used to detect and set the memory alignment of pointers. Note that offsets are in bytes. ALIGN_OFFSET(x,n) return the positive or zero offset of the memory addressed by the pointer 'x' from an address that is aligned on an 'n' byte boundary ('n' is a power of 2) ALIGN_FLOOR(x,n) return a pointer that points to memory that is aligned on an 'n' byte boundary and is not higher than the memory address pointed to by 'x' ('n' is a power of 2) ALIGN_CEIL(x,n) return a pointer that points to memory that is aligned on an 'n' byte boundary and is not lower than the memory address pointed to by 'x' ('n' is a power of 2) */ #define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1)) #define ALIGN_FLOOR(x,n) ((uint8_t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1))) #define ALIGN_CEIL(x,n) ((uint8_t*)(x) + (-((ptrint_t)(x)) & ((n) - 1))) /* These defines are used to declare buffers in a way that allows faster operations on longer variables to be used. In all these defines 'size' must be a power of 2 and >= 8. NOTE that the buffer size is in bytes but the type length is in bits UNIT_TYPEDEF(x,size) declares a variable 'x' of length 'size' bits BUFR_TYPEDEF(x,size,bsize) declares a buffer 'x' of length 'bsize' bytes defined as an array of variables each of 'size' bits (bsize must be a multiple of size / 8) UNIT_CAST(x,size) casts a variable to a type of length 'size' bits UPTR_CAST(x,size) casts a pointer to a pointer to a varaiable of length 'size' bits */ #define UI_TYPE(size) uint##size##_t #define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x #define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)] #define UNIT_CAST(x,size) ((UI_TYPE(size) )(x)) #define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x)) #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes.h0000664000000000000000000001636712652076434020512 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the definitions required to use AES in C. See aesopt.h for optimisation details. */ #ifndef _AES_H #define _AES_H #include /* This include is used to find 8 & 32 bit unsigned integer types */ #include "brg_types.h" #if defined(__cplusplus) extern "C" { #endif #define AES_128 /* if a fast 128 bit key scheduler is needed */ #define AES_192 /* if a fast 192 bit key scheduler is needed */ #define AES_256 /* if a fast 256 bit key scheduler is needed */ #define AES_VAR /* if variable key size scheduler is needed */ #define AES_MODES /* if support is needed for modes */ /* The following must also be set in assembler files if being used */ #define AES_ENCRYPT /* if support for encryption is needed */ #define AES_DECRYPT /* if support for decryption is needed */ #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ #define N_COLS 4 /* the number of columns in the state */ /* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ /* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ /* or 44, 52 or 60 32-bit words. */ #if defined( AES_VAR ) || defined( AES_256 ) #define KS_LENGTH 60 #elif defined( AES_192 ) #define KS_LENGTH 52 #else #define KS_LENGTH 44 #endif #define AES_RETURN INT_RETURN /* the character array 'inf' in the following structures is used */ /* to hold AES context information. This AES code uses cx->inf.b[0] */ /* to hold the number of rounds multiplied by 16. The other three */ /* elements can be used by code that implements additional modes */ typedef union { uint32_t l; uint8_t b[4]; } aes_inf; #ifdef _MSC_VER #pragma warning( disable : 4324 ) #endif #ifdef _WIN64 __declspec(align(16)) #endif typedef struct { uint32_t ks[KS_LENGTH]; aes_inf inf; } aes_encrypt_ctx; #ifdef _WIN64 __declspec(align(16)) #endif typedef struct { uint32_t ks[KS_LENGTH]; aes_inf inf; } aes_decrypt_ctx; #ifdef _MSC_VER #pragma warning( default : 4324 ) #endif /* This routine must be called before first use if non-static */ /* tables are being used */ AES_RETURN aes_init(void); /* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */ /* those in the range 128 <= key_len <= 256 are given in bits */ #if defined( AES_ENCRYPT ) #if defined( AES_128 ) || defined( AES_VAR) AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined( AES_192 ) || defined( AES_VAR) AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined( AES_256 ) || defined( AES_VAR) AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined( AES_VAR ) AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]); #endif AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); #endif #if defined( AES_DECRYPT ) #if defined( AES_128 ) || defined( AES_VAR) AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined( AES_192 ) || defined( AES_VAR) AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined( AES_256 ) || defined( AES_VAR) AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined( AES_VAR ) AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]); #endif AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); #endif #if defined( AES_MODES ) /* Multiple calls to the following subroutines for multiple block */ /* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */ /* long messages incrementally provided that the context AND the iv */ /* are preserved between all such calls. For the ECB and CBC modes */ /* each individual call within a series of incremental calls must */ /* process only full blocks (i.e. len must be a multiple of 16) but */ /* the CFB, OFB and CTR mode calls can handle multiple incremental */ /* calls of any length. Each mode is reset when a new AES key is */ /* set but ECB and CBC operations can be reset without setting a */ /* new key by setting a new IV value. To reset CFB, OFB and CTR */ /* without setting the key, aes_mode_reset() must be called and the */ /* IV must be set. NOTE: All these calls update the IV on exit so */ /* this has to be reset if a new operation with the same IV as the */ /* previous one is required (or decryption follows encryption with */ /* the same IV array). */ AES_RETURN aes_test_alignment_detection(unsigned int n); AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_encrypt_ctx cx[1]); AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_decrypt_ctx cx[1]); AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_encrypt_ctx cx[1]); AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_decrypt_ctx cx[1]); AES_RETURN aes_mode_reset(aes_encrypt_ctx cx[1]); AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]); AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]); #define aes_ofb_encrypt aes_ofb_crypt #define aes_ofb_decrypt aes_ofb_crypt AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]); typedef void cbuf_inc(unsigned char *cbuf); #define aes_ctr_encrypt aes_ctr_crypt #define aes_ctr_decrypt aes_ctr_crypt AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]); #endif #if defined(__cplusplus) } #endif #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aes_x86_v2.asm0000664000000000000000000011173212652076434022147 0ustar rootroot ; --------------------------------------------------------------------------- ; Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. ; ; The redistribution and use of this software (with or without changes) ; is allowed without the payment of fees or royalties provided that: ; ; source code distributions include the above copyright notice, this ; list of conditions and the following disclaimer; ; ; binary distributions include the above copyright notice, this list ; of conditions and the following disclaimer in their documentation. ; ; This software is provided 'as is' with no explicit or implied warranties ; in respect of its operation, including, but not limited to, correctness ; and fitness for purpose. ; --------------------------------------------------------------------------- ; Issue Date: 20/11/2013 ; ; This code requires either ASM_X86_V2 or ASM_X86_V2C to be set in aesopt.h ; and the same define to be set here as well. If AES_V2C is set this file ; requires the C files aeskey.c and aestab.c for support. ; An AES implementation for x86 processors using the YASM (or NASM) assembler. ; This is a full assembler implementation covering encryption, decryption and ; key scheduling. It uses 2k bytes of tables but its encryption and decryption ; performance is very close to that obtained using large tables. Key schedule ; expansion is slower for both encryption and decryption but this is likely to ; be offset by the much smaller load that this version places on the processor ; cache. I acknowledge the contribution made by Daniel Bernstein to aspects of ; the design of the AES round function used here. ; ; This code provides the standard AES block size (128 bits, 16 bytes) and the ; three standard AES key sizes (128, 192 and 256 bits). It has the same call ; interface as my C implementation. The ebx, esi, edi and ebp registers are ; preserved across calls but eax, ecx and edx and the artihmetic status flags ; are not. Although this is a full assembler implementation, it can be used ; in conjunction with my C code which provides faster key scheduling using ; large tables. In this case aeskey.c should be compiled with ASM_X86_V2C ; defined. It is also important that the defines below match those used in the ; C code. This code uses the VC++ register saving conentions; if it is used ; with another compiler, conventions for using and saving registers may need ; to be checked (and calling conventions). The YASM command line for the VC++ ; custom build step is: ; ; yasm -Xvc -f win32 -D -o "$(TargetDir)\$(InputName).obj" "$(InputPath)" ; ; For the cryptlib build this is (pcg): ; ; yasm -Xvc -f win32 -D ASM_X86_V2C -o aescrypt2.obj aes_x86_v2.asm ; ; where is ASM_X86_V2 or ASM_X86_V2C. The calling intefaces are: ; ; AES_RETURN aes_encrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; where is 128, 102 or 256. In the last two calls the length can be in ; either bits or bytes. ; The DLL interface must use the _stdcall convention in which the number ; of bytes of parameter space is added after an @ to the sutine's name. ; We must also remove our parameters from the stack before return (see ; the do_exit macro). Define DLL_EXPORT for the Dynamic Link Library version. ;%define DLL_EXPORT ; Comment in/out the following lines to obtain the desired subroutines. These ; selections MUST match those in the C header file aes.h ; The size of the code can be reduced by using functions for the encryption ; and decryption rounds in place of macro expansion %define REDUCE_CODE_SIZE %define AES_128 ; define if AES with 128 bit keys is needed %define AES_192 ; define if AES with 192 bit keys is needed %define AES_256 ; define if AES with 256 bit keys is needed %define AES_VAR ; define if a variable key size is needed %define ENCRYPTION ; define if encryption is needed %define DECRYPTION ; define if decryption is needed %define AES_REV_DKS ; define if key decryption schedule is reversed %ifndef ASM_X86_V2C %define ENCRYPTION_KEY_SCHEDULE ; define if encryption key expansion is needed %define DECRYPTION_KEY_SCHEDULE ; define if decryption key expansion is needed %endif ; The encryption key schedule has the following in memory layout where N is the ; number of rounds (10, 12 or 14): ; ; lo: | input key (round 0) | ; each round is four 32-bit words ; | encryption round 1 | ; | encryption round 2 | ; .... ; | encryption round N-1 | ; hi: | encryption round N | ; ; The decryption key schedule is normally set up so that it has the same ; layout as above by actually reversing the order of the encryption key ; schedule in memory (this happens when AES_REV_DKS is set): ; ; lo: | decryption round 0 | = | encryption round N | ; | decryption round 1 | = INV_MIX_COL[ | encryption round N-1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round N-2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round 1 | ] ; hi: | decryption round N | = | input key (round 0) | ; ; with rounds except the first and last modified using inv_mix_column() ; But if AES_REV_DKS is NOT set the order of keys is left as it is for ; encryption so that it has to be accessed in reverse when used for ; decryption (although the inverse mix column modifications are done) ; ; lo: | decryption round 0 | = | input key (round 0) | ; | decryption round 1 | = INV_MIX_COL[ | encryption round 1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round 2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round N-1 | ] ; hi: | decryption round N | = | encryption round N | ; ; This layout is faster when the assembler key scheduling provided here ; is used. ; ; End of user defines section .text align=32 %ifdef AES_VAR %ifndef AES_128 %define AES_128 %endif %ifndef AES_192 %define AES_192 %endif %ifndef AES_256 %define AES_256 %endif %endif %ifdef AES_VAR %define KS_LENGTH 60 %elifdef AES_256 %define KS_LENGTH 60 %elifdef AES_192 %define KS_LENGTH 52 %else %define KS_LENGTH 44 %endif %ifdef REDUCE_CODE_SIZE %macro mf_call 1 call %1 %endmacro %else %macro mf_call 1 %1 %endmacro %endif ; the DLL has to implement the _stdcall calling interface on return ; In this case we have to take our parameters (3 4-byte pointers) ; off the stack %define parms 12 %macro do_name 1-2 parms %ifndef DLL_EXPORT global %1 %1: %else global %1@%2 export %1@%2 %1@%2: %endif %endmacro %macro do_call 1-2 parms %ifndef DLL_EXPORT call %1 add esp,%2 %else call %1@%2 %endif %endmacro %macro do_exit 0-1 parms %ifdef DLL_EXPORT ret %1 %else ret %endif %endmacro %ifndef ASM_X86_V2C do_name _aes_init,0 do_exit 0 %endif ; finite field multiplies by {02}, {04} and {08} %define f2(x) ((x<<1)^(((x>>7)&1)*0x11b)) %define f4(x) ((x<<2)^(((x>>6)&1)*0x11b)^(((x>>6)&2)*0x11b)) %define f8(x) ((x<<3)^(((x>>5)&1)*0x11b)^(((x>>5)&2)*0x11b)^(((x>>5)&4)*0x11b)) ; finite field multiplies required in table generation %define f3(x) (f2(x) ^ x) %define f9(x) (f8(x) ^ x) %define fb(x) (f8(x) ^ f2(x) ^ x) %define fd(x) (f8(x) ^ f4(x) ^ x) %define fe(x) (f8(x) ^ f4(x) ^ f2(x)) %define etab_0(x) [enc_tab+4+8*x] %define etab_1(x) [enc_tab+3+8*x] %define etab_2(x) [enc_tab+2+8*x] %define etab_3(x) [enc_tab+1+8*x] %define etab_b(x) byte [enc_tab+1+8*x] ; used with movzx for 0x000000xx %define etab_w(x) word [enc_tab+8*x] ; used with movzx for 0x0000xx00 %define btab_0(x) [enc_tab+6+8*x] %define btab_1(x) [enc_tab+5+8*x] %define btab_2(x) [enc_tab+4+8*x] %define btab_3(x) [enc_tab+3+8*x] ; ROUND FUNCTION. Build column[2] on ESI and column[3] on EDI that have the ; round keys pre-loaded. Build column[0] in EBP and column[1] in EBX. ; ; Input: ; ; EAX column[0] ; EBX column[1] ; ECX column[2] ; EDX column[3] ; ESI column key[round][2] ; EDI column key[round][3] ; EBP scratch ; ; Output: ; ; EBP column[0] unkeyed ; EBX column[1] unkeyed ; ESI column[2] keyed ; EDI column[3] keyed ; EAX scratch ; ECX scratch ; EDX scratch %macro rnd_fun 2 rol ebx,16 %1 esi, cl, 0, ebp %1 esi, dh, 1, ebp %1 esi, bh, 3, ebp %1 edi, dl, 0, ebp %1 edi, ah, 1, ebp %1 edi, bl, 2, ebp %2 ebp, al, 0, ebp shr ebx,16 and eax,0xffff0000 or eax,ebx shr edx,16 %1 ebp, ah, 1, ebx %1 ebp, dh, 3, ebx %2 ebx, dl, 2, ebx %1 ebx, ch, 1, edx %1 ebx, al, 0, edx shr eax,16 shr ecx,16 %1 ebp, cl, 2, edx %1 edi, ch, 3, edx %1 esi, al, 2, edx %1 ebx, ah, 3, edx %endmacro ; Basic MOV and XOR Operations for normal rounds %macro nr_xor 4 movzx %4,%2 xor %1,etab_%3(%4) %endmacro %macro nr_mov 4 movzx %4,%2 mov %1,etab_%3(%4) %endmacro ; Basic MOV and XOR Operations for last round %if 1 %macro lr_xor 4 movzx %4,%2 movzx %4,etab_b(%4) %if %3 != 0 shl %4,8*%3 %endif xor %1,%4 %endmacro %macro lr_mov 4 movzx %4,%2 movzx %1,etab_b(%4) %if %3 != 0 shl %1,8*%3 %endif %endmacro %else ; less effective but worth leaving as an option %macro lr_xor 4 movzx %4,%2 mov %4,btab_%3(%4) and %4,0x000000ff << 8 * %3 xor %1,%4 %endmacro %macro lr_mov 4 movzx %4,%2 mov %1,btab_%3(%4) and %1,0x000000ff << 8 * %3 %endmacro %endif ; Apply S-Box to the 4 bytes in a 32-bit word and rotate byte positions %ifdef REDUCE_CODE_SIZE global _ls_sub _ls_sub: ; ls_sub(t,n) = ls_box(t,n) mov ecx,[esp+8] mov eax,[esp+4] shl ecx,3 rol eax,cl xor edx,edx l3s_col: movzx ecx,al ; in eax movzx ecx, etab_b(ecx) ; out eax xor edx,ecx ; scratch ecx,edx movzx ecx,ah movzx ecx, etab_b(ecx) shl ecx,8 xor edx,ecx shr eax,16 movzx ecx,al movzx ecx, etab_b(ecx) shl ecx,16 xor edx,ecx movzx ecx,ah movzx ecx, etab_b(ecx) shl ecx,24 xor edx,ecx mov eax,edx ret %else %macro l3s_col 0 movzx ecx,al ; in eax movzx ecx, etab_b(ecx) ; out eax xor edx,ecx ; scratch ecx,edx movzx ecx,ah movzx ecx, etab_b(ecx) shl ecx,8 xor edx,ecx shr eax,16 movzx ecx,al movzx ecx, etab_b(ecx) shl ecx,16 xor edx,ecx movzx ecx,ah movzx ecx, etab_b(ecx) shl ecx,24 xor edx,ecx mov eax,edx %endmacro %endif ; offsets to parameters in_blk equ 4 ; input byte array address parameter out_blk equ 8 ; output byte array address parameter ctx equ 12 ; AES context structure stk_spc equ 16 ; stack space %ifdef ENCRYPTION %define ENCRYPTION_TABLE %macro _enc_round 0 add ebp,16 mov esi,[ebp+8] mov edi,[ebp+12] push ebp rnd_fun nr_xor, nr_mov mov eax,ebp pop ebp mov ecx,esi mov edx,edi xor eax,[ebp] xor ebx,[ebp+4] %endmacro %ifdef REDUCE_CODE_SIZE enc_round: _enc_round ret %else %macro enc_round 0 _enc_round %endmacro %endif %macro enc_last_round 0 add ebp,16 mov esi,[ebp+8] mov edi,[ebp+12] push ebp rnd_fun lr_xor, lr_mov mov eax,ebp pop ebp xor eax,[ebp] xor ebx,[ebp+4] %endmacro ; AES Encryption Subroutine do_name _aes_encrypt,12 push ebp push ebx push esi push edi ; load the input block mov esi,[esp+in_blk+stk_spc] ; input pointer mov eax,[esi ] mov ebx,[esi+ 4] mov ecx,[esi+ 8] mov edx,[esi+12] ; and xor in first key block mov ebp,[esp+ctx+stk_spc] ; key pointer movzx edi,byte [ebp+4*KS_LENGTH] xor eax,[ebp ] xor ebx,[ebp+ 4] xor ecx,[ebp+ 8] xor edx,[ebp+12] ; determine the number of rounds cmp edi,10*16 je .3 cmp edi,12*16 je .2 cmp edi,14*16 je .1 mov eax,-1 jmp .5 ; do the encryption rounds .1: mf_call enc_round mf_call enc_round .2: mf_call enc_round mf_call enc_round .3: mf_call enc_round mf_call enc_round mf_call enc_round mf_call enc_round mf_call enc_round mf_call enc_round mf_call enc_round mf_call enc_round mf_call enc_round enc_last_round ; output the block mov edx,[esp+out_blk+stk_spc] mov [edx ],eax mov [edx+ 4],ebx mov [edx+ 8],esi mov [edx+12],edi xor eax,eax .5: pop edi pop esi pop ebx pop ebp do_exit 12 %endif %macro f_key 2 push ecx push edx mov edx,esi ror eax,8 mf_call l3s_col mov esi,eax pop edx pop ecx xor esi,rc_val mov [ebp+%1*%2],esi xor edi,esi mov [ebp+%1*%2+4],edi xor ecx,edi mov [ebp+%1*%2+8],ecx xor edx,ecx mov [ebp+%1*%2+12],edx mov eax,edx %if %2 == 24 %if %1 < 7 xor eax,[ebp+%1*%2+16-%2] mov [ebp+%1*%2+16],eax xor eax,[ebp+%1*%2+20-%2] mov [ebp+%1*%2+20],eax %endif %elif %2 == 32 %if %1 < 6 push ecx push edx mov edx,[ebp+%1*%2+16-%2] mf_call l3s_col pop edx pop ecx mov [ebp+%1*%2+16],eax xor eax,[ebp+%1*%2+20-%2] mov [ebp+%1*%2+20],eax xor eax,[ebp+%1*%2+24-%2] mov [ebp+%1*%2+24],eax xor eax,[ebp+%1*%2+28-%2] mov [ebp+%1*%2+28],eax %endif %endif %assign rc_val f2(rc_val) %endmacro %ifdef ENCRYPTION_KEY_SCHEDULE %ifdef AES_128 %ifndef ENCRYPTION_TABLE %define ENCRYPTION_TABLE %endif %assign rc_val 1 align 32 do_name _aes_encrypt_key128,8 push ebp push ebx push esi push edi mov ebp,[esp+24] mov [ebp+4*KS_LENGTH],dword 10*16 mov ebx,[esp+20] mov esi,[ebx] mov [ebp],esi mov edi,[ebx+4] mov [ebp+4],edi mov ecx,[ebx+8] mov [ebp+8],ecx mov edx,[ebx+12] mov [ebp+12],edx add ebp,16 mov eax,edx f_key 0,16 ; 11 * 4 = 44 unsigned longs f_key 1,16 ; 4 + 4 * 10 generated = 44 f_key 2,16 f_key 3,16 f_key 4,16 f_key 5,16 f_key 6,16 f_key 7,16 f_key 8,16 f_key 9,16 pop edi pop esi pop ebx pop ebp xor eax,eax do_exit 8 %endif %ifdef AES_192 %ifndef ENCRYPTION_TABLE %define ENCRYPTION_TABLE %endif %assign rc_val 1 align 32 do_name _aes_encrypt_key192,8 push ebp push ebx push esi push edi mov ebp,[esp+24] mov [ebp+4*KS_LENGTH],dword 12 * 16 mov ebx,[esp+20] mov esi,[ebx] mov [ebp],esi mov edi,[ebx+4] mov [ebp+4],edi mov ecx,[ebx+8] mov [ebp+8],ecx mov edx,[ebx+12] mov [ebp+12],edx mov eax,[ebx+16] mov [ebp+16],eax mov eax,[ebx+20] mov [ebp+20],eax add ebp,24 f_key 0,24 ; 13 * 4 = 52 unsigned longs f_key 1,24 ; 6 + 6 * 8 generated = 54 f_key 2,24 f_key 3,24 f_key 4,24 f_key 5,24 f_key 6,24 f_key 7,24 pop edi pop esi pop ebx pop ebp xor eax,eax do_exit 8 %endif %ifdef AES_256 %ifndef ENCRYPTION_TABLE %define ENCRYPTION_TABLE %endif %assign rc_val 1 align 32 do_name _aes_encrypt_key256,8 push ebp push ebx push esi push edi mov ebp,[esp+24] mov [ebp+4*KS_LENGTH],dword 14 * 16 mov ebx,[esp+20] mov esi,[ebx] mov [ebp],esi mov edi,[ebx+4] mov [ebp+4],edi mov ecx,[ebx+8] mov [ebp+8],ecx mov edx,[ebx+12] mov [ebp+12],edx mov eax,[ebx+16] mov [ebp+16],eax mov eax,[ebx+20] mov [ebp+20],eax mov eax,[ebx+24] mov [ebp+24],eax mov eax,[ebx+28] mov [ebp+28],eax add ebp,32 f_key 0,32 ; 15 * 4 = 60 unsigned longs f_key 1,32 ; 8 + 8 * 7 generated = 64 f_key 2,32 f_key 3,32 f_key 4,32 f_key 5,32 f_key 6,32 pop edi pop esi pop ebx pop ebp xor eax,eax do_exit 8 %endif %ifdef AES_VAR %ifndef ENCRYPTION_TABLE %define ENCRYPTION_TABLE %endif align 32 do_name _aes_encrypt_key,12 mov ecx,[esp+4] mov eax,[esp+8] mov edx,[esp+12] push edx push ecx cmp eax,16 je .1 cmp eax,128 je .1 cmp eax,24 je .2 cmp eax,192 je .2 cmp eax,32 je .3 cmp eax,256 je .3 mov eax,-1 add esp,8 do_exit 12 .1: do_call _aes_encrypt_key128,8 do_exit 12 .2: do_call _aes_encrypt_key192,8 do_exit 12 .3: do_call _aes_encrypt_key256,8 do_exit 12 %endif %endif %ifdef DECRYPTION %define DECRYPTION_TABLE %define dtab_0(x) [dec_tab+ 8*x] %define dtab_1(x) [dec_tab+3+8*x] %define dtab_2(x) [dec_tab+2+8*x] %define dtab_3(x) [dec_tab+1+8*x] %define dtab_x(x) byte [dec_tab+7+8*x] %macro irn_fun 2 rol eax,16 %1 esi, cl, 0, ebp %1 esi, bh, 1, ebp %1 esi, al, 2, ebp %1 edi, dl, 0, ebp %1 edi, ch, 1, ebp %1 edi, ah, 3, ebp %2 ebp, bl, 0, ebp shr eax,16 and ebx,0xffff0000 or ebx,eax shr ecx,16 %1 ebp, bh, 1, eax %1 ebp, ch, 3, eax %2 eax, cl, 2, ecx %1 eax, bl, 0, ecx %1 eax, dh, 1, ecx shr ebx,16 shr edx,16 %1 esi, dh, 3, ecx %1 ebp, dl, 2, ecx %1 eax, bh, 3, ecx %1 edi, bl, 2, ecx %endmacro ; Basic MOV and XOR Operations for normal rounds %macro ni_xor 4 movzx %4,%2 xor %1,dtab_%3(%4) %endmacro %macro ni_mov 4 movzx %4,%2 mov %1,dtab_%3(%4) %endmacro ; Basic MOV and XOR Operations for last round %macro li_xor 4 movzx %4,%2 movzx %4,dtab_x(%4) %if %3 != 0 shl %4,8*%3 %endif xor %1,%4 %endmacro %macro li_mov 4 movzx %4,%2 movzx %1,dtab_x(%4) %if %3 != 0 shl %1,8*%3 %endif %endmacro %macro _dec_round 0 %ifdef AES_REV_DKS add ebp,16 %else sub ebp,16 %endif mov esi,[ebp+8] mov edi,[ebp+12] push ebp irn_fun ni_xor, ni_mov mov ebx,ebp pop ebp mov ecx,esi mov edx,edi xor eax,[ebp] xor ebx,[ebp+4] %endmacro %ifdef REDUCE_CODE_SIZE section .text align=32 dec_round: _dec_round ret %else %macro dec_round 0 _dec_round %endmacro %endif %macro dec_last_round 0 %ifdef AES_REV_DKS add ebp,16 %else sub ebp,16 %endif mov esi,[ebp+8] mov edi,[ebp+12] push ebp irn_fun li_xor, li_mov mov ebx,ebp pop ebp xor eax,[ebp] xor ebx,[ebp+4] %endmacro ; AES Decryption Subroutine do_name _aes_decrypt,12 push ebp push ebx push esi push edi ; load the input block mov esi,[esp+in_blk+stk_spc] ; input pointer mov eax,[esi ] mov ebx,[esi+ 4] mov ecx,[esi+ 8] mov edx,[esi+12] lea esi,[esi+16] ; xor in the first round key mov ebp,[esp+ctx+stk_spc] ; key pointer movzx edi,byte[ebp+4*KS_LENGTH] %ifndef AES_REV_DKS ; if decryption key schedule is not reversed lea ebp,[ebp+edi] ; we have to access it from the top down %endif xor eax,[ebp ] ; key schedule xor ebx,[ebp+ 4] xor ecx,[ebp+ 8] xor edx,[ebp+12] ; determine the number of rounds cmp edi,10*16 je .3 cmp edi,12*16 je .2 cmp edi,14*16 je .1 mov eax,-1 jmp .5 ; perform the decryption rounds .1: mf_call dec_round mf_call dec_round .2: mf_call dec_round mf_call dec_round .3: mf_call dec_round mf_call dec_round mf_call dec_round mf_call dec_round mf_call dec_round mf_call dec_round mf_call dec_round mf_call dec_round mf_call dec_round dec_last_round ; output the block mov ebp,[esp+out_blk+stk_spc] mov [ebp ],eax mov [ebp+ 4],ebx mov [ebp+ 8],esi mov [ebp+12],edi xor eax,eax .5: pop edi pop esi pop ebx pop ebp do_exit 12 %endif %ifdef REDUCE_CODE_SIZE global _im_sub _im_sub: mov edx,[esp+4] inv_mix_col: movzx ecx,dl ; input eax, edx movzx ecx,etab_b(ecx) ; output eax mov eax,dtab_0(ecx) ; used ecx movzx ecx,dh shr edx,16 movzx ecx,etab_b(ecx) xor eax,dtab_1(ecx) movzx ecx,dl movzx ecx,etab_b(ecx) xor eax,dtab_2(ecx) movzx ecx,dh movzx ecx,etab_b(ecx) xor eax,dtab_3(ecx) ret %else %macro inv_mix_col 0 movzx ecx,dl ; input eax, edx movzx ecx,etab_b(ecx) ; output eax mov eax,dtab_0(ecx) ; used ecx movzx ecx,dh shr edx,16 movzx ecx,etab_b(ecx) xor eax,dtab_1(ecx) movzx ecx,dl movzx ecx,etab_b(ecx) xor eax,dtab_2(ecx) movzx ecx,dh movzx ecx,etab_b(ecx) xor eax,dtab_3(ecx) %endmacro %endif %ifdef DECRYPTION_KEY_SCHEDULE %ifdef AES_128 %ifndef DECRYPTION_TABLE %define DECRYPTION_TABLE %endif align 32 do_name _aes_decrypt_key128,8 push ebp push ebx push esi push edi mov eax,[esp+24] ; context mov edx,[esp+20] ; key push eax push edx do_call _aes_encrypt_key128,8 ; generate expanded encryption key mov eax,10*16 mov esi,[esp+24] ; pointer to first round key lea edi,[esi+eax] ; pointer to last round key add esi,32 ; the inverse mix column transformation mov edx,[esi-16] ; needs to be applied to all round keys mf_call inv_mix_col ; except first and last. Hence start by mov [esi-16],eax ; transforming the four sub-keys in the mov edx,[esi-12] ; second round key mf_call inv_mix_col mov [esi-12],eax ; transformations for subsequent rounds mov edx,[esi-8] ; can then be made more efficient by mf_call inv_mix_col ; noting that for three of the four sub-keys mov [esi-8],eax ; in the encryption round key ek[r]: mov edx,[esi-4] ; mf_call inv_mix_col ; ek[r][n] = ek[r][n-1] ^ ek[r-1][n] mov [esi-4],eax ; ; where n is 1..3. Hence the corresponding .0: mov edx,[esi] ; subkeys in the decryption round key dk[r] mf_call inv_mix_col ; also obey since inv_mix_col is linear in mov [esi],eax ; GF(256): xor eax,[esi-12] ; mov [esi+4],eax ; dk[r][n] = dk[r][n-1] ^ dk[r-1][n] xor eax,[esi-8] ; mov [esi+8],eax ; So we only need one inverse mix column xor eax,[esi-4] ; operation (n = 0) for each four word cycle mov [esi+12],eax ; in the expanded key. add esi,16 cmp edi,esi jg .0 jmp dec_end %endif %ifdef AES_192 %ifndef DECRYPTION_TABLE %define DECRYPTION_TABLE %endif align 32 do_name _aes_decrypt_key192,8 push ebp push ebx push esi push edi mov eax,[esp+24] ; context mov edx,[esp+20] ; key push eax push edx do_call _aes_encrypt_key192,8 ; generate expanded encryption key mov eax,12*16 mov esi,[esp+24] ; first round key lea edi,[esi+eax] ; last round key add esi,48 ; the first 6 words are the key, of ; which the top 2 words are part of mov edx,[esi-32] ; the second round key and hence mf_call inv_mix_col ; need to be modified. After this we mov [esi-32],eax ; need to do a further six values prior mov edx,[esi-28] ; to using a more efficient technique mf_call inv_mix_col ; based on: mov [esi-28],eax ; ; dk[r][n] = dk[r][n-1] ^ dk[r-1][n] mov edx,[esi-24] ; mf_call inv_mix_col ; for n = 1 .. 5 where the key expansion mov [esi-24],eax ; cycle is now 6 words long mov edx,[esi-20] mf_call inv_mix_col mov [esi-20],eax mov edx,[esi-16] mf_call inv_mix_col mov [esi-16],eax mov edx,[esi-12] mf_call inv_mix_col mov [esi-12],eax mov edx,[esi-8] mf_call inv_mix_col mov [esi-8],eax mov edx,[esi-4] mf_call inv_mix_col mov [esi-4],eax .0: mov edx,[esi] ; the expanded key is 13 * 4 = 44 32-bit words mf_call inv_mix_col ; of which 11 * 4 = 44 have to be modified mov [esi],eax ; using inv_mix_col. We have already done 8 xor eax,[esi-20] ; of these so 36 are left - hence we need mov [esi+4],eax ; exactly 6 loops of six here xor eax,[esi-16] mov [esi+8],eax xor eax,[esi-12] mov [esi+12],eax xor eax,[esi-8] mov [esi+16],eax xor eax,[esi-4] mov [esi+20],eax add esi,24 cmp edi,esi jg .0 jmp dec_end %endif %ifdef AES_256 %ifndef DECRYPTION_TABLE %define DECRYPTION_TABLE %endif align 32 do_name _aes_decrypt_key256,8 push ebp push ebx push esi push edi mov eax,[esp+24] mov edx,[esp+20] push eax push edx do_call _aes_encrypt_key256,8 ; generate expanded encryption key mov eax,14*16 mov esi,[esp+24] lea edi,[esi+eax] add esi,64 mov edx,[esi-48] ; the primary key is 8 words, of which mf_call inv_mix_col ; the top four require modification mov [esi-48],eax mov edx,[esi-44] mf_call inv_mix_col mov [esi-44],eax mov edx,[esi-40] mf_call inv_mix_col mov [esi-40],eax mov edx,[esi-36] mf_call inv_mix_col mov [esi-36],eax mov edx,[esi-32] ; the encryption key expansion cycle is mf_call inv_mix_col ; now eight words long so we need to mov [esi-32],eax ; start by doing one complete block mov edx,[esi-28] mf_call inv_mix_col mov [esi-28],eax mov edx,[esi-24] mf_call inv_mix_col mov [esi-24],eax mov edx,[esi-20] mf_call inv_mix_col mov [esi-20],eax mov edx,[esi-16] mf_call inv_mix_col mov [esi-16],eax mov edx,[esi-12] mf_call inv_mix_col mov [esi-12],eax mov edx,[esi-8] mf_call inv_mix_col mov [esi-8],eax mov edx,[esi-4] mf_call inv_mix_col mov [esi-4],eax .0: mov edx,[esi] ; we can now speed up the remaining mf_call inv_mix_col ; rounds by using the technique mov [esi],eax ; outlined earlier. But note that xor eax,[esi-28] ; there is one extra inverse mix mov [esi+4],eax ; column operation as the 256 bit xor eax,[esi-24] ; key has an extra non-linear step mov [esi+8],eax ; for the midway element. xor eax,[esi-20] mov [esi+12],eax ; the expanded key is 15 * 4 = 60 mov edx,[esi+16] ; 32-bit words of which 52 need to mf_call inv_mix_col ; be modified. We have already done mov [esi+16],eax ; 12 so 40 are left - which means xor eax,[esi-12] ; that we need exactly 5 loops of 8 mov [esi+20],eax xor eax,[esi-8] mov [esi+24],eax xor eax,[esi-4] mov [esi+28],eax add esi,32 cmp edi,esi jg .0 %endif dec_end: %ifdef AES_REV_DKS mov esi,[esp+24] ; this reverses the order of the .1: mov eax,[esi] ; round keys if required mov ebx,[esi+4] mov ebp,[edi] mov edx,[edi+4] mov [esi],ebp mov [esi+4],edx mov [edi],eax mov [edi+4],ebx mov eax,[esi+8] mov ebx,[esi+12] mov ebp,[edi+8] mov edx,[edi+12] mov [esi+8],ebp mov [esi+12],edx mov [edi+8],eax mov [edi+12],ebx add esi,16 sub edi,16 cmp edi,esi jg .1 %endif pop edi pop esi pop ebx pop ebp xor eax,eax do_exit 8 %ifdef AES_VAR align 32 do_name _aes_decrypt_key,12 mov ecx,[esp+4] mov eax,[esp+8] mov edx,[esp+12] push edx push ecx cmp eax,16 je .1 cmp eax,128 je .1 cmp eax,24 je .2 cmp eax,192 je .2 cmp eax,32 je .3 cmp eax,256 je .3 mov eax,-1 add esp,8 do_exit 12 .1: do_call _aes_decrypt_key128,8 do_exit 12 .2: do_call _aes_decrypt_key192,8 do_exit 12 .3: do_call _aes_decrypt_key256,8 do_exit 12 %endif %endif section .data align=32 %ifdef ENCRYPTION_TABLE ; S-box data - 256 entries %define u8(x) 0, x, x, f3(x), f2(x), x, x, f3(x) enc_tab: db u8(0x63),u8(0x7c),u8(0x77),u8(0x7b),u8(0xf2),u8(0x6b),u8(0x6f),u8(0xc5) db u8(0x30),u8(0x01),u8(0x67),u8(0x2b),u8(0xfe),u8(0xd7),u8(0xab),u8(0x76) db u8(0xca),u8(0x82),u8(0xc9),u8(0x7d),u8(0xfa),u8(0x59),u8(0x47),u8(0xf0) db u8(0xad),u8(0xd4),u8(0xa2),u8(0xaf),u8(0x9c),u8(0xa4),u8(0x72),u8(0xc0) db u8(0xb7),u8(0xfd),u8(0x93),u8(0x26),u8(0x36),u8(0x3f),u8(0xf7),u8(0xcc) db u8(0x34),u8(0xa5),u8(0xe5),u8(0xf1),u8(0x71),u8(0xd8),u8(0x31),u8(0x15) db u8(0x04),u8(0xc7),u8(0x23),u8(0xc3),u8(0x18),u8(0x96),u8(0x05),u8(0x9a) db u8(0x07),u8(0x12),u8(0x80),u8(0xe2),u8(0xeb),u8(0x27),u8(0xb2),u8(0x75) db u8(0x09),u8(0x83),u8(0x2c),u8(0x1a),u8(0x1b),u8(0x6e),u8(0x5a),u8(0xa0) db u8(0x52),u8(0x3b),u8(0xd6),u8(0xb3),u8(0x29),u8(0xe3),u8(0x2f),u8(0x84) db u8(0x53),u8(0xd1),u8(0x00),u8(0xed),u8(0x20),u8(0xfc),u8(0xb1),u8(0x5b) db u8(0x6a),u8(0xcb),u8(0xbe),u8(0x39),u8(0x4a),u8(0x4c),u8(0x58),u8(0xcf) db u8(0xd0),u8(0xef),u8(0xaa),u8(0xfb),u8(0x43),u8(0x4d),u8(0x33),u8(0x85) db u8(0x45),u8(0xf9),u8(0x02),u8(0x7f),u8(0x50),u8(0x3c),u8(0x9f),u8(0xa8) db u8(0x51),u8(0xa3),u8(0x40),u8(0x8f),u8(0x92),u8(0x9d),u8(0x38),u8(0xf5) db u8(0xbc),u8(0xb6),u8(0xda),u8(0x21),u8(0x10),u8(0xff),u8(0xf3),u8(0xd2) db u8(0xcd),u8(0x0c),u8(0x13),u8(0xec),u8(0x5f),u8(0x97),u8(0x44),u8(0x17) db u8(0xc4),u8(0xa7),u8(0x7e),u8(0x3d),u8(0x64),u8(0x5d),u8(0x19),u8(0x73) db u8(0x60),u8(0x81),u8(0x4f),u8(0xdc),u8(0x22),u8(0x2a),u8(0x90),u8(0x88) db u8(0x46),u8(0xee),u8(0xb8),u8(0x14),u8(0xde),u8(0x5e),u8(0x0b),u8(0xdb) db u8(0xe0),u8(0x32),u8(0x3a),u8(0x0a),u8(0x49),u8(0x06),u8(0x24),u8(0x5c) db u8(0xc2),u8(0xd3),u8(0xac),u8(0x62),u8(0x91),u8(0x95),u8(0xe4),u8(0x79) db u8(0xe7),u8(0xc8),u8(0x37),u8(0x6d),u8(0x8d),u8(0xd5),u8(0x4e),u8(0xa9) db u8(0x6c),u8(0x56),u8(0xf4),u8(0xea),u8(0x65),u8(0x7a),u8(0xae),u8(0x08) db u8(0xba),u8(0x78),u8(0x25),u8(0x2e),u8(0x1c),u8(0xa6),u8(0xb4),u8(0xc6) db u8(0xe8),u8(0xdd),u8(0x74),u8(0x1f),u8(0x4b),u8(0xbd),u8(0x8b),u8(0x8a) db u8(0x70),u8(0x3e),u8(0xb5),u8(0x66),u8(0x48),u8(0x03),u8(0xf6),u8(0x0e) db u8(0x61),u8(0x35),u8(0x57),u8(0xb9),u8(0x86),u8(0xc1),u8(0x1d),u8(0x9e) db u8(0xe1),u8(0xf8),u8(0x98),u8(0x11),u8(0x69),u8(0xd9),u8(0x8e),u8(0x94) db u8(0x9b),u8(0x1e),u8(0x87),u8(0xe9),u8(0xce),u8(0x55),u8(0x28),u8(0xdf) db u8(0x8c),u8(0xa1),u8(0x89),u8(0x0d),u8(0xbf),u8(0xe6),u8(0x42),u8(0x68) db u8(0x41),u8(0x99),u8(0x2d),u8(0x0f),u8(0xb0),u8(0x54),u8(0xbb),u8(0x16) %endif %ifdef DECRYPTION_TABLE ; Inverse S-box data - 256 entries %define v8(x) fe(x), f9(x), fd(x), fb(x), fe(x), f9(x), fd(x), x dec_tab: db v8(0x52),v8(0x09),v8(0x6a),v8(0xd5),v8(0x30),v8(0x36),v8(0xa5),v8(0x38) db v8(0xbf),v8(0x40),v8(0xa3),v8(0x9e),v8(0x81),v8(0xf3),v8(0xd7),v8(0xfb) db v8(0x7c),v8(0xe3),v8(0x39),v8(0x82),v8(0x9b),v8(0x2f),v8(0xff),v8(0x87) db v8(0x34),v8(0x8e),v8(0x43),v8(0x44),v8(0xc4),v8(0xde),v8(0xe9),v8(0xcb) db v8(0x54),v8(0x7b),v8(0x94),v8(0x32),v8(0xa6),v8(0xc2),v8(0x23),v8(0x3d) db v8(0xee),v8(0x4c),v8(0x95),v8(0x0b),v8(0x42),v8(0xfa),v8(0xc3),v8(0x4e) db v8(0x08),v8(0x2e),v8(0xa1),v8(0x66),v8(0x28),v8(0xd9),v8(0x24),v8(0xb2) db v8(0x76),v8(0x5b),v8(0xa2),v8(0x49),v8(0x6d),v8(0x8b),v8(0xd1),v8(0x25) db v8(0x72),v8(0xf8),v8(0xf6),v8(0x64),v8(0x86),v8(0x68),v8(0x98),v8(0x16) db v8(0xd4),v8(0xa4),v8(0x5c),v8(0xcc),v8(0x5d),v8(0x65),v8(0xb6),v8(0x92) db v8(0x6c),v8(0x70),v8(0x48),v8(0x50),v8(0xfd),v8(0xed),v8(0xb9),v8(0xda) db v8(0x5e),v8(0x15),v8(0x46),v8(0x57),v8(0xa7),v8(0x8d),v8(0x9d),v8(0x84) db v8(0x90),v8(0xd8),v8(0xab),v8(0x00),v8(0x8c),v8(0xbc),v8(0xd3),v8(0x0a) db v8(0xf7),v8(0xe4),v8(0x58),v8(0x05),v8(0xb8),v8(0xb3),v8(0x45),v8(0x06) db v8(0xd0),v8(0x2c),v8(0x1e),v8(0x8f),v8(0xca),v8(0x3f),v8(0x0f),v8(0x02) db v8(0xc1),v8(0xaf),v8(0xbd),v8(0x03),v8(0x01),v8(0x13),v8(0x8a),v8(0x6b) db v8(0x3a),v8(0x91),v8(0x11),v8(0x41),v8(0x4f),v8(0x67),v8(0xdc),v8(0xea) db v8(0x97),v8(0xf2),v8(0xcf),v8(0xce),v8(0xf0),v8(0xb4),v8(0xe6),v8(0x73) db v8(0x96),v8(0xac),v8(0x74),v8(0x22),v8(0xe7),v8(0xad),v8(0x35),v8(0x85) db v8(0xe2),v8(0xf9),v8(0x37),v8(0xe8),v8(0x1c),v8(0x75),v8(0xdf),v8(0x6e) db v8(0x47),v8(0xf1),v8(0x1a),v8(0x71),v8(0x1d),v8(0x29),v8(0xc5),v8(0x89) db v8(0x6f),v8(0xb7),v8(0x62),v8(0x0e),v8(0xaa),v8(0x18),v8(0xbe),v8(0x1b) db v8(0xfc),v8(0x56),v8(0x3e),v8(0x4b),v8(0xc6),v8(0xd2),v8(0x79),v8(0x20) db v8(0x9a),v8(0xdb),v8(0xc0),v8(0xfe),v8(0x78),v8(0xcd),v8(0x5a),v8(0xf4) db v8(0x1f),v8(0xdd),v8(0xa8),v8(0x33),v8(0x88),v8(0x07),v8(0xc7),v8(0x31) db v8(0xb1),v8(0x12),v8(0x10),v8(0x59),v8(0x27),v8(0x80),v8(0xec),v8(0x5f) db v8(0x60),v8(0x51),v8(0x7f),v8(0xa9),v8(0x19),v8(0xb5),v8(0x4a),v8(0x0d) db v8(0x2d),v8(0xe5),v8(0x7a),v8(0x9f),v8(0x93),v8(0xc9),v8(0x9c),v8(0xef) db v8(0xa0),v8(0xe0),v8(0x3b),v8(0x4d),v8(0xae),v8(0x2a),v8(0xf5),v8(0xb0) db v8(0xc8),v8(0xeb),v8(0xbb),v8(0x3c),v8(0x83),v8(0x53),v8(0x99),v8(0x61) db v8(0x17),v8(0x2b),v8(0x04),v8(0x7e),v8(0xba),v8(0x77),v8(0xd6),v8(0x26) db v8(0xe1),v8(0x69),v8(0x14),v8(0x63),v8(0x55),v8(0x21),v8(0x0c),v8(0x7d) %endif end MediaInfoLib/Source/ThirdParty/aes-gladman/aeskey.c0000664000000000000000000004020012652076434021175 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #include "aesopt.h" #include "aestab.h" #if defined( USE_INTEL_AES_IF_PRESENT ) # include "aes_ni.h" #else /* map names here to provide the external API ('name' -> 'aes_name') */ # define aes_xi(x) aes_ ## x #endif #ifdef USE_VIA_ACE_IF_PRESENT # include "aes_via_ace.h" #endif #if defined(__cplusplus) extern "C" { #endif /* Initialise the key schedule from the user supplied key. The key length can be specified in bytes, with legal values of 16, 24 and 32, or in bits, with legal values of 128, 192 and 256. These values correspond with Nk values of 4, 6 and 8 respectively. The following macros implement a single cycle in the key schedule generation process. The number of cycles needed for each cx->n_col and nk value is: nk = 4 5 6 7 8 ------------------------------ cx->n_col = 4 10 9 8 7 7 cx->n_col = 5 14 11 10 9 9 cx->n_col = 6 19 15 12 11 11 cx->n_col = 7 21 19 16 13 14 cx->n_col = 8 29 23 19 17 14 */ #if defined( REDUCE_CODE_SIZE ) # define ls_box ls_sub uint32_t ls_sub(const uint32_t t, const uint32_t n); # define inv_mcol im_sub uint32_t im_sub(const uint32_t x); # ifdef ENC_KS_UNROLL # undef ENC_KS_UNROLL # endif # ifdef DEC_KS_UNROLL # undef DEC_KS_UNROLL # endif #endif #if (FUNCS_IN_C & ENC_KEYING_IN_C) #if defined(AES_128) || defined( AES_VAR ) #define ke4(k,i) \ { k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \ k[4*(i)+5] = ss[1] ^= ss[0]; \ k[4*(i)+6] = ss[2] ^= ss[1]; \ k[4*(i)+7] = ss[3] ^= ss[2]; \ } AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1]) { uint32_t ss[4]; cx->ks[0] = ss[0] = word_in(key, 0); cx->ks[1] = ss[1] = word_in(key, 1); cx->ks[2] = ss[2] = word_in(key, 2); cx->ks[3] = ss[3] = word_in(key, 3); #ifdef ENC_KS_UNROLL ke4(cx->ks, 0); ke4(cx->ks, 1); ke4(cx->ks, 2); ke4(cx->ks, 3); ke4(cx->ks, 4); ke4(cx->ks, 5); ke4(cx->ks, 6); ke4(cx->ks, 7); ke4(cx->ks, 8); #else { uint32_t i; for(i = 0; i < 9; ++i) ke4(cx->ks, i); } #endif ke4(cx->ks, 9); cx->inf.l = 0; cx->inf.b[0] = 10 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_192) || defined( AES_VAR ) #define kef6(k,i) \ { k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \ k[6*(i)+ 7] = ss[1] ^= ss[0]; \ k[6*(i)+ 8] = ss[2] ^= ss[1]; \ k[6*(i)+ 9] = ss[3] ^= ss[2]; \ } #define ke6(k,i) \ { kef6(k,i); \ k[6*(i)+10] = ss[4] ^= ss[3]; \ k[6*(i)+11] = ss[5] ^= ss[4]; \ } AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1]) { uint32_t ss[6]; cx->ks[0] = ss[0] = word_in(key, 0); cx->ks[1] = ss[1] = word_in(key, 1); cx->ks[2] = ss[2] = word_in(key, 2); cx->ks[3] = ss[3] = word_in(key, 3); cx->ks[4] = ss[4] = word_in(key, 4); cx->ks[5] = ss[5] = word_in(key, 5); #ifdef ENC_KS_UNROLL ke6(cx->ks, 0); ke6(cx->ks, 1); ke6(cx->ks, 2); ke6(cx->ks, 3); ke6(cx->ks, 4); ke6(cx->ks, 5); ke6(cx->ks, 6); #else { uint32_t i; for(i = 0; i < 7; ++i) ke6(cx->ks, i); } #endif kef6(cx->ks, 7); cx->inf.l = 0; cx->inf.b[0] = 12 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_256) || defined( AES_VAR ) #define kef8(k,i) \ { k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \ k[8*(i)+ 9] = ss[1] ^= ss[0]; \ k[8*(i)+10] = ss[2] ^= ss[1]; \ k[8*(i)+11] = ss[3] ^= ss[2]; \ } #define ke8(k,i) \ { kef8(k,i); \ k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); \ k[8*(i)+13] = ss[5] ^= ss[4]; \ k[8*(i)+14] = ss[6] ^= ss[5]; \ k[8*(i)+15] = ss[7] ^= ss[6]; \ } AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1]) { uint32_t ss[8]; cx->ks[0] = ss[0] = word_in(key, 0); cx->ks[1] = ss[1] = word_in(key, 1); cx->ks[2] = ss[2] = word_in(key, 2); cx->ks[3] = ss[3] = word_in(key, 3); cx->ks[4] = ss[4] = word_in(key, 4); cx->ks[5] = ss[5] = word_in(key, 5); cx->ks[6] = ss[6] = word_in(key, 6); cx->ks[7] = ss[7] = word_in(key, 7); #ifdef ENC_KS_UNROLL ke8(cx->ks, 0); ke8(cx->ks, 1); ke8(cx->ks, 2); ke8(cx->ks, 3); ke8(cx->ks, 4); ke8(cx->ks, 5); #else { uint32_t i; for(i = 0; i < 6; ++i) ke8(cx->ks, i); } #endif kef8(cx->ks, 6); cx->inf.l = 0; cx->inf.b[0] = 14 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #endif #if (FUNCS_IN_C & DEC_KEYING_IN_C) /* this is used to store the decryption round keys */ /* in forward or reverse order */ #ifdef AES_REV_DKS #define v(n,i) ((n) - (i) + 2 * ((i) & 3)) #else #define v(n,i) (i) #endif #if DEC_ROUND == NO_TABLES #define ff(x) (x) #else #define ff(x) inv_mcol(x) #if defined( dec_imvars ) #define d_vars dec_imvars #endif #endif #if defined(AES_128) || defined( AES_VAR ) #define k4e(k,i) \ { k[v(40,(4*(i))+4)] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \ k[v(40,(4*(i))+5)] = ss[1] ^= ss[0]; \ k[v(40,(4*(i))+6)] = ss[2] ^= ss[1]; \ k[v(40,(4*(i))+7)] = ss[3] ^= ss[2]; \ } #if 1 #define kdf4(k,i) \ { ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; \ ss[1] = ss[1] ^ ss[3]; \ ss[2] = ss[2] ^ ss[3]; \ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \ ss[i % 4] ^= ss[4]; \ ss[4] ^= k[v(40,(4*(i)))]; k[v(40,(4*(i))+4)] = ff(ss[4]); \ ss[4] ^= k[v(40,(4*(i))+1)]; k[v(40,(4*(i))+5)] = ff(ss[4]); \ ss[4] ^= k[v(40,(4*(i))+2)]; k[v(40,(4*(i))+6)] = ff(ss[4]); \ ss[4] ^= k[v(40,(4*(i))+3)]; k[v(40,(4*(i))+7)] = ff(ss[4]); \ } #define kd4(k,i) \ { ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \ ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \ k[v(40,(4*(i))+4)] = ss[4] ^= k[v(40,(4*(i)))]; \ k[v(40,(4*(i))+5)] = ss[4] ^= k[v(40,(4*(i))+1)]; \ k[v(40,(4*(i))+6)] = ss[4] ^= k[v(40,(4*(i))+2)]; \ k[v(40,(4*(i))+7)] = ss[4] ^= k[v(40,(4*(i))+3)]; \ } #define kdl4(k,i) \ { ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; ss[i % 4] ^= ss[4]; \ k[v(40,(4*(i))+4)] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; \ k[v(40,(4*(i))+5)] = ss[1] ^ ss[3]; \ k[v(40,(4*(i))+6)] = ss[0]; \ k[v(40,(4*(i))+7)] = ss[1]; \ } #else #define kdf4(k,i) \ { ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ff(ss[0]); \ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ff(ss[1]); \ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ff(ss[2]); \ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ff(ss[3]); \ } #define kd4(k,i) \ { ss[4] = ls_box(ss[3],3) ^ t_use(r,c)[i]; \ ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[v(40,(4*(i))+ 4)] = ss[4] ^= k[v(40,(4*(i)))]; \ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[4] ^= k[v(40,(4*(i))+ 1)]; \ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[4] ^= k[v(40,(4*(i))+ 2)]; \ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[4] ^= k[v(40,(4*(i))+ 3)]; \ } #define kdl4(k,i) \ { ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ss[0]; \ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[1]; \ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[2]; \ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[3]; \ } #endif AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1]) { uint32_t ss[5]; #if defined( d_vars ) d_vars; #endif cx->ks[v(40,(0))] = ss[0] = word_in(key, 0); cx->ks[v(40,(1))] = ss[1] = word_in(key, 1); cx->ks[v(40,(2))] = ss[2] = word_in(key, 2); cx->ks[v(40,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL kdf4(cx->ks, 0); kd4(cx->ks, 1); kd4(cx->ks, 2); kd4(cx->ks, 3); kd4(cx->ks, 4); kd4(cx->ks, 5); kd4(cx->ks, 6); kd4(cx->ks, 7); kd4(cx->ks, 8); kdl4(cx->ks, 9); #else { uint32_t i; for(i = 0; i < 10; ++i) k4e(cx->ks, i); #if !(DEC_ROUND == NO_TABLES) for(i = N_COLS; i < 10 * N_COLS; ++i) cx->ks[i] = inv_mcol(cx->ks[i]); #endif } #endif cx->inf.l = 0; cx->inf.b[0] = 10 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_192) || defined( AES_VAR ) #define k6ef(k,i) \ { k[v(48,(6*(i))+ 6)] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \ k[v(48,(6*(i))+ 7)] = ss[1] ^= ss[0]; \ k[v(48,(6*(i))+ 8)] = ss[2] ^= ss[1]; \ k[v(48,(6*(i))+ 9)] = ss[3] ^= ss[2]; \ } #define k6e(k,i) \ { k6ef(k,i); \ k[v(48,(6*(i))+10)] = ss[4] ^= ss[3]; \ k[v(48,(6*(i))+11)] = ss[5] ^= ss[4]; \ } #define kdf6(k,i) \ { ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ff(ss[0]); \ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ff(ss[1]); \ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ff(ss[2]); \ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ff(ss[3]); \ ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ff(ss[4]); \ ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ff(ss[5]); \ } #define kd6(k,i) \ { ss[6] = ls_box(ss[5],3) ^ t_use(r,c)[i]; \ ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[v(48,(6*(i))+ 6)] = ss[6] ^= k[v(48,(6*(i)))]; \ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[6] ^= k[v(48,(6*(i))+ 1)]; \ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[6] ^= k[v(48,(6*(i))+ 2)]; \ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[6] ^= k[v(48,(6*(i))+ 3)]; \ ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ss[6] ^= k[v(48,(6*(i))+ 4)]; \ ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ss[6] ^= k[v(48,(6*(i))+ 5)]; \ } #define kdl6(k,i) \ { ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ss[0]; \ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[1]; \ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[2]; \ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[3]; \ } AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1]) { uint32_t ss[7]; #if defined( d_vars ) d_vars; #endif cx->ks[v(48,(0))] = ss[0] = word_in(key, 0); cx->ks[v(48,(1))] = ss[1] = word_in(key, 1); cx->ks[v(48,(2))] = ss[2] = word_in(key, 2); cx->ks[v(48,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4)); cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5)); kdf6(cx->ks, 0); kd6(cx->ks, 1); kd6(cx->ks, 2); kd6(cx->ks, 3); kd6(cx->ks, 4); kd6(cx->ks, 5); kd6(cx->ks, 6); kdl6(cx->ks, 7); #else cx->ks[v(48,(4))] = ss[4] = word_in(key, 4); cx->ks[v(48,(5))] = ss[5] = word_in(key, 5); { uint32_t i; for(i = 0; i < 7; ++i) k6e(cx->ks, i); k6ef(cx->ks, 7); #if !(DEC_ROUND == NO_TABLES) for(i = N_COLS; i < 12 * N_COLS; ++i) cx->ks[i] = inv_mcol(cx->ks[i]); #endif } #endif cx->inf.l = 0; cx->inf.b[0] = 12 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_256) || defined( AES_VAR ) #define k8ef(k,i) \ { k[v(56,(8*(i))+ 8)] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \ k[v(56,(8*(i))+ 9)] = ss[1] ^= ss[0]; \ k[v(56,(8*(i))+10)] = ss[2] ^= ss[1]; \ k[v(56,(8*(i))+11)] = ss[3] ^= ss[2]; \ } #define k8e(k,i) \ { k8ef(k,i); \ k[v(56,(8*(i))+12)] = ss[4] ^= ls_box(ss[3],0); \ k[v(56,(8*(i))+13)] = ss[5] ^= ss[4]; \ k[v(56,(8*(i))+14)] = ss[6] ^= ss[5]; \ k[v(56,(8*(i))+15)] = ss[7] ^= ss[6]; \ } #define kdf8(k,i) \ { ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ff(ss[0]); \ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ff(ss[1]); \ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ff(ss[2]); \ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ff(ss[3]); \ ss[4] ^= ls_box(ss[3],0); k[v(56,(8*(i))+12)] = ff(ss[4]); \ ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ff(ss[5]); \ ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ff(ss[6]); \ ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ff(ss[7]); \ } #define kd8(k,i) \ { ss[8] = ls_box(ss[7],3) ^ t_use(r,c)[i]; \ ss[0] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+ 8)] = ss[8] ^= k[v(56,(8*(i)))]; \ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[8] ^= k[v(56,(8*(i))+ 1)]; \ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[8] ^= k[v(56,(8*(i))+ 2)]; \ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[8] ^= k[v(56,(8*(i))+ 3)]; \ ss[8] = ls_box(ss[3],0); \ ss[4] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+12)] = ss[8] ^= k[v(56,(8*(i))+ 4)]; \ ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ss[8] ^= k[v(56,(8*(i))+ 5)]; \ ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ss[8] ^= k[v(56,(8*(i))+ 6)]; \ ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ss[8] ^= k[v(56,(8*(i))+ 7)]; \ } #define kdl8(k,i) \ { ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ss[0]; \ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[1]; \ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[2]; \ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[3]; \ } AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1]) { uint32_t ss[9]; #if defined( d_vars ) d_vars; #endif cx->ks[v(56,(0))] = ss[0] = word_in(key, 0); cx->ks[v(56,(1))] = ss[1] = word_in(key, 1); cx->ks[v(56,(2))] = ss[2] = word_in(key, 2); cx->ks[v(56,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL cx->ks[v(56,(4))] = ff(ss[4] = word_in(key, 4)); cx->ks[v(56,(5))] = ff(ss[5] = word_in(key, 5)); cx->ks[v(56,(6))] = ff(ss[6] = word_in(key, 6)); cx->ks[v(56,(7))] = ff(ss[7] = word_in(key, 7)); kdf8(cx->ks, 0); kd8(cx->ks, 1); kd8(cx->ks, 2); kd8(cx->ks, 3); kd8(cx->ks, 4); kd8(cx->ks, 5); kdl8(cx->ks, 6); #else cx->ks[v(56,(4))] = ss[4] = word_in(key, 4); cx->ks[v(56,(5))] = ss[5] = word_in(key, 5); cx->ks[v(56,(6))] = ss[6] = word_in(key, 6); cx->ks[v(56,(7))] = ss[7] = word_in(key, 7); { uint32_t i; for(i = 0; i < 6; ++i) k8e(cx->ks, i); k8ef(cx->ks, 6); #if !(DEC_ROUND == NO_TABLES) for(i = N_COLS; i < 14 * N_COLS; ++i) cx->ks[i] = inv_mcol(cx->ks[i]); #endif } #endif cx->inf.l = 0; cx->inf.b[0] = 14 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #endif #if defined( AES_VAR ) AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]) { switch(key_len) { case 16: case 128: return aes_encrypt_key128(key, cx); case 24: case 192: return aes_encrypt_key192(key, cx); case 32: case 256: return aes_encrypt_key256(key, cx); default: return EXIT_FAILURE; } } AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]) { switch(key_len) { case 16: case 128: return aes_decrypt_key128(key, cx); case 24: case 192: return aes_decrypt_key192(key, cx); case 32: case 256: return aes_decrypt_key256(key, cx); default: return EXIT_FAILURE; } } #endif #if defined(__cplusplus) } #endif MediaInfoLib/Source/ThirdParty/aes-gladman/aestab.c0000664000000000000000000003642112652076434021165 0ustar rootroot/* --------------------------------------------------------------------------- Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that: source code distributions include the above copyright notice, this list of conditions and the following disclaimer; binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation. This software is provided 'as is' with no explicit or implied warranties in respect of its operation, including, but not limited to, correctness and fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #define DO_TABLES #include "aes.h" #include "aesopt.h" #if defined(FIXED_TABLES) #define sb_data(w) {\ w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } #define isb_data(w) {\ w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\ w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\ w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\ w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\ w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\ w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\ w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\ w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\ w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\ w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\ w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\ w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\ w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\ w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\ w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\ w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\ w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\ w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\ w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\ w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\ w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\ w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\ w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\ w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\ w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\ w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\ w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\ w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\ w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\ w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\ w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\ w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d) } #define mm_data(w) {\ w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\ w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\ w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\ w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\ w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\ w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\ w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\ w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\ w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\ w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\ w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\ w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\ w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\ w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\ w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\ w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\ w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\ w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\ w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\ w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\ w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\ w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\ w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\ w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\ w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\ w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\ w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\ w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\ w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\ w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\ w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\ w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff) } #define rc_data(w) {\ w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\ w(0x1b), w(0x36) } #define h0(x) (x) #define w0(p) bytes2word(p, 0, 0, 0) #define w1(p) bytes2word(0, p, 0, 0) #define w2(p) bytes2word(0, 0, p, 0) #define w3(p) bytes2word(0, 0, 0, p) #define u0(p) bytes2word(f2(p), p, p, f3(p)) #define u1(p) bytes2word(f3(p), f2(p), p, p) #define u2(p) bytes2word(p, f3(p), f2(p), p) #define u3(p) bytes2word(p, p, f3(p), f2(p)) #define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p)) #define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p)) #define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p)) #define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p)) #endif #if defined(FIXED_TABLES) || !defined(FF_TABLES) #define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY)) #define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY)) #define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \ ^ (((x>>5) & 4) * WPOLY)) #define f3(x) (f2(x) ^ x) #define f9(x) (f8(x) ^ x) #define fb(x) (f8(x) ^ f2(x) ^ x) #define fd(x) (f8(x) ^ f4(x) ^ x) #define fe(x) (f8(x) ^ f4(x) ^ f2(x)) #else #define f2(x) ((x) ? pow[log[x] + 0x19] : 0) #define f3(x) ((x) ? pow[log[x] + 0x01] : 0) #define f9(x) ((x) ? pow[log[x] + 0xc7] : 0) #define fb(x) ((x) ? pow[log[x] + 0x68] : 0) #define fd(x) ((x) ? pow[log[x] + 0xee] : 0) #define fe(x) ((x) ? pow[log[x] + 0xdf] : 0) #endif #include "aestab.h" #if defined(__cplusplus) extern "C" { #endif #if defined(FIXED_TABLES) /* implemented in case of wrong call for fixed tables */ AES_RETURN aes_init(void) { return EXIT_SUCCESS; } #else /* Generate the tables for the dynamic table option */ #if defined(FF_TABLES) #define gf_inv(x) ((x) ? pow[ 255 - log[x]] : 0) #else /* It will generally be sensible to use tables to compute finite field multiplies and inverses but where memory is scarse this code might sometimes be better. But it only has effect during initialisation so its pretty unimportant in overall terms. */ /* return 2 ^ (n - 1) where n is the bit number of the highest bit set in x with x in the range 1 < x < 0x00000200. This form is used so that locals within fi can be bytes rather than words */ static uint8_t hibit(const uint32_t x) { uint8_t r = (uint8_t)((x >> 1) | (x >> 2)); r |= (r >> 2); r |= (r >> 4); return (r + 1) >> 1; } /* return the inverse of the finite field element x */ static uint8_t gf_inv(const uint8_t x) { uint8_t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0; if(x < 2) return x; for( ; ; ) { if(n1) while(n2 >= n1) /* divide polynomial p2 by p1 */ { n2 /= n1; /* shift smaller polynomial left */ p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */ v2 ^= v1 * n2; /* shift accumulated value and */ n2 = hibit(p2); /* add into result */ } else return v1; if(n2) /* repeat with values swapped */ while(n1 >= n2) { n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1); } else return v2; } } #endif /* The forward and inverse affine transformations used in the S-box */ uint8_t fwd_affine(const uint8_t x) { uint32_t w = x; w ^= (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4); return 0x63 ^ ((w ^ (w >> 8)) & 0xff); } uint8_t inv_affine(const uint8_t x) { uint32_t w = x; w = (w << 1) ^ (w << 3) ^ (w << 6); return 0x05 ^ ((w ^ (w >> 8)) & 0xff); } static int init = 0; AES_RETURN aes_init(void) { uint32_t i, w; #if defined(FF_TABLES) uint8_t pow[512], log[256]; if(init) return EXIT_SUCCESS; /* log and power tables for GF(2^8) finite field with WPOLY as modular polynomial - the simplest primitive root is 0x03, used here to generate the tables */ i = 0; w = 1; do { pow[i] = (uint8_t)w; pow[i + 255] = (uint8_t)w; log[w] = (uint8_t)i++; w ^= (w << 1) ^ (w & 0x80 ? WPOLY : 0); } while (w != 1); #else if(init) return EXIT_SUCCESS; #endif for(i = 0, w = 1; i < RC_LENGTH; ++i) { t_set(r,c)[i] = bytes2word(w, 0, 0, 0); w = f2(w); } for(i = 0; i < 256; ++i) { uint8_t b; b = fwd_affine(gf_inv((uint8_t)i)); w = bytes2word(f2(b), b, b, f3(b)); #if defined( SBX_SET ) t_set(s,box)[i] = b; #endif #if defined( FT1_SET ) /* tables for a normal encryption round */ t_set(f,n)[i] = w; #endif #if defined( FT4_SET ) t_set(f,n)[0][i] = w; t_set(f,n)[1][i] = upr(w,1); t_set(f,n)[2][i] = upr(w,2); t_set(f,n)[3][i] = upr(w,3); #endif w = bytes2word(b, 0, 0, 0); #if defined( FL1_SET ) /* tables for last encryption round (may also */ t_set(f,l)[i] = w; /* be used in the key schedule) */ #endif #if defined( FL4_SET ) t_set(f,l)[0][i] = w; t_set(f,l)[1][i] = upr(w,1); t_set(f,l)[2][i] = upr(w,2); t_set(f,l)[3][i] = upr(w,3); #endif #if defined( LS1_SET ) /* table for key schedule if t_set(f,l) above is*/ t_set(l,s)[i] = w; /* not of the required form */ #endif #if defined( LS4_SET ) t_set(l,s)[0][i] = w; t_set(l,s)[1][i] = upr(w,1); t_set(l,s)[2][i] = upr(w,2); t_set(l,s)[3][i] = upr(w,3); #endif b = gf_inv(inv_affine((uint8_t)i)); w = bytes2word(fe(b), f9(b), fd(b), fb(b)); #if defined( IM1_SET ) /* tables for the inverse mix column operation */ t_set(i,m)[b] = w; #endif #if defined( IM4_SET ) t_set(i,m)[0][b] = w; t_set(i,m)[1][b] = upr(w,1); t_set(i,m)[2][b] = upr(w,2); t_set(i,m)[3][b] = upr(w,3); #endif #if defined( ISB_SET ) t_set(i,box)[i] = b; #endif #if defined( IT1_SET ) /* tables for a normal decryption round */ t_set(i,n)[i] = w; #endif #if defined( IT4_SET ) t_set(i,n)[0][i] = w; t_set(i,n)[1][i] = upr(w,1); t_set(i,n)[2][i] = upr(w,2); t_set(i,n)[3][i] = upr(w,3); #endif w = bytes2word(b, 0, 0, 0); #if defined( IL1_SET ) /* tables for last decryption round */ t_set(i,l)[i] = w; #endif #if defined( IL4_SET ) t_set(i,l)[0][i] = w; t_set(i,l)[1][i] = upr(w,1); t_set(i,l)[2][i] = upr(w,2); t_set(i,l)[3][i] = upr(w,3); #endif } init = 1; return EXIT_SUCCESS; } #endif #if defined(__cplusplus) } #endif MediaInfoLib/Source/Install/0000775000000000000000000000000012652076434014717 5ustar rootrootMediaInfoLib/Source/Install/MediaInfo_DLL_Windows_x64.nsi0000664000000000000000000001330012652076434022170 0ustar rootroot; Request application privileges for Windows Vista RequestExecutionLevel admin ; Some defines !define PRODUCT_NAME "MediaInfo" !define PRODUCT_PUBLISHER "MediaArea.net" !define PRODUCT_VERSION "0.7.82" !define PRODUCT_VERSION4 "${PRODUCT_VERSION}.0" !define PRODUCT_WEB_SITE "http://MediaArea.net/MediaInfo" !define COMPANY_REGISTRY "Software\MediaArea.net" !define PRODUCT_REGISTRY "Software\MediaArea.net\MediaInfo.dll" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MediaInfo.dll" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}.dll" !define PRODUCT_UNINST_ROOT_KEY "HKLM" ; Compression SetCompressor /FINAL /SOLID lzma ; x64 stuff !include "x64.nsh" ; File size !include FileFunc.nsh !include WinVer.nsh ; Modern UI !include "MUI2.nsh" !define MUI_ABORTWARNING !define MUI_ICON "..\..\..\MediaInfo\Source\Resource\Image\MediaInfo.ico" ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Installer pages !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ; Language files !insertmacro MUI_LANGUAGE "Arabic" !insertmacro MUI_LANGUAGE "Albanian" !insertmacro MUI_LANGUAGE "Belarusian" !insertmacro MUI_LANGUAGE "Catalan" !insertmacro MUI_LANGUAGE "Croatian" !insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Dutch" !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "Farsi" !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "Greek" !insertmacro MUI_LANGUAGE "Korean" !insertmacro MUI_LANGUAGE "Hungarian" !insertmacro MUI_LANGUAGE "Italian" !insertmacro MUI_LANGUAGE "Japanese" !insertmacro MUI_LANGUAGE "Lithuanian" !insertmacro MUI_LANGUAGE "Polish" !insertmacro MUI_LANGUAGE "Portuguese" !insertmacro MUI_LANGUAGE "PortugueseBR" !insertmacro MUI_LANGUAGE "Romanian" !insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "Swedish" !insertmacro MUI_LANGUAGE "Thai" !insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "Turkish" !insertmacro MUI_RESERVEFILE_LANGDLL ; Info VIProductVersion "${PRODUCT_VERSION4}" VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}" VIAddVersionKey "ProductName" "${PRODUCT_NAME}" VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION4}" VIAddVersionKey "FileDescription" "All about your audio and video files" VIAddVersionKey "FileVersion" "${PRODUCT_VERSION4}" VIAddVersionKey "LegalCopyright" "${PRODUCT_PUBLISHER}" VIAddVersionKey "OriginalFilename" "${PRODUCT_NAME}_DLL_${PRODUCT_VERSION}_Windows_x64.exe" BrandingText " " ; Modern UI end Name "${PRODUCT_NAME}.dll ${PRODUCT_VERSION}" OutFile "..\..\Release\MediaInfo_DLL_${PRODUCT_VERSION}_Windows_x64.exe" InstallDir "$PROGRAMFILES64\MediaInfo.dll" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails nevershow ShowUnInstDetails nevershow Function .onInit ${If} ${RunningX64} SetRegView 64 ${Else} MessageBox MB_OK|MB_ICONSTOP 'You are trying to install the 64-bit version of ${PRODUCT_NAME} on 32-bit Windows.$\r$\nPlease download and use the 32-bit version instead.$\r$\nClick OK to quit Setup.' Quit ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd !include Library.nsh Section "SectionPrincipale" SEC01 SetOutPath "$INSTDIR" !insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "..\..\Project\MSVC2013\x64\Release\MediaInfo.dll" $SYSDIR\MediaInfo.dll $SYSDIR !insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "..\..\Project\MSVC2013\x64\Release\MediaInfo_InfoTip.dll" $INSTDIR\MediaInfo_InfoTip.dll $INSTDIR SectionEnd Section -Post WriteUninstaller "$INSTDIR\MediaInfo_uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\MediaInfo.dll" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\MediaInfo_uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\MediaInfo_InfoTip.dll" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" ; File size, taken from SumatraPDF installer ${If} ${AtLeastWin7} ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 IntFmt $0 "0x%08X" $0 ; Convert the decimal KB value in $0 to DWORD, put it right back into $0 WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0" ; Create/Write the reg key with the dword value ${EndIf} SectionEnd Section Uninstall UnRegDLL "$INSTDIR\MediaInfo_InfoTip.dll" Delete "$INSTDIR\MediaInfo_uninst.exe" !insertmacro UnInstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED $SYSDIR\MediaInfo.dll !insertmacro UnInstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED $INSTDIR\MediaInfo_InfoTip.dll RMDir "$INSTDIR" SetRegView 64 DeleteRegKey HKLM "${PRODUCT_REGISTRY}" DeleteRegKey /ifempty HKLM "${COMPANY_REGISTRY}" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose true SectionEndMediaInfoLib/Source/Install/MediaInfo_DLL_Windows_i386.nsi0000664000000000000000000001371112652076434022246 0ustar rootroot; Request application privileges for Windows Vista RequestExecutionLevel admin ; Some defines !define PRODUCT_NAME "MediaInfo" !define PRODUCT_PUBLISHER "MediaArea.net" !define PRODUCT_VERSION "0.7.82" !define PRODUCT_VERSION4 "${PRODUCT_VERSION}.0" !define PRODUCT_WEB_SITE "http://MediaArea.net/MediaInfo" !define COMPANY_REGISTRY "Software\MediaArea.net" !define PRODUCT_REGISTRY "Software\MediaArea.net\MediaInfo.dll" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MediaInfo.dll" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}.dll" !define PRODUCT_UNINST_ROOT_KEY "HKLM" ; Compression SetCompressor /FINAL /SOLID lzma ; x64 stuff !include "x64.nsh" ; File size !include FileFunc.nsh !include WinVer.nsh ; Modern UI !include "MUI2.nsh" !define MUI_ABORTWARNING !define MUI_ICON "..\..\..\MediaInfo\Source\Resource\Image\MediaInfo.ico" ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Installer pages !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ; Language files !insertmacro MUI_LANGUAGE "Arabic" !insertmacro MUI_LANGUAGE "Albanian" !insertmacro MUI_LANGUAGE "Belarusian" !insertmacro MUI_LANGUAGE "Catalan" !insertmacro MUI_LANGUAGE "Croatian" !insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Dutch" !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "Farsi" !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "Greek" !insertmacro MUI_LANGUAGE "Korean" !insertmacro MUI_LANGUAGE "Hungarian" !insertmacro MUI_LANGUAGE "Italian" !insertmacro MUI_LANGUAGE "Japanese" !insertmacro MUI_LANGUAGE "Lithuanian" !insertmacro MUI_LANGUAGE "Polish" !insertmacro MUI_LANGUAGE "Portuguese" !insertmacro MUI_LANGUAGE "PortugueseBR" !insertmacro MUI_LANGUAGE "Romanian" !insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "Swedish" !insertmacro MUI_LANGUAGE "Thai" !insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "Turkish" !insertmacro MUI_RESERVEFILE_LANGDLL ; Info VIProductVersion "${PRODUCT_VERSION4}" VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}" VIAddVersionKey "ProductName" "${PRODUCT_NAME}" VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION4}" VIAddVersionKey "FileDescription" "All about your audio and video files" VIAddVersionKey "FileVersion" "${PRODUCT_VERSION4}" VIAddVersionKey "LegalCopyright" "${PRODUCT_PUBLISHER}" VIAddVersionKey "OriginalFilename" "${PRODUCT_NAME}_DLL_${PRODUCT_VERSION}_Windows_i386.exe" BrandingText " " ; Modern UI end Name "${PRODUCT_NAME}.dll ${PRODUCT_VERSION}" OutFile "..\..\Release\MediaInfo_DLL_${PRODUCT_VERSION}_Windows_i386.exe" InstallDir "$PROGRAMFILES\MediaInfo.dll" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails nevershow ShowUnInstDetails nevershow Function .onInit ${If} ${RunningX64} MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 'You are trying to install the 32-bit version of ${PRODUCT_NAME} on 64-bit Windows.$\r$\nPlease download and use the 64-bit version instead.$\r$\nContinue with the installation of the 32-bit version?' IDYES noprob Quit noprob: ${Else} ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd !include Library.nsh Section "SectionPrincipale" SEC01 SetOutPath "$INSTDIR" !insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "..\..\Project\MSVC2013\Win32\Release\MediaInfo.dll" $SYSDIR\MediaInfo.dll $SYSDIR !insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "..\..\Project\MSVC2013\Win32\Release\MediaInfo_InfoTip.dll" $INSTDIR\MediaInfo_InfoTip.dll $INSTDIR SectionEnd Section -Post WriteUninstaller "$INSTDIR\MediaInfo_uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\MediaInfo.dll" ${If} ${RunningX64} DeleteRegValue HKLM "Software\MediaArea.net\MediaInfo" "DisplayName" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name) (32-bit)" ${Else} WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" ${EndIf} WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\MediaInfo_uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\MediaInfo_InfoTip.dll" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" ; File size, taken from SumatraPDF installer ${If} ${AtLeastWin7} ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 IntFmt $0 "0x%08X" $0 ; Convert the decimal KB value in $0 to DWORD, put it right back into $0 WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0" ; Create/Write the reg key with the dword value ${EndIf} SectionEnd Section Uninstall UnRegDLL "$INSTDIR\MediaInfo_InfoTip.dll" Delete "$INSTDIR\MediaInfo_uninst.exe" !insertmacro UnInstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED $SYSDIR\MediaInfo.dll !insertmacro UnInstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED $INSTDIR\MediaInfo_InfoTip.dll RMDir "$INSTDIR" DeleteRegKey HKLM "${PRODUCT_REGISTRY}" DeleteRegKey /ifempty HKLM "${COMPANY_REGISTRY}" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose true SectionEndMediaInfoLib/Source/RegressionTest/0000775000000000000000000000000012652076434016271 5ustar rootrootMediaInfoLib/Source/RegressionTest/RegressionTest_Md5.cpp0000664000000000000000000001152012652076434022461 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ // RegressionTest.cpp : Defines the entry point for the console application. // #include #include #include "tchar.h" #include "MediaInfoDLL/MediaInfoDLL.h" #include "ZenLib/ZtringListListF.h" #include "ZenLib/File.h" #include "ZenLib/Dir.h" extern "C" { #include "md5.h" } #include "RegressionTest/RegressionTest.h" using namespace MediaInfoDLL; using namespace ZenLib; using namespace std; void WriteMd5Info(const Ztring &FileName, MediaInfo &MI, const Ztring &DataBaseDirectory) { int8u* Buffer=new int8u[0x1000000]; File F; String MD5_FromMI=MI.Get(Stream_General, 0, __T("MD5")); String Format=MI.Get(Stream_General, 0, __T("Format")); Ztring MD5_FromFile; if (!MD5_FromMI.empty()) { F.Open(FileName); MD5Context Context; MD5Init(&Context); size_t Size; do { Size=F.Read(Buffer, 0x1000000); MD5Update(&Context, Buffer, Size); } while (Size==0x1000000); unsigned char Digest[16]; MD5Final(Digest, &Context); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+ 0)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+ 2)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+ 4)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+ 6)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+ 8)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+10)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+12)); MD5_FromFile+=Ztring().From_CC2(BigEndian2int16u(Digest+14)); MD5_FromFile.MakeLowerCase(); } bool EmptyNormal=false; if (MD5_FromMI.empty() && Format==__T("MXF") && MI.Get(Stream_General, 0, __T("Format_Settings")).find(__T("Open / "))!=string::npos) { Format+=__T(" ")+MI.Get(Stream_General, 0, __T("Format_Settings")); EmptyNormal=true; } if (MD5_FromMI.empty() && Format.empty()) { EmptyNormal=true; } if (MD5_FromMI.empty() || EmptyNormal) { F.Open(DataBaseDirectory+(EmptyNormal?__T("\\MD5.EmptyNormal.csv"):__T("\\MD5.________________Missing.csv")), File::Access_Write_Append); F.Write(FileName+__T(";")+MI.Get(Stream_General, 0, __T("Format"))+EOL); } else if (MD5_FromMI==MD5_FromFile) { F.Open(DataBaseDirectory+__T("\\MD5.Success.csv"), File::Access_Write_Append); F.Write(FileName+__T(";")+Format+__T(";")+MD5_FromMI+EOL); } else { F.Open(DataBaseDirectory+__T("\\MD5.________________Fail.csv"), File::Access_Write_Append); F.Write(FileName+__T(";")+MI.Get(Stream_General, 0, __T("Format"))+__T(";")+MD5_FromMI+__T(";")+MD5_FromFile+EOL); } delete[] Buffer; } void RegressionTest_Md5(Ztring Files, Ztring DataBaseDirectory, int32u Scenario) { cout<<" Analyzing"<Percentage) { cout<<" "< #include "tchar.h" #include "MediaInfoDLL/MediaInfoDLL.h" #include "ZenLib/ZtringListListF.h" #include "ZenLib/File.h" #include "ZenLib/FileName.h" #include "ZenLib/Dir.h" #include "RegressionTest/RegressionTest.h" #include "MediaInfo/MediaInfo_Events.h" #include "ctime" using namespace MediaInfoDLL; using namespace ZenLib; using namespace std; /***************************************************************************/ /* Events */ /***************************************************************************/ struct UserHandle_struct { Ztring Name; int64u Size; File Time_File; time_t Time_Start; Ztring Parser; UserHandle_struct() { Size=(int64u)-1; Time_Start=(time_t)-1; Time_Start=(time_t)-1; } }; void Basic_General_Start_0 (struct MediaInfo_Event_General_Start_0* Event, struct UserHandle_struct* UserHandle) { if (Event->FileName_Unicode) { UserHandle->Name=Event->FileName_Unicode; UserHandle->Time_File.Write(Event->FileName_Unicode+__T(';')); } UserHandle->Size=Event->Stream_Size; UserHandle->Time_Start=time(NULL); UserHandle->Parser.clear(); } void Basic_General_End_0 (struct MediaInfo_Event_General_End_0* Event, struct UserHandle_struct* UserHandle) { time_t Diff; if (UserHandle->Time_Start!=(time_t)-1) Diff=time(NULL)-UserHandle->Time_Start; else Diff=(time_t)-1; if (Diff!=(time_t)-1) UserHandle->Time_File.Write(__T(';')+Ztring::ToZtring(UserHandle->Size)+__T(';')+Ztring::ToZtring(Diff)+EOL); UserHandle->Time_Start=(time_t)-1; UserHandle->Parser.clear(); } void Basic_General_Parser_Selected_0 (struct MediaInfo_Event_General_Parser_Selected_0* Event, struct UserHandle_struct* UserHandle) { if (Event->Name) UserHandle->Parser.From_UTF8(Event->Name); else UserHandle->Parser.clear(); } /***************************************************************************/ /* The callback function */ /***************************************************************************/ #define CASE(_PARSER,_EVENT,_VERSION) \ case MediaInfo_Event_##_PARSER##_##_EVENT : if (EventVersion==_VERSION && Data_Size>=sizeof(struct MediaInfo_Event_##_PARSER##_##_EVENT##_##_VERSION)) _PARSER##_##_EVENT##_##_VERSION((struct MediaInfo_Event_##_PARSER##_##_EVENT##_##_VERSION*)Data_Content, UserHandle); break; void __stdcall Basic_Event_CallBackFunction(unsigned char* Data_Content, size_t Data_Size, void* UserHandle_Void) { /*Retrieving UserHandle*/ struct UserHandle_struct* UserHandle=(struct UserHandle_struct*)UserHandle_Void; struct MediaInfo_Event_Generic* Event_Generic=(struct MediaInfo_Event_Generic*) Data_Content; unsigned char ParserID; unsigned short EventID; unsigned char EventVersion; /*integrity tests*/ if (Data_Size<4) return; //There is a problem /*Retrieving EventID*/ ParserID =(unsigned char) ((Event_Generic->EventCode&0xFF000000)>>24); EventID =(unsigned short)((Event_Generic->EventCode&0x00FFFF00)>>8 ); EventVersion=(unsigned char) ( Event_Generic->EventCode&0x000000FF ); switch (ParserID) { case MediaInfo_Parser_None : switch (EventID) { case MediaInfo_Event_General_Start : if (EventVersion==0 && Data_Size>=sizeof(struct MediaInfo_Event_General_Start_0)) Basic_General_Start_0((struct MediaInfo_Event_General_Start_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_End : if (EventVersion==0 && Data_Size>=sizeof(struct MediaInfo_Event_General_End_0)) Basic_General_End_0((struct MediaInfo_Event_General_End_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_Parser_Selected : if (EventVersion==0 && Data_Size>=sizeof(struct MediaInfo_Event_General_Parser_Selected_0)) Basic_General_Parser_Selected_0((struct MediaInfo_Event_General_Parser_Selected_0*)Data_Content, UserHandle); break; default : ; } break; default : ; //ParserID is unknown } } /***************************************************************************/ /* The callback function */ /***************************************************************************/ void RegressionTest_Basic(Ztring Files, Ztring DataBaseDirectory, int32u Scenario) { /* //One per one ZtringList List=Dir::GetAllFileNames(Files); for (size_t Pos=0; PosOpen(List[Pos]); delete MIL; MediaInfoDLL_UnLoad(); File::Move(L"C:\\Temp\\Debug_MemoryLeak.txt", L"C:\\Temp\\"+ZenLib::FileName(List[Pos]).Name_Get()+L"."+ZenLib::FileName(List[Pos]).Extension_Get()+L"."+Ztring::ToZtring(Pos)+L".txt"); } */ /* Old ZtringListListF* Ref=new ZtringListListF[Stream_Max]; for (size_t StreamKind=0; StreamKind #include #include #include "tchar.h" #include "MediaInfoDLL/MediaInfoDLL.h" #include "MediaInfo/MediaInfo_Events.h" #include "ZenLib/ZtringListListF.h" #include "ZenLib/Dir.h" #include "ZenLib/File.h" #include "ZenLib/FileName.h" #include "RegressionTest/RegressionTest.h" using namespace MediaInfoDLL; using namespace ZenLib; using namespace std; const char* F_FileName; #define echoF(_format) Events_UserHandle_struct::perevent &PerEvent=UserHandle->PerEvent[Event->EventCode]; if (!PerEvent.F_MoreThanOnce) {fprintf(PerEvent.F, _format); PerEvent.F_MoreThanOnce=true; } fprintf(PerEvent.F, "\n"); #define echo0(_format) fprintf(PerEvent.F, _format) #define echo1(_format, Arg1) fprintf(PerEvent.F, _format, Arg1) #define echo2(_format, Arg1, Arg2) fprintf(PerEvent.F, _format, Arg1, Arg2) #define echo4(_format, Arg1, Arg2, Arg3, Arg4) fprintf(PerEvent.F, _format, Arg1, Arg2, Arg3, Arg4) struct Events_UserHandle_struct { FileName Name; Ztring Files; Ztring DataBaseDirectory; struct perevent { FILE* F; bool F_MoreThanOnce; bool Custom_MoreThanOnce; }; map PerEvent; int32u Scenario; bool Custom; bool ParseSpeed; bool NextPacket; bool DemuxContainerOnly; bool Seek; Events_UserHandle_struct() { Custom=false; ParseSpeed=false; NextPacket=false; DemuxContainerOnly=false; Seek=false; } void Clear() { for (map::iterator Item=PerEvent.begin(); Item!=PerEvent.end(); ++Item) fclose (Item->second.F); PerEvent.clear(); } }; void General_Start_0 (struct MediaInfo_Event_General_Start_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo starts\n"); echo1("Stream_Size=%i\n", Event->Stream_Size); } void General_End_0 (struct MediaInfo_Event_General_End_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo ends\n"); echo1("Stream_Bytes_Analyzed=%i\n", Event->Stream_Bytes_Analyzed); } void General_Parser_Selected_0 (struct MediaInfo_Event_General_Parser_Selected_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo has selected the parser\n"); echo1("Name=%s\n", Event->Name); } void General_Move_Request_0 (struct MediaInfo_Event_General_Move_Request_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo has requested to seek\n"); echo1("StreamOffset=%08x\n", Event->StreamOffset); } void General_Move_Done_0 (struct MediaInfo_Event_General_Move_Done_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo has seek\n"); echo1("StreamOffset=%08x\n", Event->StreamOffset); } void General_SubFile_Start_0 (struct MediaInfo_Event_General_SubFile_Start_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo is parsing a new file from the source file\n"); echo1("FileName_Relative=%s\n", Event->FileName_Relative); echo1("FileName_Absolute=%s\n", Event->FileName_Absolute); } void General_SubFile_End_0 (struct MediaInfo_Event_General_SubFile_End_0* Event, struct Events_UserHandle_struct* UserHandle) { echoF("MediaInfo has finished the parsing a new file from the source file\n"); } void Global_Demux_4(struct MediaInfo_Event_Global_Demux_4 *Event, struct Events_UserHandle_struct* UserHandle) { if (!UserHandle->DemuxContainerOnly) return; echoF("MediaInfo Demux\n"); echo1("StreamOffset=%08x,", Event->StreamOffset); echo1(" Frame_Number=%u\n", Event->FrameNumber); echo0("IDs="); for (size_t Pos=0; PosStreamIDs_Size; Pos++) switch (Event->StreamIDs_Width[Pos]) { case 2: echo1("%02x, ", Event->StreamIDs[Pos]); break; case 4: echo1("%04x, ", Event->StreamIDs[Pos]); break; case 8: echo1("%08x, ", Event->StreamIDs[Pos]); break; default: echo1("%08x, ", Event->StreamIDs[Pos]); break; } echo0("\n"); if (Event->PCR!=(int64u)-1) echo1("PCR=%s, ", Ztring().Duration_From_Milliseconds(Event->PCR/1000000).To_Local().c_str()); if (Event->PTS!=(int64u)-1) echo1("PTS=%s, ", Ztring().Duration_From_Milliseconds(Event->PTS/1000000).To_Local().c_str()); if (Event->DTS!=(int64u)-1) echo1("DTS=%s, ", Ztring().Duration_From_Milliseconds(Event->DTS/1000000).To_Local().c_str()); if (Event->DUR!=(int64u)-1) echo1("DUR=%s, ", Ztring().Duration_From_Milliseconds(Event->DUR/1000000).To_Local().c_str()); if (Event->PCR!=(int64u)-1 || Event->PTS!=(int64u)-1 || Event->DTS!=(int64u)-1 || Event->DUR!=(int64u)-1) echo0("\n"); echo1("Content_Type=%i,", Event->Content_Type); echo1(" Content_Size=%i,", Event->Content_Size); echo1(" Flags=%08x\n", Event->Flags); } void Video_SliceInfo_0(struct MediaInfo_Event_Video_SliceInfo_0 *Event, struct Events_UserHandle_struct* UserHandle) { if (!UserHandle->DemuxContainerOnly) return; echoF("MediaInfo Demux\n"); echo1("StreamOffset=%08x,", Event->StreamOffset); echo1(" FramePosition=%u,", Event->FrameNumber); echo1(" FieldPosition=%u,", Event->FieldPosition); echo1(" SlicePosition=%u,", Event->SlicePosition); echo0("IDs="); for (size_t Pos=0; PosStreamIDs_Size; Pos++) switch (Event->StreamIDs_Width[Pos]) { case 2: echo1("%02x, ", Event->StreamIDs[Pos]); break; case 4: echo1("%04x, ", Event->StreamIDs[Pos]); break; case 8: echo1("%08x, ", Event->StreamIDs[Pos]); break; default: echo1("%08x, ", Event->StreamIDs[Pos]); break; } echo0("\n"); if (Event->PCR!=(int64u)-1) echo1("PCR=%s, ", Ztring().Duration_From_Milliseconds(Event->PCR/1000000).To_Local().c_str()); if (Event->PTS!=(int64u)-1) echo1("PTS=%s, ", Ztring().Duration_From_Milliseconds(Event->PTS/1000000).To_Local().c_str()); if (Event->DTS!=(int64u)-1) echo1("DTS=%s, ", Ztring().Duration_From_Milliseconds(Event->DTS/1000000).To_Local().c_str()); if (Event->DUR!=(int64u)-1) echo1("DUR=%s, ", Ztring().Duration_From_Milliseconds(Event->DUR/1000000).To_Local().c_str()); if (Event->PCR!=(int64u)-1 || Event->PTS!=(int64u)-1 || Event->DTS!=(int64u)-1 || Event->DUR!=(int64u)-1) echo0("\n"); echo1("SliceType=%i,", Event->SliceType); echo1(" Flags=%08x\n", Event->Flags); } /***************************************************************************/ /* The callback function */ /***************************************************************************/ #define CASE(_PARSER,_EVENT,_VERSION) \ case MediaInfo_Event_##_PARSER##_##_EVENT : if (EventVersion==_VERSION && Data_Size>=sizeof(struct MediaInfo_Event_##_PARSER##_##_EVENT##_##_VERSION)) _PARSER##_##_EVENT##_##_VERSION((struct MediaInfo_Event_##_PARSER##_##_EVENT##_##_VERSION*)Data_Content, UserHandle); break; void __stdcall Event_CallBackFunction(unsigned char* Data_Content, size_t Data_Size, void* UserHandle_Void) { /*Retrieving UserHandle*/ struct Events_UserHandle_struct* UserHandle=(struct Events_UserHandle_struct*)UserHandle_Void; struct MediaInfo_Event_Generic* Event_Generic=(struct MediaInfo_Event_Generic*) Data_Content; unsigned char ParserID; unsigned short EventID; unsigned char EventVersion; /*integrity tests*/ if (Data_Size<4) return; //There is a problem if (UserHandle->PerEvent[Event_Generic->EventCode].F==NULL) { Ztring Number; Number.From_Number(Event_Generic->EventCode, 16); while (Number.size()<8) Number.insert(0, 1, __T('0')); Ztring Name=Ztring(UserHandle->DataBaseDirectory+__T("\\Events\\New\\")+Ztring::ToZtring(UserHandle->Scenario)+__T("\\")+Number+__T("\\")+UserHandle->Name.Name_Get()+__T(".txt")); if (!Dir::Exists(UserHandle->DataBaseDirectory+__T("\\Events\\New"))) Dir::Create(UserHandle->DataBaseDirectory+__T("\\Events\\New")); if (!Dir::Exists(UserHandle->DataBaseDirectory+__T("\\Events\\New\\")+Ztring::ToZtring(UserHandle->Scenario))) Dir::Create(UserHandle->DataBaseDirectory+__T("\\Events\\New\\")+Ztring::ToZtring(UserHandle->Scenario)); if (!Dir::Exists(UserHandle->DataBaseDirectory+__T("\\Events\\New\\")+Ztring::ToZtring(UserHandle->Scenario)+__T("\\")+Number)) Dir::Create(UserHandle->DataBaseDirectory+__T("\\Events\\New\\")+Ztring::ToZtring(UserHandle->Scenario)+__T("\\")+Number); if (!Dir::Exists(FileName(Name).Path_Get())) Dir::Create(FileName(Name).Path_Get()); UserHandle->PerEvent[Event_Generic->EventCode].F=fopen(Name.To_Local().c_str(), "w"); } /*Retrieving EventID*/ ParserID =(unsigned char) ((Event_Generic->EventCode&0xFF000000)>>24); EventID =(unsigned short)((Event_Generic->EventCode&0x00FFFF00)>>8 ); EventVersion=(unsigned char) ( Event_Generic->EventCode&0x000000FF ); //*Global to all parsers switch (EventID) { CASE (Global, Demux, 4) CASE (Video, SliceInfo, 0) default : ; } switch (ParserID) { case MediaInfo_Parser_None : switch (EventID) { case MediaInfo_Event_General_Start : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_Start_0)) General_Start_0((struct MediaInfo_Event_General_Start_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_End : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_End_0)) General_End_0((struct MediaInfo_Event_General_End_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_Parser_Selected : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_Parser_Selected_0)) General_Parser_Selected_0((struct MediaInfo_Event_General_Parser_Selected_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_Move_Request : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_Move_Request_0)) General_Move_Request_0((struct MediaInfo_Event_General_Move_Request_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_Move_Done : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_Move_Done_0)) General_Move_Done_0((struct MediaInfo_Event_General_Move_Done_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_SubFile_Start : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_SubFile_Start_0)) General_SubFile_Start_0((struct MediaInfo_Event_General_SubFile_Start_0*)Data_Content, UserHandle); break; case MediaInfo_Event_General_SubFile_End : if (EventVersion==0 && Data_Size==sizeof(struct MediaInfo_Event_General_SubFile_End_0)) General_SubFile_End_0((struct MediaInfo_Event_General_SubFile_End_0*)Data_Content, UserHandle); break; default : ; } break; default : ; //ParserID is unknown } } void RegressionTest_Events(Ztring Files, Ztring DataBaseDirectory, int32u Scenario) { // Scenarios: // bit 0 : quick parsing / full parsing // bit 1 : next packet interface // bit 2 : demux (by container only) // bit 3 : do some seeks cout<<" Analyzing"< FilesList; for (size_t FilesList_Source_Pos=0; FilesList_Source_Pos100000000) Size=100000000; int8u* F_Ref_Buffer=new int8u[(size_t)Size]; F_Ref.Read(F_Ref_Buffer, (size_t)Size); int8u* F_New_Buffer=new int8u[(size_t)Size]; F_New.Read(F_New_Buffer, (size_t)Size); if (memcmp(F_Ref_Buffer, F_New_Buffer, (size_t)Size)) IsDiff=true; delete[] F_Ref_Buffer; delete[] F_New_Buffer; } else IsDiff=true; } if (New_RefPos==(size_t)-1 || IsDiff) { //Not in new or is different Ztring Diff_Name=Ref[Ref_Pos]; Diff_Name.FindAndReplace(__T("\\Events\\Ref\\"), __T("\\Events\\Diff\\")); if (!Dir::Exists(DataBaseDirectory+__T("\\Events\\Diff"))) Dir::Create(DataBaseDirectory+__T("\\Events\\Diff")); if (!Dir::Exists(DataBaseDirectory+__T("\\Events\\Diff\\")+FileName(Files).Name_Get())) Dir::Create(DataBaseDirectory+__T("\\Events\\Diff\\")+FileName(Files).Name_Get()); if (!Dir::Exists(DataBaseDirectory+__T("\\Events\\Diff\\")+FileName(Files).Name_Get()+__T("\\")+Ztring::ToZtring(Scenario))) Dir::Create(DataBaseDirectory+__T("\\Events\\Diff\\")+FileName(Files).Name_Get()+__T("\\")+Ztring::ToZtring(Scenario)); if (!Dir::Exists(FileName(Diff_Name).Path_Get())) Dir::Create(FileName(Diff_Name).Path_Get()); if (!IsDiff) File::Copy(Ref[Ref_Pos], Diff_Name+__T(".RefAlone.txt")); //Not in new else { File::Copy(Ref[Ref_Pos], Diff_Name+__T(".Ref.txt")); //Diff File::Copy(New[New_RefPos], Diff_Name+__T(".New.txt")); } } if (New_RefPos!=(size_t)-1) New.erase(New.begin()+New_RefPos); } for (size_t New_Pos=0; New_Pos #include #include "ZenLib/Ztring.h" #include "RegressionTest/RegressionTest.h" using namespace std; using namespace ZenLib; int _tmain(int argc, _TCHAR* argv[]) { if (argc<4) return 1; Ztring Files=argv[1]; Ztring DataBaseDirectory=argv[2]; int32u Scenario=Ztring(argv[3]).To_int32u(); bool Flag_All=true, Flag_Basic=false, Flag_Events=false, Flag_Md5=false; for (int Pos=3; Pos
(redirecting)
MediaInfoLib/Source/Doc/Doxyfile0000664000000000000000000000745312652076434015535 0ustar rootroot# Doxyfile 1.5.4 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = MediaInfoLib PROJECT_NUMBER = 0.7 PROJECT_LOGO = OUTPUT_DIRECTORY = ./ OUTPUT_LANGUAGE = English REPEAT_BRIEF = YES ABBREVIATE_BRIEF = FULL_PATH_NAMES = NO BUILTIN_STL_SUPPORT = YES OPTIMIZE_OUTPUT_FOR_C = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = NO #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = YES WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = YES #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = ../MediaInfo/MediaInfo_Const.h \ ../MediaInfo/MediaInfoList.h \ ../MediaInfo/MediaInfo.h \ ../MediaInfoDLL/MediaInfoDLL.h #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = ../../Doc HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO MediaInfoLib/Source/Doc/setlocale.txt0000664000000000000000000000147012652076434016534 0ustar rootrootHowever, setlocale(LC_ALL, "") does the trick... only in a standalone app. When running as daemon LC_ALL is set by Suse to POSIX (Fedora and others do it as well) and any call to setlocale() from within the daemon code results either in NULL or complete garbage and changes nothing. The only way I could fix the locale problem is having extended the startup script for the mediatomb service by this part: . /etc/sysconfig/language locale_vars=" \ LANG \ LC_CTYPE \ LC_NUMERIC \ LC_TIME \ LC_COLLATE \ LC_MONETARY \ LC_MESSAGES \ LC_PAPER \ LC_NAME \ LC_ADDRESS \ LC_TELEPHONE \ LC_MEASUREMENT \ LC_IDENTIFICATION \ LC_ALL" unset LC_ALL for tmplc in $locale_vars do eval tmpval="\$RC_$tmplc" if test -n "$tmpval"; then eval $tmplc="\$RC_$tmplc" export $tmplc fi done unset tmplc tmpvalMediaInfoLib/Source/MediaInfoDLL/0000775000000000000000000000000012652076434015500 5ustar rootrootMediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.py0000664000000000000000000005216412652076434020251 0ustar rootroot## Copyright (c) MediaArea.net SARL. All Rights Reserved. # # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. ## # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # Public DLL interface implementation # Wrapper for MediaInfo Library # Please see MediaInfo.h for help # # Converted to python module by Petr Kaderabek # Modifications by Jerome Martinez # Python 3 update by Jerome Martinez # Mac OSX support, Python 2/3 merge and ctypes fixes by Miguel Grinberg # # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # MediaInfoDLL.py and MediaInfoDLL3.py are same # but all files are kept in order to not break programs calling them. # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import os import sys from ctypes import * if os.name == "nt" or os.name == "dos" or os.name == "os2" or os.name == "ce": MediaInfoDLL_Handler = windll.MediaInfo MustUseAnsi = 0 elif sys.platform == "darwin": MediaInfoDLL_Handler = CDLL("libmediainfo.0.dylib") MustUseAnsi = 1 else: MediaInfoDLL_Handler = CDLL("libmediainfo.so.0") MustUseAnsi = 1 # types --> C Python: # size_t c_size_t # unsigned char* c_char_p # enum c_size_t # const wchar_t* c_wchar_p, # NULL None, # these functions need strings in unicode format class Stream: General, Video, Audio, Text, Other, Image, Menu, Max = list(range(8)) class Info: Name, Text, Measure, Options, Name_Text, Measure_Text, Info, HowTo, Max = list(range(9)) class InfoOption: ShowInInform, Reserved, ShowInSupported, TypeOfValue, Max = list(range(5)) class FileOptions: Nothing, Recursive, CloseAll, xxNonexx_3, Max = list(range(5)) class MediaInfo: #MEDIAINFO_EXP void* __stdcall MediaInfo_New (); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ #/** @brief A 'new' MediaInfo interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ MediaInfo_New = MediaInfoDLL_Handler.MediaInfo_New MediaInfo_New.argtypes = [] MediaInfo_New.restype = c_void_p #MEDIAINFO_EXP void* __stdcall MediaInfo_New_Quick (const wchar_t* File, const wchar_t* Options); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ MediaInfo_New_Quick = MediaInfoDLL_Handler.MediaInfo_New_Quick MediaInfo_New_Quick.argtypes = [c_wchar_p, c_wchar_p] MediaInfo_New_Quick.restype = c_void_p MediaInfoA_New_Quick = MediaInfoDLL_Handler.MediaInfoA_New_Quick MediaInfoA_New_Quick.argtypes = [c_char_p, c_char_p] MediaInfoA_New_Quick.restype = c_void_p #/** @brief Delete a MediaInfo interface*/ #MEDIAINFO_EXP void __stdcall MediaInfo_Delete (void* Handle); MediaInfo_Delete = MediaInfoDLL_Handler.MediaInfo_Delete MediaInfo_Delete.argtypes = [c_void_p] MediaInfo_Delete.restype = None #/** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a filename)*/ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Open (void* Handle, const wchar_t* File); MediaInfo_Open = MediaInfoDLL_Handler.MediaInfo_Open MediaInfo_Open.argtypes = [c_void_p, c_wchar_p] MediaInfo_Open.restype = c_size_t MediaInfoA_Open = MediaInfoDLL_Handler.MediaInfoA_Open MediaInfoA_Open.argtypes = [c_void_p, c_char_p] MediaInfoA_Open.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer) */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ MediaInfo_Open_Buffer = MediaInfoDLL_Handler.MediaInfo_Open_Buffer MediaInfo_Open_Buffer.argtypes = [c_void_p, c_void_p, c_size_t, c_void_p, c_size_t] MediaInfo_Open_Buffer.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Save */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Save (void* Handle); MediaInfo_Save = MediaInfoDLL_Handler.MediaInfo_Save MediaInfo_Save.argtypes = [c_void_p] MediaInfo_Save.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Close */ #MEDIAINFO_EXP void __stdcall MediaInfo_Close (void* Handle); MediaInfo_Close = MediaInfoDLL_Handler.MediaInfo_Close MediaInfo_Close.argtypes = [c_void_p] MediaInfo_Close.restype = None #/** @brief Wrapper for MediaInfoLib::MediaInfo::Inform */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Inform (void* Handle, size_t Reserved); /*Default : Reserved=0*/ MediaInfo_Inform = MediaInfoDLL_Handler.MediaInfo_Inform MediaInfo_Inform.argtypes = [c_void_p, c_size_t] MediaInfo_Inform.restype = c_wchar_p MediaInfoA_Inform = MediaInfoDLL_Handler.MediaInfoA_Inform MediaInfoA_Inform.argtypes = [c_void_p, c_size_t] MediaInfoA_Inform.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_GetI (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ MediaInfo_GetI = MediaInfoDLL_Handler.MediaInfo_GetI MediaInfo_GetI.argtypes = [c_void_p, c_size_t, c_size_t, c_size_t, c_size_t] MediaInfo_GetI.restype = c_wchar_p MediaInfoA_GetI = MediaInfoDLL_Handler.MediaInfoA_GetI MediaInfoA_GetI.argtypes = [c_void_p, c_size_t, c_size_t, c_size_t, c_size_t] MediaInfoA_GetI.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ MediaInfo_Get = MediaInfoDLL_Handler.MediaInfo_Get MediaInfo_Get.argtypes = [c_void_p, c_size_t, c_size_t, c_wchar_p, c_size_t, c_size_t] MediaInfo_Get.restype = c_wchar_p MediaInfoA_Get = MediaInfoDLL_Handler.MediaInfoA_Get MediaInfoA_Get.argtypes = [c_void_p, c_size_t, c_size_t, c_wchar_p, c_size_t, c_size_t] MediaInfoA_Get.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_SetI (void* Handle, const wchar_t* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter); MediaInfo_SetI = MediaInfoDLL_Handler.MediaInfo_SetI MediaInfo_SetI.argtypes = [c_void_p, c_wchar_p, c_size_t, c_size_t, c_size_t, c_wchar_p] MediaInfo_SetI.restype = c_void_p MediaInfoA_SetI = MediaInfoDLL_Handler.MediaInfoA_SetI MediaInfoA_SetI.argtypes = [c_void_p, c_char_p, c_size_t, c_size_t, c_size_t, c_wchar_p] MediaInfoA_SetI.restype = c_void_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Set (void* Handle, const wchar_t* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter); MediaInfo_Set = MediaInfoDLL_Handler.MediaInfo_Set MediaInfo_Set.argtypes = [c_void_p, c_wchar_p, c_size_t, c_size_t, c_wchar_p, c_wchar_p] MediaInfo_Set.restype = c_size_t MediaInfoA_Set = MediaInfoDLL_Handler.MediaInfoA_Set MediaInfoA_Set.argtypes = [c_void_p, c_char_p, c_size_t, c_size_t, c_wchar_p, c_wchar_p] MediaInfoA_Set.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Option */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Option (void* Handle, const wchar_t* Option, const wchar_t* Value); MediaInfo_Option = MediaInfoDLL_Handler.MediaInfo_Option MediaInfo_Option.argtypes = [c_void_p, c_wchar_p, c_wchar_p] MediaInfo_Option.restype = c_wchar_p MediaInfoA_Option = MediaInfoDLL_Handler.MediaInfoA_Option MediaInfoA_Option.argtypes = [c_void_p, c_char_p, c_char_p] MediaInfoA_Option.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::State_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_State_Get (void* Handle); MediaInfo_State_Get = MediaInfoDLL_Handler.MediaInfo_State_Get MediaInfo_State_Get.argtypes = [c_void_p] MediaInfo_State_Get.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Count_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Count_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ MediaInfo_Count_Get = MediaInfoDLL_Handler.MediaInfo_Count_Get MediaInfo_Count_Get.argtypes = [c_void_p, c_size_t, c_size_t] MediaInfo_Count_Get.restype = c_size_t Handle = c_void_p(0) MustUseAnsi = 0 #Handling def __init__(self): self.Handle=self.MediaInfo_New() self.MediaInfo_Option(self.Handle, "CharSet", "UTF-8") def __del__(self): self.MediaInfo_Delete(self.Handle) def Open(self, File): if MustUseAnsi: return self.MediaInfoA_Open (self.Handle, File.encode("utf-8")); else: return self.MediaInfo_Open (self.Handle, File); def Open_Buffer(self, Begin, Begin_Size, End=None, End_Size=0): return self.MediaInfo_Open_Buffer(self.Handle, Begin, Begin_Size, End, End_Size) def Save(self): return self.MediaInfo_Save(self.Handle) def Close(self): return self.MediaInfo_Close(self.Handle) #General information def Inform(self): if MustUseAnsi: return self.MediaInfoA_Inform(self.Handle, 0).decode("utf_8", 'ignore') else: return self.MediaInfo_Inform(self.Handle, 0) def Get(self, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text, SearchKind=Info.Name): if MustUseAnsi: return self.MediaInfoA_Get(self.Handle, StreamKind, StreamNumber, Parameter.encode("utf-8"), InfoKind, SearchKind).decode("utf_8", 'ignore') else: return self.MediaInfo_Get(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind, SearchKind) def GetI(self, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text): if MustUseAnsi: return self.MediaInfoA_GetI(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind).decode("utf_8", 'ignore') else: return self.MediaInfo_GetI(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind) def Set(self, ToSet, StreamKind, StreamNumber, Parameter, OldParameter=""): if MustUseAnsi: return self.MediaInfoA_Set(self.Handle, ToSet, StreamKind, StreamNumber, Parameter.encode("utf-8"), OldParameter.encode("utf-8")) else: return self.MediaInfo_Set(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldParameter) def SetI(self, ToSet, StreamKind, StreamNumber, Parameter, OldValue): if MustUseAnsi: return self.MediaInfoA_SetI(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldValue.encode("utf-8")) else: return self.MediaInfo_SetI(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldValue) #Options def Option(self, Option, Value=""): if MustUseAnsi: return self.MediaInfoA_Option(self.Handle, Option.encode("utf-8"), Value.encode("utf-8")).decode("utf_8", 'ignore') else: return self.MediaInfo_Option(self.Handle, Option, Value) def Option_Static(self, Option, Value=""): if MustUseAnsi: return self.MediaInfoA_Option(None, Option.encode("utf-8"), Value.encode("utf-8")).decode("utf_8", 'ignore') else: return self.MediaInfo_Option(None, Option, Value) def State_Get(self): return self.MediaInfo_State_Get(self.Handle) def Count_Get(self, StreamKind, StreamNumber=-1): return self.MediaInfo_Count_Get(self.Handle, StreamKind, StreamNumber) class MediaInfoList: #/** @brief A 'new' MediaInfoList interface, return a Handle, don't forget to delete it after using it*/ #MEDIAINFO_EXP void* __stdcall MediaInfoList_New (); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ MediaInfoList_New = MediaInfoDLL_Handler.MediaInfoList_New MediaInfoList_New.argtypes = [] MediaInfoList_New.restype = c_void_p #/** @brief A 'new' MediaInfoList interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ #MEDIAINFO_EXP void* __stdcall MediaInfoList_New_Quick (const wchar_t* Files, const wchar_t* Config); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ MediaInfoList_New_Quick = MediaInfoDLL_Handler.MediaInfoList_New_Quick MediaInfoList_New_Quick.argtypes = [c_wchar_p, c_wchar_p] MediaInfoList_New_Quick.restype = c_void_p #/** @brief Delete a MediaInfoList interface*/ #MEDIAINFO_EXP void __stdcall MediaInfoList_Delete (void* Handle); MediaInfoList_Delete = MediaInfoDLL_Handler.MediaInfoList_Delete MediaInfoList_Delete.argtypes = [c_void_p] #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a filename)*/ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Open (void* Handle, const wchar_t* Files, const MediaInfo_fileoptions_C Options); /*Default : Options=MediaInfo_FileOption_Nothing*/ MediaInfoList_Open = MediaInfoDLL_Handler.MediaInfoList_Open MediaInfoList_Open.argtypes = [c_void_p, c_wchar_p, c_void_p] MediaInfoList_Open.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a buffer) */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ MediaInfoList_Open_Buffer = MediaInfoDLL_Handler.MediaInfoList_Open_Buffer MediaInfoList_Open_Buffer.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p] MediaInfoList_Open_Buffer.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Save */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Save (void* Handle, size_t FilePos); MediaInfoList_Save = MediaInfoDLL_Handler.MediaInfoList_Save MediaInfoList_Save.argtypes = [c_void_p, c_void_p] MediaInfoList_Save.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Close */ #MEDIAINFO_EXP void __stdcall MediaInfoList_Close (void* Handle, size_t FilePos); MediaInfoList_Close = MediaInfoDLL_Handler.MediaInfoList_Close MediaInfoList_Close.argtypes = [c_void_p, c_void_p] #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Inform */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Inform (void* Handle, size_t FilePos, size_t Reserved); /*Default : Reserved=0*/ MediaInfoList_Inform = MediaInfoDLL_Handler.MediaInfoList_Inform MediaInfoList_Inform.argtypes = [c_void_p, c_void_p, c_void_p] MediaInfoList_Inform.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_GetI (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ MediaInfoList_GetI = MediaInfoDLL_Handler.MediaInfoList_GetI MediaInfoList_GetI.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p] MediaInfoList_GetI.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ MediaInfoList_Get = MediaInfoDLL_Handler.MediaInfoList_Get MediaInfoList_Get.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_wchar_p, c_void_p, c_void_p] MediaInfoList_Get.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_SetI (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter); MediaInfoList_SetI = MediaInfoDLL_Handler.MediaInfoList_SetI MediaInfoList_SetI.argtypes = [c_void_p, c_wchar_p, c_void_p, c_void_p, c_void_p, c_void_p, c_wchar_p] MediaInfoList_SetI.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Set (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter); MediaInfoList_Set = MediaInfoDLL_Handler.MediaInfoList_Set MediaInfoList_Set.argtypes = [c_void_p, c_wchar_p, c_void_p, c_void_p, c_void_p, c_wchar_p, c_wchar_p] MediaInfoList_Set.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Option */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Option (void* Handle, const wchar_t* Option, const wchar_t* Value); MediaInfoList_Option = MediaInfoDLL_Handler.MediaInfoList_Option MediaInfoList_Option.argtypes = [c_void_p, c_wchar_p, c_wchar_p] MediaInfoList_Option.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::State_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_State_Get (void* Handle); MediaInfoList_State_Get = MediaInfoDLL_Handler.MediaInfoList_State_Get MediaInfoList_State_Get.argtypes = [c_void_p] MediaInfoList_State_Get.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Count_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ MediaInfoList_Count_Get = MediaInfoDLL_Handler.MediaInfoList_Count_Get MediaInfoList_Count_Get.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p] MediaInfoList_Count_Get.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Count_Get_Files (void* Handle); MediaInfoList_Count_Get_Files = MediaInfoDLL_Handler.MediaInfoList_Count_Get_Files MediaInfoList_Count_Get_Files.argtypes = [c_void_p] MediaInfoList_Count_Get_Files.restype = c_void_p Handle = c_void_p(0) #Handling def __init__(self): self.Handle=MediaInfoList_New() def __del__(self): MediaInfoList_Delete(self.Handle) def Open(self, Files, Options=FileOptions.Nothing): return MediaInfoList_Open(self.Handle, Files, Options) def Open_Buffer(self, Begin, Begin_Size, End=None, End_Size=0): return MediaInfoList_Open_Buffer (self.Handle, Begin, Begin_Size, End, End_Size) def Save(self, FilePos): return MediaInfoList_Save(self.Handle, FilePos) def Close(self, FilePos): MediaInfoList_Close (self.Handle, FilePos) #General information def Inform(self, FilePos, Reserved=0): return MediaInfoList_Inform (self.Handle, FilePos, Reserved) def GetI(self, FilePos, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text): return MediaInfoList_GetI (self.Handle, FilePos, StreamKind, StreamNumber, Parameter, InfoKind) def Get(self, FilePos, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text, SearchKind=Info.Name): return MediaInfoList_Get (self.Handle, FilePos, StreamKind, StreamNumber, (Parameter), InfoKind, SearchKind) def SetI(self, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter=""): return MediaInfoList_SetI (self, Handle, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter) def Set(self, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter=""): return MediaInfoList_Set (self.Handle, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter) #Options def Option(self, Option, Value=""): return MediaInfoList_Option (self.Handle, Option, Value) def Option_Static(self, Option, Value=""): return MediaInfoList_Option(None, Option, Value) def State_Get(self): return MediaInfoList_State_Get (self.Handle) def Count_Get(self, FilePos, StreamKind, StreamNumber): return MediaInfoList_Count_Get (self.Handle, FilePos, StreamKind, StreamNumber=-1) def Count_Get_Files(self): return MediaInfoList_Count_Get_Files (self.Handle) MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.def0000664000000000000000000000606712652076434020360 0ustar rootrootEXPORTS MediaInfo_New @26 MediaInfo_New_Quick @30 MediaInfo_Delete @27 MediaInfo_Open @14 MediaInfo_Open_Buffer @15 MediaInfo_Open_Buffer_Init @64 MediaInfo_Open_Buffer_Continue @65 MediaInfo_Open_Buffer_Continue_GoTo_Get @66 MediaInfo_Open_Buffer_Finalize @67 MediaInfo_Open_NextPacket @76 MediaInfo_Save @16 MediaInfo_Close @17 MediaInfo_Inform @18 MediaInfo_GetI @19 MediaInfo_Get @20 MediaInfo_SetI @21 MediaInfo_Set @22 MediaInfo_Output_Buffer_Get @72 MediaInfo_Output_Buffer_GetI @74 MediaInfo_Option @23 MediaInfo_State_Get @24 MediaInfo_Count_Get @25 MediaInfoA_New @28 MediaInfoA_New_Quick @31 MediaInfoA_Delete @29 MediaInfoA_Open @01 MediaInfoA_Open_Buffer @06 MediaInfoA_Open_Buffer_Init @68 MediaInfoA_Open_Buffer_Continue @69 MediaInfoA_Open_Buffer_Continue_GoTo_Get @70 MediaInfoA_Open_Buffer_Finalize @71 MediaInfoA_Open_NextPacket @77 MediaInfoA_Save @10 MediaInfoA_Close @02 MediaInfoA_Inform @03 MediaInfoA_GetI @04 MediaInfoA_Get @05 MediaInfoA_SetI @08 MediaInfoA_Set @09 MediaInfoA_Output_Buffer_Get @73 MediaInfoA_Output_Buffer_GetI @75 MediaInfoA_Option @11 MediaInfoA_State_Get @12 MediaInfoA_Count_Get @07 MediaInfo_Info_Version @13 MediaInfoList_New @32 MediaInfoList_New_Quick @33 MediaInfoList_Delete @34 MediaInfoList_Open @35 MediaInfoList_Open_Buffer @36 MediaInfoList_Save @37 MediaInfoList_Close @38 MediaInfoList_Inform @39 MediaInfoList_GetI @40 MediaInfoList_Get @41 MediaInfoList_SetI @42 MediaInfoList_Set @43 MediaInfoList_Option @44 MediaInfoList_State_Get @45 MediaInfoList_Count_Get @46 MediaInfoList_Count_Get_Files @62 MediaInfoListA_New @47 MediaInfoListA_New_Quick @48 MediaInfoListA_Delete @49 MediaInfoListA_Open @50 MediaInfoListA_Open_Buffer @51 MediaInfoListA_Save @52 MediaInfoListA_Close @53 MediaInfoListA_Inform @54 MediaInfoListA_GetI @55 MediaInfoListA_Get @56 MediaInfoListA_SetI @57 MediaInfoListA_Set @58 MediaInfoListA_Option @59 MediaInfoListA_State_Get @60 MediaInfoListA_Count_Get @61 MediaInfoListA_Count_Get_Files @63 ;Last item = 77 MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.jsl0000664000000000000000000001151612652076434020405 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Microsoft Visual J# wrapper for MediaInfo Library // See MediaInfo.h for help // // To make it working, you must put MediaInfo.Dll // in the executable folder // // Warning : not tested with J# 64-bit, will not work! // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import System.Runtime.InteropServices.*; import System.IntPtr; public enum StreamKind { General, Visual, Audio, Text, Other, Image, Menu, Max } public enum InfoKind { Name, Text, Measure, Options, NameText, MeasureText, Info, HowTo, Max } public enum InfoOptions { ShowInInform, Reserved, ShowInSupported, TypeOfValue, Max } public class MediaInfo { /**@attribute DllImport("MediaInfo.dll")*/ public static native IntPtr MediaInfo_New(); /**@attribute DllImport("MediaInfo.dll")*/ public static native void MediaInfo_Delete(IntPtr Handle); /**@attribute DllImport("MediaInfo.dll")*/ public static native int MediaInfo_Open(IntPtr Handle, /** @attribute MarshalAs(UnmanagedType.LPWStr)*/ String File); /**@attribute DllImport("MediaInfo.dll")*/ public static native void MediaInfo_Close(IntPtr Handle); /**@attribute DllImport("MediaInfo.dll")*/ public static native IntPtr MediaInfo_Inform(IntPtr Handle, int Options); //WARNING : This is a wchar* value /**@attribute DllImport("MediaInfo.dll")*/ public static native IntPtr MediaInfo_GetI(IntPtr Handle, StreamKind StreamKind, int StreamNumber, int Parameter, InfoKind KindOfInfo); //WARNING : This is a wchar* value, see MediaInfoDLL.h for enumeration values /**@attribute DllImport("MediaInfo.dll")*/ public static native IntPtr MediaInfo_Get(IntPtr Handle, StreamKind StreamKind, int StreamNumber, /** @attribute MarshalAs(UnmanagedType.LPWStr)*/ String Parameter, InfoKind KindOfInfo, InfoKind KindOfSearch); //WARNING : This is a wchar* value, see MediaInfoDLL.h for enumeration values /**@attribute DllImport("MediaInfo.dll")*/ public static native IntPtr MediaInfo_Option(IntPtr Handle, /** @attribute MarshalAs(UnmanagedType.LPWStr)*/ String Option, /** @attribute MarshalAs(UnmanagedType.LPWStr)*/ String Value); //WARNING : This is a wchar* value, see MediaInfoDLL.h for enumeration values /**@attribute DllImport("MediaInfo.dll")*/ public static native int MediaInfo_State_Get(IntPtr Handle); //see MediaInfoDLL.h for details /**@attribute DllImport("MediaInfo.dll")*/ public static native int MediaInfo_Count_Get(IntPtr Handle, StreamKind StreamKind, int StreamNumber); //see MediaInfoDLL.h for enumeration values //MediaInfo class public MediaInfo() { Handle = MediaInfo_New(); } void Dispose(boolean disposing) { MediaInfo_Delete(Handle); } public int Open(String FileName) { return MediaInfo_Open(Handle, FileName); } public void Close() { MediaInfo_Close(Handle); } public String Inform() { return Marshal.PtrToStringUni(MediaInfo_Inform(Handle, 0)); } public String Get(StreamKind StreamKind, int StreamNumber, String Parameter, InfoKind KindOfInfo, InfoKind KindOfSearch) { return Marshal.PtrToStringUni(MediaInfo_Get(Handle, StreamKind, StreamNumber, Parameter, KindOfInfo, KindOfSearch)); } public String Get(StreamKind StreamKind, int StreamNumber, int Parameter, InfoKind KindOfInfo) { return Marshal.PtrToStringUni(MediaInfo_GetI(Handle, StreamKind, StreamNumber, Parameter, KindOfInfo)); } public String Option(String Option, String Value) { return Marshal.PtrToStringUni(MediaInfo_Option(Handle, Option, Value)); } public int State_Get() { return MediaInfo_State_Get(Handle); } public int Count_Get(StreamKind StreamKind, int StreamNumber) { return MediaInfo_Count_Get(Handle, StreamKind, StreamNumber); } private IntPtr Handle; //Default values, if you know how to set default values in J#, say me public String Get(StreamKind StreamKind, int StreamNumber, String Parameter, InfoKind KindOfInfo) { return Get(StreamKind, StreamNumber, Parameter, KindOfInfo, InfoKind.Name); } public String Get(StreamKind StreamKind, int StreamNumber, String Parameter) { return Get(StreamKind, StreamNumber, Parameter, InfoKind.Text, InfoKind.Name); } public String Get(StreamKind StreamKind, int StreamNumber, int Parameter) { return Get(StreamKind, StreamNumber, Parameter, InfoKind.Text); } public String Option(String Option) { return Option(Option, ""); } public int Count_Get(StreamKind StreamKind) { return Count_Get(StreamKind, -1); } } MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.JNative.java0000664000000000000000000005772512652076434022111 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ import org.xvolks.jnative.JNative; import org.xvolks.jnative.Type; import org.xvolks.jnative.pointers.Pointer; import org.xvolks.jnative.pointers.memory.MemoryBlockFactory; import org.xvolks.jnative.exceptions.NativeException; import org.xvolks.jnative.pointers.memory.NativeMemoryBlock; /** * Class to retrieve info about media files. * MediaInfo library (http://MediaArea.net/MediaInfo) is used * by the help of JNative (http://jnative.sourceforge.net) * to obtain technical the info about the files. * * @author bro3@users.sourceforge.net * @author Info@MediaArea.net */ class MediaInfo { /* static_fields */ final public static int Stream_General = 0; final public static int Stream_Video = 1; final public static int Stream_Audio = 2; final public static int Stream_Text = 3; final public static int Stream_Other = 4; final public static int Stream_Image = 5; final public static int Stream_Menu = 6; final public static int Stream_Max = 7; final public static int Info_Name = 0; final public static int Info_Text = 1; final public static int Info_Measure = 2; final public static int Info_Options = 3; final public static int Info_Name_Text = 4; final public static int Info_Measure_Text = 5; final public static int Info_Info = 6; final public static int Info_HowTo = 7; final public static int Info_Max = 8; /* The MediaInfo handle */ private String handle = null; private JNative new_jnative; /* The library to be used */ private static String libraryName = ""; /** * Constructor that initializes the new MediaInfo object. * @throws NativeException JNative Exception. */ public MediaInfo() throws NativeException, Exception { setLibraryName(); New(); } /** * Constructor that initializes the new MediaInfo object. * @param libraryName name of libarary to be used * @throws NativeException JNative Exception */ public MediaInfo(String libraryName) throws NativeException, Exception { setLibraryName(libraryName); New(); } /** * Method New initializes the MediaInfo handle * @throws NativeException JNative Exception */ private void New() throws NativeException, Exception { /* Getting the handle */ new_jnative = new JNative(libraryName, "MediaInfoA_New"); new_jnative.setRetVal(Type.INT); new_jnative.invoke(); handle = new_jnative.getRetVal(); Option("CharSet", "UTF-8"); } /** * Opens a media file. * Overloads method {@link #Open(int, int, int, int)} * @param begin buffer with the beginning of datas * @param beginSize size of begin * @return 1 for success and 0 for failure * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Open(int, int, int, int) */ public int Open(int begin, int beginSize) throws HandleNotInitializedException, NativeException, Exception { return Open(begin, beginSize, 0, 0); } /** * Opens a media file. * @param begin buffer with the beginning of datas * @param beginSize size of begin * @param end buffer with the end of datas * @param endSize size of end * @return 1 for success and 0 for failure * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public int Open(int begin, int beginSize, int end, int endSize) throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Open_Buffer"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, Type.INT, String.valueOf(begin)); jnative.setParameter(2, Type.INT, String.valueOf(beginSize)); jnative.setParameter(3, Type.INT, String.valueOf(end)); jnative.setParameter(4, Type.INT, String.valueOf(endSize)); jnative.invoke(); /* Retrieving data */ int ret = Integer.parseInt(jnative.getRetVal()); return ret; } /** * Opens a media file. * @param filename the filename * @return 1 for success and 0 for failure * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public int Open(String filename) throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /* Setting the memory with the byte array returned in UTF-8 format */ Pointer fileNamePointer = createPointer(filename); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Open"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, fileNamePointer); jnative.invoke(); /* Retrieving data */ int ret = Integer.parseInt(jnative.getRetVal()); return ret; } /** * Gets the file info, (if available) according to the previous options set by {@link #Option(String, String)} * @return the file info * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public String Inform() throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Inform"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, Type.INT, "0"); //Necessary for backward compatibility jnative.invoke(); /* Retrieving data */ String ret = retrieveString(jnative); return ret; } /** * Gets the specific info according to the parameters. * Overloads method {@link #Get(int, int, String, int, int)}. * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @param streamNumber stream number to process * @param parameter parameter string (list of strings is available with Option("Info_Parameters"); * @return information * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Get(int, int, String, int, int) */ public String Get(int streamKind, int streamNumber, String parameter) throws HandleNotInitializedException, NativeException, Exception { return Get(streamKind, streamNumber, parameter, MediaInfo.Info_Name, MediaInfo.Info_Text); } /** * Gets the specific info according to the parameters. * Overloads method {@link #Get(int, int, String, int, int)} * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @param streamNumber stream to process * @param parameter parameter string (list of strings is available with Option("Info_Parameters"); * @param infoKind type of info. Can be any of the Info_XX values {@link Field details} * @return desired information * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Get(int, int, String, int, int) */ public String Get(int streamKind, int streamNumber, String parameter, int infoKind) throws HandleNotInitializedException, NativeException, Exception { return Get(streamKind, streamNumber, parameter, infoKind, MediaInfo.Info_Name); } /** * Gets the specific file info according to the parameters. * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @param streamNumber stream to process * @param parameter parameter string (list of strings is available with Option("Info_Parameters"); * @param infoKind type of info. Can be any of the Info_XX values {@link Field details} * @param searchKind type of search. Can be any of the Info_XX values {@link Field details} * @return desired information * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public String Get(int streamKind, int streamNumber, String parameter, int infoKind, int searchKind) throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /* Setting the memory with the byte array returned in UTF-8 format */ Pointer parameterPointer = createPointer(parameter); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Get"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, Type.INT, String.valueOf(streamKind)); jnative.setParameter(2, Type.INT, String.valueOf(streamNumber)); jnative.setParameter(3, parameterPointer); jnative.setParameter(4, Type.INT, String.valueOf(infoKind)); jnative.setParameter(5, Type.INT, String.valueOf(searchKind)); jnative.invoke(); /* Retrieving data */ String ret = retrieveString(jnative); return ret; } /** * Gets the specific file info according to the parameters. * Overloads method {@link #Get(int, int, int, int)}. * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @param streamNumber stream to process * @param parameter parameter position (count of parameters is available with Count_Get(streamKind, streamNumber) ) * @return desired information * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Get(int, int, int, int) */ public String Get(int streamKind, int streamNumber, int parameter) throws HandleNotInitializedException, NativeException, Exception { return Get(streamKind, streamNumber, parameter, MediaInfo.Info_Text); } /** * Gets the specific file info according to the parameters. * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @param streamNumber stream to process * @param parameter parameter position (count of parameters is available with Count_Get(streamKind, streamNumber) ) * @param infoKind type of info. Can be any of the Info_XX values {@link Field details} * @return desired information * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public String Get(int streamKind, int streamNumber, int parameter, int infoKind) throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_GetI"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, Type.INT, String.valueOf(streamKind)); jnative.setParameter(2, Type.INT, String.valueOf(streamNumber)); jnative.setParameter(3, Type.INT, String.valueOf(parameter)); jnative.setParameter(4, Type.INT, String.valueOf(infoKind)); jnative.invoke(); /* Retrieving data */ String ret = retrieveString(jnative); return ret; } /** * Sets the option * Overloads method {@link #Option(String, String)} * @param option name of option * @return desired information or status of the option * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Option(String, String) */ public String Option(String option) throws HandleNotInitializedException, NativeException, Exception { return Option(option, ""); } /** * Sets the option with value * @param option name of option * @param value option value * @return desired information or status of the option * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public String Option(String option, String value) throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /* Setting the memory with the byte array returned in UTF-8 format */ Pointer optionPointer = createPointer(option); Pointer valuePointer = createPointer(value); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Option"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, optionPointer); jnative.setParameter(2, valuePointer); jnative.invoke(); /* Retrieving data */ String ret = retrieveString(jnative); return ret; } /** * Sets the option (you do not need to create a MediaInfo handle) * Overloads method {@link #Option_Static(String, String)} * @param option name of option * @return desired information or status of the option * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Option_Static(String, String) */ static public String Option_Static(String option) throws HandleNotInitializedException, NativeException, Exception { return Option_Static(option, ""); } /** * Sets the option (you do not need to create a MediaInfo handle) * @param option name of option * @param value option value * @return desired information or status of the option * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ static public String Option_Static(String option, String value) throws HandleNotInitializedException, NativeException, Exception { if (libraryName.equals("")) setLibraryName(); /* Setting the memory with the byte array returned in UTF-8 format */ Pointer optionPointer = createPointer(option); Pointer valuePointer = createPointer(value); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Option"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, "0"); jnative.setParameter(1, optionPointer); jnative.setParameter(2, valuePointer); jnative.invoke(); /* Retrieving data */ String ret = retrieveString(jnative); return ret; } /** * Gets the state of the libaray * @return state of the library (between 0 and 10000) * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public int State_Get() throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_State_Get"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.invoke(); /* Retrieving data */ int ret = Integer.parseInt(jnative.getRetVal()); return ret; } /** * Gets the count of streams * Overloads method {@link #Count_Get(int, int)}. * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @return count of streams * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception * @see #Count_Get(int, int) */ public int Count_Get(int streamKind) throws HandleNotInitializedException, NativeException, Exception { return Count_Get(streamKind, -1); } /** * Gets the count of streams * @param streamKind type of stream. Can be any of the Stream_XX values {@link Field details} * @param streamNumber stream to process * @return count of parameters for a specific stream * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public int Count_Get(int streamKind, int streamNumber) throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Count_Get"); jnative.setRetVal(Type.INT); jnative.setParameter(0, Type.INT, handle); jnative.setParameter(1, Type.INT, String.valueOf(streamKind)); jnative.setParameter(2, Type.INT, String.valueOf(streamNumber)); jnative.invoke(); /* Retrieving data */ int retval = Integer.parseInt(jnative.getRetVal()); return retval; } /** * Deletes the handle * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ protected void finalize() throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Delete"); jnative.setParameter(0, Type.INT, handle); jnative.invoke(); } /** * Closes the handle * @throws HandleNotInitializedException if the handle is null * @throws NativeException JNative Exception */ public void Close() throws HandleNotInitializedException, NativeException, Exception { if (handle == null) throw new HandleNotInitializedException("Handle is not initialized."); /*JNative call */ JNative jnative = new JNative(libraryName, "MediaInfoA_Close"); jnative.setParameter(0, Type.INT, handle); jnative.invoke(); } /** * Create a memory pointer for giving it to an external library * @param value The string to give * @return A pointer to the memory */ static Pointer createPointer(String value) throws Exception { value+="\0"; byte[] array=value.getBytes("UTF-8"); Pointer valuePointer = new Pointer(MemoryBlockFactory.createMemoryBlock(array.length)); valuePointer.setMemory(array); return valuePointer; } /** * Create a string from a memory pointer * @param jnative The jnative handler * @return A string */ static String retrieveString(JNative jnative) throws Exception { int address = Integer.parseInt(jnative.getRetVal()); byte[] strEnd ={0}; int howFarToSearch =10000; int length =0; while (true) { int pos=JNative.searchNativePattern(address+length, strEnd, howFarToSearch); if (pos == -1) howFarToSearch+=10000; //The strEnd wasn't found else { length+=pos; break; } } if (length > 0) { Pointer retPointer = new Pointer(new NativeMemoryBlock(address, length)); String fileInfo = new String(retPointer.getMemory(), "UTF-8"); retPointer.dispose(); return fileInfo; } else return new String(); } /** * Sets the default name of the library to be used. * If windows -> "MediaInfo.dll" else -> "libmediainfo.so.0" */ public static void setLibraryName() { if (libraryName.equals("")) { String os=System.getProperty("os.name"); if (os!=null && os.toLowerCase().startsWith("windows")) setLibraryName("MediaInfo.dll"); else if (os!=null && os.toLowerCase().startsWith("mac")) setLibraryName("libmediainfo.dynlib.0"); else setLibraryName("libmediainfo.so.0"); } } /** * Sets the name of the library to be used. * @param libName name of the library */ public static void setLibraryName(String libName) { libraryName = libName; } } /** * Exception thrown if the handle isn't initialized. */ class HandleNotInitializedException extends Exception { private static final long serialVersionUID = 1L; HandleNotInitializedException(String msg) { super(msg); } } MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.pb0000664000000000000000000000547212652076434020222 0ustar rootroot;; Copyright (c) MediaArea.net SARL. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license that can ; be found in the License.html file in the root of the source tree. ;; ;*************************************************************************** ; Constants ;*************************************************************************** Enumeration #Stream_General #Stream_Video #Stream_Audio #Stream_Text #Stream_Other #Stream_Image #Stream_Menu #Stream_Max EndEnumeration Enumeration #Info_Name #Info_Text #Info_Measure #Info_Options #Info_NameText #Info_MeasureText #Info_Info #Info_HowTo #Info_Max EndEnumeration Enumeration #Option_ShowInInform #Option_Reserved #Option_ShowInSupported #Option_TypeOfValue #Option_Max EndEnumeration ;*************************************************************************** ; Prototyping MediaInfo calls ;*************************************************************************** Prototype protoMediaInfo_New() Prototype protoMediaInfo_Delete(Handle) Prototype protoMediaInfoA_Open(Handle, File.s) Prototype protoMediaInfoA_Count_Get(Handle, Streamkind.l, StreamNumber.l) Prototype protoMediaInfoA_Get(Handle, StreamKind.l, StreamNumber.l, Parameter.s, InfoKind.l, SearchKind.l) Prototype protoMediaInfoA_GetI(Handle, StreamKind.l, StreamNumber.l, Parameter.l, InfoKind.l) Prototype protoMediaInfoA_Inform(Handle, Reserved.l) Prototype protoMediaInfoA_Option(handle, Option.s, Value.s) Prototype protoMediaInfoA_close() MI_ptr = OpenLibrary(#PB_Any, "MediaInfo.dll") If MI_ptr = #False MessageRequester ("Warning", "MediaInfo.dll not open :("+ #CRLF$ + "Is it in the same folder as this app?") End EndIf Define MediaInfo_New.protoMediaInfo_New = GetFunction(MI_ptr, "MediaInfo_New") Define MediaInfo_Delete.protoMediaInfo_Delete = GetFunction(MI_ptr, "MediaInfo_Delete") Define MediainfoA_Open.protoMediaInfoA_Open = GetFunction(MI_ptr, "MediaInfoA_Open") Define MediainfoA_Count_Get.protoMediaInfoA_Count_Get = GetFunction(MI_ptr, "MediaInfoA_Count_Get") Define MediaInfoA_Get.protoMediaInfoA_Get = GetFunction(MI_ptr, "MediaInfoA_Get") Define MediaInfoA_GetI.protoMediaInfoA_GetI = GetFunction(MI_ptr, "MediaInfoA_GetI") Define MediaInfoA_Inform.protoMediaInfoA_Inform = GetFunction(MI_ptr, "MediaInfoA_Inform") Define MediaInfoA_Option.protoMediaInfoA_Option = GetFunction(MI_ptr, "MediaInfoA_Option") Define MediainfoA_close.protoMediaInfoA_Close = GetFunction(MI_ptr, "MediaInfoA_Close") ; IDE Options = PureBasic 4.20 (Windows - x86) ; CursorPosition = 85 ; FirstLine = 44 ; Folding = -MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL3.py0000664000000000000000000005216412652076434020334 0ustar rootroot## Copyright (c) MediaArea.net SARL. All Rights Reserved. # # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. ## # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # Public DLL interface implementation # Wrapper for MediaInfo Library # Please see MediaInfo.h for help # # Converted to python module by Petr Kaderabek # Modifications by Jerome Martinez # Python 3 update by Jerome Martinez # Mac OSX support, Python 2/3 merge and ctypes fixes by Miguel Grinberg # # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # MediaInfoDLL.py and MediaInfoDLL3.py are same # but all files are kept in order to not break programs calling them. # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import os import sys from ctypes import * if os.name == "nt" or os.name == "dos" or os.name == "os2" or os.name == "ce": MediaInfoDLL_Handler = windll.MediaInfo MustUseAnsi = 0 elif sys.platform == "darwin": MediaInfoDLL_Handler = CDLL("libmediainfo.0.dylib") MustUseAnsi = 1 else: MediaInfoDLL_Handler = CDLL("libmediainfo.so.0") MustUseAnsi = 1 # types --> C Python: # size_t c_size_t # unsigned char* c_char_p # enum c_size_t # const wchar_t* c_wchar_p, # NULL None, # these functions need strings in unicode format class Stream: General, Video, Audio, Text, Other, Image, Menu, Max = list(range(8)) class Info: Name, Text, Measure, Options, Name_Text, Measure_Text, Info, HowTo, Max = list(range(9)) class InfoOption: ShowInInform, Reserved, ShowInSupported, TypeOfValue, Max = list(range(5)) class FileOptions: Nothing, Recursive, CloseAll, xxNonexx_3, Max = list(range(5)) class MediaInfo: #MEDIAINFO_EXP void* __stdcall MediaInfo_New (); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ #/** @brief A 'new' MediaInfo interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ MediaInfo_New = MediaInfoDLL_Handler.MediaInfo_New MediaInfo_New.argtypes = [] MediaInfo_New.restype = c_void_p #MEDIAINFO_EXP void* __stdcall MediaInfo_New_Quick (const wchar_t* File, const wchar_t* Options); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ MediaInfo_New_Quick = MediaInfoDLL_Handler.MediaInfo_New_Quick MediaInfo_New_Quick.argtypes = [c_wchar_p, c_wchar_p] MediaInfo_New_Quick.restype = c_void_p MediaInfoA_New_Quick = MediaInfoDLL_Handler.MediaInfoA_New_Quick MediaInfoA_New_Quick.argtypes = [c_char_p, c_char_p] MediaInfoA_New_Quick.restype = c_void_p #/** @brief Delete a MediaInfo interface*/ #MEDIAINFO_EXP void __stdcall MediaInfo_Delete (void* Handle); MediaInfo_Delete = MediaInfoDLL_Handler.MediaInfo_Delete MediaInfo_Delete.argtypes = [c_void_p] MediaInfo_Delete.restype = None #/** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a filename)*/ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Open (void* Handle, const wchar_t* File); MediaInfo_Open = MediaInfoDLL_Handler.MediaInfo_Open MediaInfo_Open.argtypes = [c_void_p, c_wchar_p] MediaInfo_Open.restype = c_size_t MediaInfoA_Open = MediaInfoDLL_Handler.MediaInfoA_Open MediaInfoA_Open.argtypes = [c_void_p, c_char_p] MediaInfoA_Open.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer) */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ MediaInfo_Open_Buffer = MediaInfoDLL_Handler.MediaInfo_Open_Buffer MediaInfo_Open_Buffer.argtypes = [c_void_p, c_void_p, c_size_t, c_void_p, c_size_t] MediaInfo_Open_Buffer.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Save */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Save (void* Handle); MediaInfo_Save = MediaInfoDLL_Handler.MediaInfo_Save MediaInfo_Save.argtypes = [c_void_p] MediaInfo_Save.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Close */ #MEDIAINFO_EXP void __stdcall MediaInfo_Close (void* Handle); MediaInfo_Close = MediaInfoDLL_Handler.MediaInfo_Close MediaInfo_Close.argtypes = [c_void_p] MediaInfo_Close.restype = None #/** @brief Wrapper for MediaInfoLib::MediaInfo::Inform */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Inform (void* Handle, size_t Reserved); /*Default : Reserved=0*/ MediaInfo_Inform = MediaInfoDLL_Handler.MediaInfo_Inform MediaInfo_Inform.argtypes = [c_void_p, c_size_t] MediaInfo_Inform.restype = c_wchar_p MediaInfoA_Inform = MediaInfoDLL_Handler.MediaInfoA_Inform MediaInfoA_Inform.argtypes = [c_void_p, c_size_t] MediaInfoA_Inform.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_GetI (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ MediaInfo_GetI = MediaInfoDLL_Handler.MediaInfo_GetI MediaInfo_GetI.argtypes = [c_void_p, c_size_t, c_size_t, c_size_t, c_size_t] MediaInfo_GetI.restype = c_wchar_p MediaInfoA_GetI = MediaInfoDLL_Handler.MediaInfoA_GetI MediaInfoA_GetI.argtypes = [c_void_p, c_size_t, c_size_t, c_size_t, c_size_t] MediaInfoA_GetI.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ MediaInfo_Get = MediaInfoDLL_Handler.MediaInfo_Get MediaInfo_Get.argtypes = [c_void_p, c_size_t, c_size_t, c_wchar_p, c_size_t, c_size_t] MediaInfo_Get.restype = c_wchar_p MediaInfoA_Get = MediaInfoDLL_Handler.MediaInfoA_Get MediaInfoA_Get.argtypes = [c_void_p, c_size_t, c_size_t, c_wchar_p, c_size_t, c_size_t] MediaInfoA_Get.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_SetI (void* Handle, const wchar_t* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter); MediaInfo_SetI = MediaInfoDLL_Handler.MediaInfo_SetI MediaInfo_SetI.argtypes = [c_void_p, c_wchar_p, c_size_t, c_size_t, c_size_t, c_wchar_p] MediaInfo_SetI.restype = c_void_p MediaInfoA_SetI = MediaInfoDLL_Handler.MediaInfoA_SetI MediaInfoA_SetI.argtypes = [c_void_p, c_char_p, c_size_t, c_size_t, c_size_t, c_wchar_p] MediaInfoA_SetI.restype = c_void_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Set (void* Handle, const wchar_t* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter); MediaInfo_Set = MediaInfoDLL_Handler.MediaInfo_Set MediaInfo_Set.argtypes = [c_void_p, c_wchar_p, c_size_t, c_size_t, c_wchar_p, c_wchar_p] MediaInfo_Set.restype = c_size_t MediaInfoA_Set = MediaInfoDLL_Handler.MediaInfoA_Set MediaInfoA_Set.argtypes = [c_void_p, c_char_p, c_size_t, c_size_t, c_wchar_p, c_wchar_p] MediaInfoA_Set.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Option */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Option (void* Handle, const wchar_t* Option, const wchar_t* Value); MediaInfo_Option = MediaInfoDLL_Handler.MediaInfo_Option MediaInfo_Option.argtypes = [c_void_p, c_wchar_p, c_wchar_p] MediaInfo_Option.restype = c_wchar_p MediaInfoA_Option = MediaInfoDLL_Handler.MediaInfoA_Option MediaInfoA_Option.argtypes = [c_void_p, c_char_p, c_char_p] MediaInfoA_Option.restype = c_char_p #/** @brief Wrapper for MediaInfoLib::MediaInfo::State_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_State_Get (void* Handle); MediaInfo_State_Get = MediaInfoDLL_Handler.MediaInfo_State_Get MediaInfo_State_Get.argtypes = [c_void_p] MediaInfo_State_Get.restype = c_size_t #/** @brief Wrapper for MediaInfoLib::MediaInfo::Count_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfo_Count_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ MediaInfo_Count_Get = MediaInfoDLL_Handler.MediaInfo_Count_Get MediaInfo_Count_Get.argtypes = [c_void_p, c_size_t, c_size_t] MediaInfo_Count_Get.restype = c_size_t Handle = c_void_p(0) MustUseAnsi = 0 #Handling def __init__(self): self.Handle=self.MediaInfo_New() self.MediaInfo_Option(self.Handle, "CharSet", "UTF-8") def __del__(self): self.MediaInfo_Delete(self.Handle) def Open(self, File): if MustUseAnsi: return self.MediaInfoA_Open (self.Handle, File.encode("utf-8")); else: return self.MediaInfo_Open (self.Handle, File); def Open_Buffer(self, Begin, Begin_Size, End=None, End_Size=0): return self.MediaInfo_Open_Buffer(self.Handle, Begin, Begin_Size, End, End_Size) def Save(self): return self.MediaInfo_Save(self.Handle) def Close(self): return self.MediaInfo_Close(self.Handle) #General information def Inform(self): if MustUseAnsi: return self.MediaInfoA_Inform(self.Handle, 0).decode("utf_8", 'ignore') else: return self.MediaInfo_Inform(self.Handle, 0) def Get(self, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text, SearchKind=Info.Name): if MustUseAnsi: return self.MediaInfoA_Get(self.Handle, StreamKind, StreamNumber, Parameter.encode("utf-8"), InfoKind, SearchKind).decode("utf_8", 'ignore') else: return self.MediaInfo_Get(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind, SearchKind) def GetI(self, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text): if MustUseAnsi: return self.MediaInfoA_GetI(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind).decode("utf_8", 'ignore') else: return self.MediaInfo_GetI(self.Handle, StreamKind, StreamNumber, Parameter, InfoKind) def Set(self, ToSet, StreamKind, StreamNumber, Parameter, OldParameter=""): if MustUseAnsi: return self.MediaInfoA_Set(self.Handle, ToSet, StreamKind, StreamNumber, Parameter.encode("utf-8"), OldParameter.encode("utf-8")) else: return self.MediaInfo_Set(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldParameter) def SetI(self, ToSet, StreamKind, StreamNumber, Parameter, OldValue): if MustUseAnsi: return self.MediaInfoA_SetI(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldValue.encode("utf-8")) else: return self.MediaInfo_SetI(self.Handle, ToSet, StreamKind, StreamNumber, Parameter, OldValue) #Options def Option(self, Option, Value=""): if MustUseAnsi: return self.MediaInfoA_Option(self.Handle, Option.encode("utf-8"), Value.encode("utf-8")).decode("utf_8", 'ignore') else: return self.MediaInfo_Option(self.Handle, Option, Value) def Option_Static(self, Option, Value=""): if MustUseAnsi: return self.MediaInfoA_Option(None, Option.encode("utf-8"), Value.encode("utf-8")).decode("utf_8", 'ignore') else: return self.MediaInfo_Option(None, Option, Value) def State_Get(self): return self.MediaInfo_State_Get(self.Handle) def Count_Get(self, StreamKind, StreamNumber=-1): return self.MediaInfo_Count_Get(self.Handle, StreamKind, StreamNumber) class MediaInfoList: #/** @brief A 'new' MediaInfoList interface, return a Handle, don't forget to delete it after using it*/ #MEDIAINFO_EXP void* __stdcall MediaInfoList_New (); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ MediaInfoList_New = MediaInfoDLL_Handler.MediaInfoList_New MediaInfoList_New.argtypes = [] MediaInfoList_New.restype = c_void_p #/** @brief A 'new' MediaInfoList interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ #MEDIAINFO_EXP void* __stdcall MediaInfoList_New_Quick (const wchar_t* Files, const wchar_t* Config); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ MediaInfoList_New_Quick = MediaInfoDLL_Handler.MediaInfoList_New_Quick MediaInfoList_New_Quick.argtypes = [c_wchar_p, c_wchar_p] MediaInfoList_New_Quick.restype = c_void_p #/** @brief Delete a MediaInfoList interface*/ #MEDIAINFO_EXP void __stdcall MediaInfoList_Delete (void* Handle); MediaInfoList_Delete = MediaInfoDLL_Handler.MediaInfoList_Delete MediaInfoList_Delete.argtypes = [c_void_p] #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a filename)*/ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Open (void* Handle, const wchar_t* Files, const MediaInfo_fileoptions_C Options); /*Default : Options=MediaInfo_FileOption_Nothing*/ MediaInfoList_Open = MediaInfoDLL_Handler.MediaInfoList_Open MediaInfoList_Open.argtypes = [c_void_p, c_wchar_p, c_void_p] MediaInfoList_Open.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a buffer) */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ MediaInfoList_Open_Buffer = MediaInfoDLL_Handler.MediaInfoList_Open_Buffer MediaInfoList_Open_Buffer.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p] MediaInfoList_Open_Buffer.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Save */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Save (void* Handle, size_t FilePos); MediaInfoList_Save = MediaInfoDLL_Handler.MediaInfoList_Save MediaInfoList_Save.argtypes = [c_void_p, c_void_p] MediaInfoList_Save.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Close */ #MEDIAINFO_EXP void __stdcall MediaInfoList_Close (void* Handle, size_t FilePos); MediaInfoList_Close = MediaInfoDLL_Handler.MediaInfoList_Close MediaInfoList_Close.argtypes = [c_void_p, c_void_p] #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Inform */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Inform (void* Handle, size_t FilePos, size_t Reserved); /*Default : Reserved=0*/ MediaInfoList_Inform = MediaInfoDLL_Handler.MediaInfoList_Inform MediaInfoList_Inform.argtypes = [c_void_p, c_void_p, c_void_p] MediaInfoList_Inform.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_GetI (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ MediaInfoList_GetI = MediaInfoDLL_Handler.MediaInfoList_GetI MediaInfoList_GetI.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p] MediaInfoList_GetI.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ MediaInfoList_Get = MediaInfoDLL_Handler.MediaInfoList_Get MediaInfoList_Get.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_wchar_p, c_void_p, c_void_p] MediaInfoList_Get.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_SetI (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter); MediaInfoList_SetI = MediaInfoDLL_Handler.MediaInfoList_SetI MediaInfoList_SetI.argtypes = [c_void_p, c_wchar_p, c_void_p, c_void_p, c_void_p, c_void_p, c_wchar_p] MediaInfoList_SetI.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Set (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter); MediaInfoList_Set = MediaInfoDLL_Handler.MediaInfoList_Set MediaInfoList_Set.argtypes = [c_void_p, c_wchar_p, c_void_p, c_void_p, c_void_p, c_wchar_p, c_wchar_p] MediaInfoList_Set.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Option */ #MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Option (void* Handle, const wchar_t* Option, const wchar_t* Value); MediaInfoList_Option = MediaInfoDLL_Handler.MediaInfoList_Option MediaInfoList_Option.argtypes = [c_void_p, c_wchar_p, c_wchar_p] MediaInfoList_Option.restype = c_wchar_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::State_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_State_Get (void* Handle); MediaInfoList_State_Get = MediaInfoDLL_Handler.MediaInfoList_State_Get MediaInfoList_State_Get.argtypes = [c_void_p] MediaInfoList_State_Get.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Count_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ MediaInfoList_Count_Get = MediaInfoDLL_Handler.MediaInfoList_Count_Get MediaInfoList_Count_Get.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p] MediaInfoList_Count_Get.restype = c_void_p #/** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ #MEDIAINFO_EXP size_t __stdcall MediaInfoList_Count_Get_Files (void* Handle); MediaInfoList_Count_Get_Files = MediaInfoDLL_Handler.MediaInfoList_Count_Get_Files MediaInfoList_Count_Get_Files.argtypes = [c_void_p] MediaInfoList_Count_Get_Files.restype = c_void_p Handle = c_void_p(0) #Handling def __init__(self): self.Handle=MediaInfoList_New() def __del__(self): MediaInfoList_Delete(self.Handle) def Open(self, Files, Options=FileOptions.Nothing): return MediaInfoList_Open(self.Handle, Files, Options) def Open_Buffer(self, Begin, Begin_Size, End=None, End_Size=0): return MediaInfoList_Open_Buffer (self.Handle, Begin, Begin_Size, End, End_Size) def Save(self, FilePos): return MediaInfoList_Save(self.Handle, FilePos) def Close(self, FilePos): MediaInfoList_Close (self.Handle, FilePos) #General information def Inform(self, FilePos, Reserved=0): return MediaInfoList_Inform (self.Handle, FilePos, Reserved) def GetI(self, FilePos, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text): return MediaInfoList_GetI (self.Handle, FilePos, StreamKind, StreamNumber, Parameter, InfoKind) def Get(self, FilePos, StreamKind, StreamNumber, Parameter, InfoKind=Info.Text, SearchKind=Info.Name): return MediaInfoList_Get (self.Handle, FilePos, StreamKind, StreamNumber, (Parameter), InfoKind, SearchKind) def SetI(self, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter=""): return MediaInfoList_SetI (self, Handle, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter) def Set(self, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter=""): return MediaInfoList_Set (self.Handle, ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldParameter) #Options def Option(self, Option, Value=""): return MediaInfoList_Option (self.Handle, Option, Value) def Option_Static(self, Option, Value=""): return MediaInfoList_Option(None, Option, Value) def State_Get(self): return MediaInfoList_State_Get (self.Handle) def Count_Get(self, FilePos, StreamKind, StreamNumber): return MediaInfoList_Count_Get (self.Handle, FilePos, StreamKind, StreamNumber=-1) def Count_Get_Files(self): return MediaInfoList_Count_Get_Files (self.Handle) MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.h0000664000000000000000000007160212652076434020046 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Public DLL interface implementation // Wrapper for MediaInfo Library // See MediaInfo.h for help // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #ifndef MediaInfoDLLH #define MediaInfoDLLH //*************************************************************************** // 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 /*-------------------------------------------------------------------------*/ #if defined(_WIN32) || defined(WIN32) #ifdef _UNICODE #define MEDIAINFODLL_NAME L"MediaInfo.dll" #else //_UNICODE #define MEDIAINFODLL_NAME "MediaInfo.dll" #endif //_UNICODE #elif defined(__APPLE__) && defined(__MACH__) #define MEDIAINFODLL_NAME "libmediainfo.0.dylib" #define __stdcall #ifdef __cplusplus #include //for size_t #else /* __cplusplus */ #include //for size_t #endif /* __cplusplus */ #else #define MEDIAINFODLL_NAME "libmediainfo.so.0" #define __stdcall #endif //!defined(_WIN32) || defined(WIN32) /*-------------------------------------------------------------------------*/ /*Char types */ #undef __T #define __T(__x) __T(__x) #if defined(UNICODE) || defined(_UNICODE) typedef wchar_t MediaInfo_Char; #undef __T #define __T(__x) L ## __x #define MEDIAINFO_Ansi "" #else typedef char MediaInfo_Char; #undef __T #define __T(__x) __x #define MEDIAINFO_Ansi "A" #endif /*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /*8-bit int */ typedef unsigned char MediaInfo_int8u; /*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /*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; #elif defined(__WIN32__) || defined(_WIN32) #undef MAXTYPE_INT #define MAXTYPE_INT 64 typedef unsigned __int64 MediaInfo_int64u; #else #pragma message This machine has no 64-bit integer type? #endif /*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /*NULL */ #ifndef NULL #define NULL 0 #endif /*-------------------------------------------------------------------------*/ /** @brief Kinds of Stream */ typedef enum MediaInfo_stream_t { MediaInfo_Stream_General, MediaInfo_Stream_Video, MediaInfo_Stream_Audio, MediaInfo_Stream_Text, MediaInfo_Stream_Other, MediaInfo_Stream_Image, MediaInfo_Stream_Menu, MediaInfo_Stream_Max } MediaInfo_stream_C; /** @brief Kinds of Info */ typedef enum MediaInfo_info_t { MediaInfo_Info_Name, MediaInfo_Info_Text, MediaInfo_Info_Measure, MediaInfo_Info_Options, MediaInfo_Info_Name_Text, MediaInfo_Info_Measure_Text, MediaInfo_Info_Info, MediaInfo_Info_HowTo, MediaInfo_Info_Max } MediaInfo_info_C; /** @brief Option if InfoKind = Info_Options */ typedef enum MediaInfo_infooptions_t { MediaInfo_InfoOption_ShowInInform, MediaInfo_InfoOption_Reserved, MediaInfo_InfoOption_ShowInSupported, MediaInfo_InfoOption_TypeOfValue, MediaInfo_InfoOption_Max } MediaInfo_infooptions_C; /** @brief File opening options */ typedef enum MediaInfo_fileoptions_t { MediaInfo_FileOption_Nothing = 0x00, MediaInfo_FileOption_NoRecursive = 0x01, MediaInfo_FileOption_CloseAll = 0x02, MediaInfo_FileOption_Max = 0x04 } MediaInfo_fileoptions_C; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #ifdef MEDIAINFO_GLIBC #include static GModule* MediaInfo_Module = NULL; #elif defined(_WIN32) || defined(WIN32) #include static HMODULE MediaInfo_Module = NULL; #else #ifdef MACOSX #include #endif #include static void* MediaInfo_Module = NULL; #endif static size_t Module_Count = 0; #ifdef MEDIAINFO_GLIBC #define MEDIAINFO_ASSIGN(_Name,_Name2) \ if (!g_module_symbol (MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfo_##_Name)) \ Errors++; #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \ if (!g_module_symbol (MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfoList_##_Name)) \ Errors++; #elif defined(_WIN32) || defined(WIN32) #define MEDIAINFO_ASSIGN(_Name,_Name2) \ MediaInfo_##_Name=(MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \ if (MediaInfo_##_Name==NULL) Errors++; #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \ MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \ if (MediaInfoList_##_Name==NULL) Errors++; #else #define MEDIAINFO_ASSIGN(_Name,_Name2) \ MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \ if (MediaInfo_##_Name==NULL) Errors++; #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \ MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \ if (MediaInfoList_##_Name==NULL) Errors++; #endif typedef void* (__stdcall *MEDIAINFO_New)(); static MEDIAINFO_New MediaInfo_New; typedef void* (__stdcall *MEDIAINFOLIST_New)(); static MEDIAINFOLIST_New MediaInfoList_New; typedef void (__stdcall *MEDIAINFO_Delete)(void*); static MEDIAINFO_Delete MediaInfo_Delete; typedef void (__stdcall *MEDIAINFOLIST_Delete)(void*); static MEDIAINFOLIST_Delete MediaInfoList_Delete; typedef size_t (__stdcall *MEDIAINFO_Open)(void*, const MediaInfo_Char*); static MEDIAINFO_Open MediaInfo_Open; typedef size_t (__stdcall *MEDIAINFOLIST_Open)(void*, const MediaInfo_Char*, const MediaInfo_fileoptions_C); static MEDIAINFOLIST_Open MediaInfoList_Open; typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Init)(void*, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset); static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init; typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Continue)(void*, MediaInfo_int8u* Buffer, size_t Buffer_Size); static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue; typedef MediaInfo_int64u(__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void*); static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get; typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Finalize)(void*); static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize; typedef size_t (__stdcall *MEDIAINFO_Open_NextPacket)(void*); static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket; typedef void (__stdcall *MEDIAINFO_Close)(void*); static MEDIAINFO_Close MediaInfo_Close; typedef void (__stdcall *MEDIAINFOLIST_Close)(void*, size_t); static MEDIAINFOLIST_Close MediaInfoList_Close; typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Inform)(void*, size_t Reserved); static MEDIAINFO_Inform MediaInfo_Inform; typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Inform)(void*, size_t, size_t Reserved); static MEDIAINFOLIST_Inform MediaInfoList_Inform; typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_GetI)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo); static MEDIAINFO_GetI MediaInfo_GetI; typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_GetI)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo); static MEDIAINFOLIST_GetI MediaInfoList_GetI; typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch); static MEDIAINFO_Get MediaInfo_Get; typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch); static MEDIAINFOLIST_Get MediaInfoList_Get; typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_Get)(void*, const MediaInfo_Char* Parameter); static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get; typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_GetI)(void*, size_t Pos); static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI; typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value); static MEDIAINFO_Option MediaInfo_Option; typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value); static MEDIAINFOLIST_Option MediaInfoList_Option; typedef size_t (__stdcall *MEDIAINFO_State_Get)(void*); static MEDIAINFO_State_Get MediaInfo_State_Get; typedef size_t (__stdcall *MEDIAINFOLIST_State_Get)(void*); static MEDIAINFOLIST_State_Get MediaInfoList_State_Get; typedef size_t (__stdcall *MEDIAINFO_Count_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber); static MEDIAINFO_Count_Get MediaInfo_Count_Get; typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber); static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get; typedef size_t (__stdcall *MEDIAINFO_Count_Get_Files)(void*); static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files; typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get_Files)(void*); static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files; static size_t MediaInfoDLL_Load() { size_t Errors = 0; if (Module_Count > 0) { Module_Count++; return 1; } /* Load library */ #ifdef MEDIAINFO_GLIBC MediaInfo_Module = g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY); #elif defined(_WIN32) || defined(WIN32) MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME); #else #ifdef MACOSX MediaInfo_Module = dlopen("@executable_path/" MEDIAINFODLL_NAME, RTLD_LAZY); if (!MediaInfo_Module) { CFBundleRef mainBundle = CFBundleGetMainBundle(); // get full app path and delete app name CFURLRef app_url = CFBundleCopyExecutableURL(mainBundle); CFURLRef app_path_url = CFURLCreateCopyDeletingLastPathComponent(NULL, app_url); CFStringRef app_path = CFURLCopyFileSystemPath(app_path_url, kCFURLPOSIXPathStyle); CFMutableStringRef mut_app_path = CFStringCreateMutableCopy(NULL, NULL, app_path); CFStringAppend(mut_app_path, CFSTR("/")); CFStringAppend(mut_app_path, CFSTR(MEDIAINFODLL_NAME)); CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); const char *fullPath = CFStringGetCStringPtr(mut_app_path, encodingMethod); MediaInfo_Module = dlopen(fullPath, RTLD_LAZY); CFRelease(app_url); CFRelease(app_path_url); CFRelease(app_path); CFRelease(mut_app_path); } #endif /* MACOSX*/ if (!MediaInfo_Module) MediaInfo_Module = dlopen(MEDIAINFODLL_NAME, RTLD_LAZY); if (!MediaInfo_Module) MediaInfo_Module = dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY); if (!MediaInfo_Module) MediaInfo_Module = dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY); if (!MediaInfo_Module) MediaInfo_Module = dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY); if (!MediaInfo_Module) MediaInfo_Module = dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY); if (!MediaInfo_Module) MediaInfo_Module = dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY); #endif if (!MediaInfo_Module) return (size_t) - 1; /* Load methods */ MEDIAINFO_ASSIGN(New, "New") MEDIAINFOLIST_ASSIGN(New, "New") MEDIAINFO_ASSIGN(Delete, "Delete") MEDIAINFOLIST_ASSIGN(Delete, "Delete") MEDIAINFO_ASSIGN(Open, "Open") MEDIAINFOLIST_ASSIGN(Open, "Open") MEDIAINFO_ASSIGN(Open_Buffer_Init, "Open_Buffer_Init") MEDIAINFO_ASSIGN(Open_Buffer_Continue, "Open_Buffer_Continue") MEDIAINFO_ASSIGN(Open_Buffer_Continue_GoTo_Get, "Open_Buffer_Continue_GoTo_Get") MEDIAINFO_ASSIGN(Open_Buffer_Finalize, "Open_Buffer_Finalize") MEDIAINFO_ASSIGN(Open_NextPacket, "Open_NextPacket") MEDIAINFO_ASSIGN(Close, "Close") MEDIAINFOLIST_ASSIGN(Close, "Close") MEDIAINFO_ASSIGN(Inform, "Inform") MEDIAINFOLIST_ASSIGN(Inform, "Inform") MEDIAINFO_ASSIGN(GetI, "GetI") MEDIAINFOLIST_ASSIGN(GetI, "GetI") MEDIAINFO_ASSIGN(Get, "Get") MEDIAINFOLIST_ASSIGN(Get, "Get") MEDIAINFO_ASSIGN(Output_Buffer_Get, "Output_Buffer_Get") MEDIAINFO_ASSIGN(Output_Buffer_GetI, "Output_Buffer_GetI") MEDIAINFO_ASSIGN(Option, "Option") MEDIAINFOLIST_ASSIGN(Option, "Option") MEDIAINFO_ASSIGN(State_Get, "State_Get") MEDIAINFOLIST_ASSIGN(State_Get, "State_Get") MEDIAINFO_ASSIGN(Count_Get, "Count_Get") MEDIAINFOLIST_ASSIGN(Count_Get, "Count_Get") MEDIAINFOLIST_ASSIGN(Count_Get_Files, "Count_Get_Files") if (Errors > 0) { // Unload DLL with errors #ifdef MEDIAINFO_GLIBC g_module_close(MediaInfo_Module); #elif defined(_WIN32) || defined(WIN32) FreeLibrary(MediaInfo_Module); #else dlclose(MediaInfo_Module); #endif MediaInfo_Module = NULL; return (size_t) - 1; } Module_Count++; return (size_t)1; } static size_t MediaInfoDLL_IsLoaded() { if (MediaInfo_Module) return 1; else return 0; } static void MediaInfoDLL_UnLoad() { Module_Count--; if (Module_Count > 0) return; #ifdef MEDIAINFO_GLIBC g_module_close(MediaInfo_Module); #elif defined(_WIN32) || defined(WIN32) FreeLibrary(MediaInfo_Module); #else dlclose(MediaInfo_Module); #endif MediaInfo_Module = NULL; } #ifdef __cplusplus } #endif /*__cplusplus*/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ #ifdef __cplusplus //DLL C++ wrapper for C functions //--------------------------------------------------------------------------- #include #include //--------------------------------------------------------------------------- namespace MediaInfoDLL { //--------------------------------------------------------------------------- //MediaInfo_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 String; typedef std::basic_stringstream StringStream; typedef std::basic_istringstream iStringStream; typedef std::basic_ostringstream oStringStream; typedef std::basic_istringstream tiStringStream; // Legacy typedef std::basic_ostringstream toStringStream; //Legacy const size_t Error = (size_t)(-1); //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- /// @brief Kinds of Stream enum stream_t { Stream_General, ///< StreamKind = General Stream_Video, ///< StreamKind = Video Stream_Audio, ///< StreamKind = Audio Stream_Text, ///< StreamKind = Text Stream_Other, ///< StreamKind = Other 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 = Information : how data is found 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 }; const String Unable_Load_DLL = __T("Unable to load ")MEDIAINFODLL_NAME; #define MEDIAINFO_TEST_VOID \ if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return;} #define MEDIAINFO_TEST_INT \ if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return 0;} #define MEDIAINFO_TEST_STRING \ if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return Unable_Load_DLL;} #define MEDIAINFO_TEST_STRING_STATIC \ if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return Unable_Load_DLL;} //--------------------------------------------------------------------------- class MediaInfo { public : MediaInfo() {if (!MediaInfo_Module) MediaInfoDLL_Load(); if (!MediaInfo_Module) {Handle = NULL; return;}; Handle = MediaInfo_New();}; ~MediaInfo() {MEDIAINFO_TEST_VOID; MediaInfo_Delete(Handle);}; //File size_t Open(const String &File) {MEDIAINFO_TEST_INT; return MediaInfo_Open(Handle, File.c_str());}; size_t Open_Buffer_Init(MediaInfo_int64u File_Size = (MediaInfo_int64u) - 1, MediaInfo_int64u File_Offset = 0) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Init(Handle, File_Size, File_Offset);}; size_t Open_Buffer_Continue(MediaInfo_int8u* Buffer, size_t Buffer_Size) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);}; MediaInfo_int64u Open_Buffer_Continue_GoTo_Get() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);}; size_t Open_Buffer_Finalize() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Finalize(Handle);}; size_t Open_NextPacket() {MEDIAINFO_TEST_INT; return MediaInfo_Open_NextPacket(Handle);}; //size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);}; void Close() {MEDIAINFO_TEST_VOID; return MediaInfo_Close(Handle);}; //General information String Inform() {MEDIAINFO_TEST_STRING; return MediaInfo_Inform(Handle, 0);}; String Get(stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind = Info_Text) {MEDIAINFO_TEST_STRING; return MediaInfo_GetI(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);}; String Get(stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind = Info_Text, info_t SearchKind = Info_Name) {MEDIAINFO_TEST_STRING; return MediaInfo_Get(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);}; //size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfo_SetI (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());}; //size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfo_Set (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());}; size_t Output_Buffer_Get(const String &Value) {return MediaInfo_Output_Buffer_Get(Handle, Value.c_str());} size_t Output_Buffer_Get(size_t Pos) {return MediaInfo_Output_Buffer_GetI(Handle, Pos);} String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfo_Option(Handle, Option.c_str(), Value.c_str());}; static String Option_Static(const String &Option, const String &Value = __T("")) {if (!MediaInfo_Module) MediaInfoDLL_Load(); MEDIAINFO_TEST_STRING_STATIC; return MediaInfo_Option(NULL, Option.c_str(), Value.c_str());}; size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfo_State_Get(Handle);}; size_t Count_Get(stream_t StreamKind, size_t StreamNumber = (size_t) - 1) {MEDIAINFO_TEST_INT; return MediaInfo_Count_Get(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber);}; bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;} private : void* Handle; }; class MediaInfoList { public : MediaInfoList() {MediaInfoDLL_Load(); if (!MediaInfoDLL_IsLoaded()) {Handle = NULL; return;}; Handle = MediaInfoList_New();}; ~MediaInfoList() {MEDIAINFO_TEST_VOID; MediaInfoList_Delete(Handle); MediaInfoDLL_UnLoad();}; //File size_t Open(const String &File, const fileoptions_t Options = FileOption_Nothing) {MEDIAINFO_TEST_INT; return MediaInfoList_Open(Handle, File.c_str(), (MediaInfo_fileoptions_C)Options);}; //size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);}; void Close(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_VOID; return MediaInfoList_Close(Handle, FilePos);}; //General information String Inform(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_STRING; return MediaInfoList_Inform(Handle, FilePos, 0);}; String Get(size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind = Info_Text) {MEDIAINFO_TEST_STRING; return MediaInfoList_GetI(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);}; String Get(size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind = Info_Text, info_t SearchKind = Info_Name) {MEDIAINFO_TEST_STRING; return MediaInfoList_Get(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);}; //size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfoList_SetI (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());}; //size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfoList_Set (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());}; String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfoList_Option(Handle, Option.c_str(), Value.c_str());}; static String Option_Static(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING_STATIC; return MediaInfoList_Option(NULL, Option.c_str(), Value.c_str());}; size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_State_Get(Handle);}; size_t Count_Get(size_t FilePos, stream_t StreamKind, size_t StreamNumber = (size_t) - 1) {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber);}; size_t Count_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get_Files(Handle);}; bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;} private : void* Handle; }; } //NameSpace #endif /*__cplusplus*/ #endif MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.pas0000664000000000000000000002020612652076434020374 0ustar rootrootunit MediaInfoDll; { MediaInfoLib (MediaInfo.dll v0.7.7.6) Interface for Delphi (c)2008 by Norbert Mereg (Icebob) http://MediaArea.net/MediaInfo } interface uses {$IFDEF WIN32} Windows; {$ELSE} Wintypes, WinProcs; {$ENDIF} type TMIStreamKind = ( Stream_General, Stream_Video, Stream_Audio, Stream_Text, Stream_Other, Stream_Image, Stream_Menu, Stream_Max ); type TMIInfo = ( Info_Name, Info_Text, Info_Measure, Info_Options, Info_Name_Text, Info_Measure_Text, Info_Info, Info_HowTo, Info_Max ); type TMIInfoOption = ( InfoOption_ShowInInform, InfoOption_Reserved, InfoOption_ShowInSupported, InfoOption_TypeOfValue, InfoOption_Max ); {$IFDEF STATIC} // Unicode methods function MediaInfo_New(): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; procedure MediaInfo_Delete(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF}; external 'MediaInfo.Dll'; function MediaInfo_Open(Handle: Cardinal; File__: PWideChar): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; procedure MediaInfo_Close(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfo_Inform(Handle: Cardinal; Reserved: Integer): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfo_GetI(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text function MediaInfo_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PWideChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name function MediaInfo_Option(Handle: Cardinal; Option: PWideChar; Value: PWideChar): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfo_State_Get(Handle: Cardinal): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfo_Count_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; // Ansi methods function MediaInfoA_New(): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; procedure MediaInfoA_Delete(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfoA_Open(Handle: Cardinal; File__: PChar): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; procedure MediaInfoA_Close(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfoA_Inform(Handle: Cardinal; Reserved: Integer): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfoA_GetI(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text function MediaInfoA_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name function MediaInfoA_Option(Handle: Cardinal; Option: PChar; Value: PChar): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfoA_State_Get(Handle: Cardinal): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; function MediaInfoA_Count_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; {$ELSE} var LibHandle: THandle = 0; // Unicode methods MediaInfo_New: function (): Cardinal cdecl stdcall; MediaInfo_Delete: procedure (Handle: Cardinal) cdecl stdcall; MediaInfo_Open: function (Handle: Cardinal; File__: PWideChar): Cardinal cdecl stdcall; MediaInfo_Close: procedure (Handle: Cardinal) cdecl stdcall; MediaInfo_Inform: function (Handle: Cardinal; Reserved: Integer): PWideChar cdecl stdcall; MediaInfo_GetI: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PWideChar cdecl stdcall; //Default: KindOfInfo=Info_Text, MediaInfo_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PWideChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PWideChar cdecl stdcall; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name MediaInfo_Option: function (Handle: Cardinal; Option: PWideChar; Value: PWideChar): PWideChar cdecl stdcall; MediaInfo_State_Get: function (Handle: Cardinal): Integer cdecl stdcall; MediaInfo_Count_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl stdcall; // Ansi methods MediaInfoA_New: function (): Cardinal cdecl stdcall; MediaInfoA_Delete: procedure (Handle: Cardinal) cdecl stdcall; MediaInfoA_Open: function (Handle: Cardinal; File__: PChar): Cardinal cdecl stdcall; MediaInfoA_Close: procedure (Handle: Cardinal) cdecl stdcall; MediaInfoA_Inform: function (Handle: Cardinal; Reserved: Integer): PChar cdecl stdcall; MediaInfoA_GetI: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PChar cdecl stdcall; //Default: KindOfInfo=Info_Text MediaInfoA_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PChar cdecl stdcall; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name MediaInfoA_Option: function (Handle: Cardinal; Option: PChar; Value: PChar): PChar cdecl stdcall; MediaInfoA_State_Get: function (Handle: Cardinal): Integer cdecl stdcall; MediaInfoA_Count_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl stdcall; function MediaInfoDLL_Load(LibPath: string): boolean; {$ENDIF} implementation {$IFNDEF STATIC} function MI_GetProcAddress(Name: PChar; var Addr: Pointer): boolean; begin Addr := GetProcAddress(LibHandle, Name); Result := Addr <> nil; end; function MediaInfoDLL_Load(LibPath: string): boolean; begin Result := False; if LibHandle = 0 then LibHandle := LoadLibrary(PChar(LibPath)); if LibHandle <> 0 then begin MI_GetProcAddress('MediaInfo_New', @MediaInfo_New); MI_GetProcAddress('MediaInfo_Delete', @MediaInfo_Delete); MI_GetProcAddress('MediaInfo_Open', @MediaInfo_Open); MI_GetProcAddress('MediaInfo_Close', @MediaInfo_Close); MI_GetProcAddress('MediaInfo_Inform', @MediaInfo_Inform); MI_GetProcAddress('MediaInfo_GetI', @MediaInfo_GetI); MI_GetProcAddress('MediaInfo_Get', @MediaInfo_Get); MI_GetProcAddress('MediaInfo_Option', @MediaInfo_Option); MI_GetProcAddress('MediaInfo_State_Get', @MediaInfo_State_Get); MI_GetProcAddress('MediaInfo_Count_Get', @MediaInfo_Count_Get); MI_GetProcAddress('MediaInfoA_New', @MediaInfoA_New); MI_GetProcAddress('MediaInfoA_Delete', @MediaInfoA_Delete); MI_GetProcAddress('MediaInfoA_Open', @MediaInfoA_Open); MI_GetProcAddress('MediaInfoA_Close', @MediaInfoA_Close); MI_GetProcAddress('MediaInfoA_Inform', @MediaInfoA_Inform); MI_GetProcAddress('MediaInfoA_GetI', @MediaInfoA_GetI); MI_GetProcAddress('MediaInfoA_Get', @MediaInfoA_Get); MI_GetProcAddress('MediaInfoA_Option', @MediaInfoA_Option); MI_GetProcAddress('MediaInfoA_State_Get', @MediaInfoA_State_Get); MI_GetProcAddress('MediaInfoA_Count_Get', @MediaInfoA_Count_Get); Result := True; end; end; {$ENDIF} end. MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.JNA.java0000664000000000000000000003570012652076434021146 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ // Note: the original stuff was well packaged with Java style, // but I (the main developer) prefer to keep an easiest for me // way to have all sources and example in the same place // Removed stuff: // "package net.sourceforge.mediainfo;" // directory was /net/sourceforge/mediainfo import static java.util.Collections.singletonMap; import java.lang.reflect.Method; import java.net.URL; import com.sun.jna.FunctionMapper; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; import com.sun.jna.Pointer; import com.sun.jna.WString; class MediaInfo { static String LibraryPath="mediainfo"; static { // libmediainfo for linux depends on libzen try { // We need to load dependencies first, because we know where our native libs are (e.g. Java Web Start Cache). // If we do not, the system will look for dependencies, but only in the library path. String os=System.getProperty("os.name"); if (os!=null && !os.toLowerCase().startsWith("windows") && !os.toLowerCase().startsWith("mac")) { final ClassLoader loader=MediaInfo.class.getClassLoader(); final String LocalPath; if (loader!=null) { LocalPath=loader.getResource(MediaInfo.class.getName().replace('.', '/')+ ".class").getPath().replace("MediaInfo.class", ""); try { NativeLibrary.getInstance(LocalPath+"libzen.so.0"); // Local path } catch (LinkageError e) { NativeLibrary.getInstance("zen"); // Default path } } else { LocalPath=""; NativeLibrary.getInstance("zen"); // Default path } if (LocalPath.length()>0) { try { NativeLibrary.getInstance(LocalPath+"libmediainfo.so.0"); // Local path LibraryPath=LocalPath+"libmediainfo.so.0"; } catch (LinkageError e) { } } } } catch (LinkageError e) { //Logger.getLogger(MediaInfo.class.getName()).warning("Failed to preload libzen"); } } //Internal stuff interface MediaInfoDLL_Internal extends Library { MediaInfoDLL_Internal INSTANCE = (MediaInfoDLL_Internal) Native.loadLibrary(LibraryPath, MediaInfoDLL_Internal.class, singletonMap(OPTION_FUNCTION_MAPPER, new FunctionMapper() { @Override public String getFunctionName(NativeLibrary lib, Method method) { return "MediaInfo_" + method.getName(); } } )); //Constructor/Destructor Pointer New(); void Delete(Pointer Handle); //File int Open(Pointer Handle, WString file); int Open_Buffer_Init(Pointer handle, long length, long offset); int Open_Buffer_Continue(Pointer handle, byte[] buffer, int size); long Open_Buffer_Continue_GoTo_Get(Pointer handle); int Open_Buffer_Finalize(Pointer handle); void Close(Pointer Handle); //Infos WString Inform(Pointer Handle, int Reserved); WString Get(Pointer Handle, int StreamKind, int StreamNumber, WString parameter, int infoKind, int searchKind); WString GetI(Pointer Handle, int StreamKind, int StreamNumber, int parameterIndex, int infoKind); int Count_Get(Pointer Handle, int StreamKind, int StreamNumber); //Options WString Option(Pointer Handle, WString option, WString value); } private Pointer Handle; public enum StreamKind { General, Video, Audio, Text, Other, Image, Menu; } //Enums public enum InfoKind { /** * Unique name of parameter. */ Name, /** * Value of parameter. */ Text, /** * Unique name of measure unit of parameter. */ Measure, Options, /** * Translated name of parameter. */ Name_Text, /** * Translated name of measure unit. */ Measure_Text, /** * More information about the parameter. */ Info, /** * How this parameter is supported, could be N (No), B (Beta), R (Read only), W * (Read/Write). */ HowTo, /** * Domain of this piece of information. */ Domain; } public enum Status { None (0x00), Accepted (0x01), Filled (0x02), Updated (0x04), Finalized (0x08); private int value; private Status(int value) {this.value = value;} public int getValue(int value) {return value;} } //Constructor/Destructor public MediaInfo() { Handle = MediaInfoDLL_Internal.INSTANCE.New(); } public void dispose() { if (Handle == null) throw new IllegalStateException(); MediaInfoDLL_Internal.INSTANCE.Delete(Handle); Handle = null; } @Override protected void finalize() throws Throwable { if (Handle != null) dispose(); } //File /** * Open a file and collect information about it (technical information and tags). * * @param file full name of the file to open * @return 1 if file was opened, 0 if file was not not opened */ public int Open(String File_Name) { return MediaInfoDLL_Internal.INSTANCE.Open(Handle, new WString(File_Name)); } public int Open_Buffer_Init(long length, long offset) { return MediaInfoDLL_Internal.INSTANCE.Open_Buffer_Init(Handle, length, offset); } /** * Open a stream and collect information about it (technical information and tags) (By buffer, Continue) * @param buffer pointer to the stream * @param size Count of bytes to read * @return a bitfield 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 */ public int Open_Buffer_Continue(byte[] buffer, int size) { return MediaInfoDLL_Internal.INSTANCE.Open_Buffer_Continue(Handle, buffer, size); } public long Open_Buffer_Continue_GoTo_Get() { return MediaInfoDLL_Internal.INSTANCE.Open_Buffer_Continue_GoTo_Get(Handle); } public int Open_Buffer_Finalize() { return MediaInfoDLL_Internal.INSTANCE.Open_Buffer_Finalize(Handle); } /** * Close a file opened before with Open(). * */ public void Close() { MediaInfoDLL_Internal.INSTANCE.Close(Handle); } //Information /** * Get all details about a file. * * @return All details about a file in one string */ public String Inform() { return MediaInfoDLL_Internal.INSTANCE.Inform(Handle, 0).toString(); } /** * 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"...) * @return a string about information you search, an empty string if there is a problem */ public String Get(StreamKind StreamKind, int StreamNumber, String parameter) { return Get(StreamKind, StreamNumber, parameter, InfoKind.Text, InfoKind.Name); } /** * 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"...) * @param infoKind Kind of information you want about the parameter (the text, the measure, * the help...) * @param searchKind Where to look for the parameter */ public String Get(StreamKind StreamKind, int StreamNumber, String parameter, InfoKind infoKind) { return Get(StreamKind, StreamNumber, parameter, infoKind, InfoKind.Name); } /** * 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"...) * @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, an empty string if there is a problem */ public String Get(StreamKind StreamKind, int StreamNumber, String parameter, InfoKind infoKind, InfoKind searchKind) { return MediaInfoDLL_Internal.INSTANCE.Get(Handle, StreamKind.ordinal(), StreamNumber, new WString(parameter), infoKind.ordinal(), searchKind.ordinal()).toString(); } /** * 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...) * @return a string about information you search, an empty string if there is a problem */ public String get(StreamKind StreamKind, int StreamNumber, int parameterIndex) { return Get(StreamKind, StreamNumber, parameterIndex, InfoKind.Text); } /** * 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, an empty string if there is a problem */ public String Get(StreamKind StreamKind, int StreamNumber, int parameterIndex, InfoKind infoKind) { return MediaInfoDLL_Internal.INSTANCE.GetI(Handle, StreamKind.ordinal(), StreamNumber, parameterIndex, infoKind.ordinal()).toString(); } /** * 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...) * @return number of Streams of the given Stream kind */ public int Count_Get(StreamKind StreamKind) { //We should use NativeLong for -1, but it fails on 64-bit //int Count_Get(Pointer Handle, int StreamKind, NativeLong StreamNumber); //return MediaInfoDLL_Internal.INSTANCE.Count_Get(Handle, StreamKind.ordinal(), -1); //so we use slower Get() with a character string String StreamCount = Get(StreamKind, 0, "StreamCount"); if (StreamCount == null || StreamCount.length() == 0) return 0; return Integer.parseInt(StreamCount); } /** * 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...) * @return number of Streams of the given Stream kind */ public int Count_Get(StreamKind StreamKind, int StreamNumber) { return MediaInfoDLL_Internal.INSTANCE.Count_Get(Handle, StreamKind.ordinal(), StreamNumber); } //Options /** * Configure or get information about MediaInfo. * * @param Option The name of option * @return Depends on the option: by default "" (nothing) means No, other means Yes */ public String Option(String Option) { return MediaInfoDLL_Internal.INSTANCE.Option(Handle, new WString(Option), new WString("")).toString(); } /** * Configure or get information about MediaInfo. * * @param Option The name of option * @param Value The value of option * @return Depends on the option: by default "" (nothing) means No, other means Yes */ public String Option(String Option, String Value) { return MediaInfoDLL_Internal.INSTANCE.Option(Handle, new WString(Option), new WString(Value)).toString(); } /** * Configure or get information about MediaInfo (Static version). * * @param Option The name of option * @return Depends on the option: by default "" (nothing) means No, other means Yes */ public static String Option_Static(String Option) { return MediaInfoDLL_Internal.INSTANCE.Option(MediaInfoDLL_Internal.INSTANCE.New(), new WString(Option), new WString("")).toString(); } /** * Configure or get information about MediaInfo(Static version). * * @param Option The name of option * @param Value The value of option * @return Depends on the option: by default "" (nothing) means No, other means Yes */ public static String Option_Static(String Option, String Value) { return MediaInfoDLL_Internal.INSTANCE.Option(MediaInfoDLL_Internal.INSTANCE.New(), new WString(Option), new WString(Value)).toString(); } } MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL_Static.h0000664000000000000000000010633012652076434021352 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Public DLL interface implementation // Wrapper for MediaInfo Library // Please see MediaInfo.h for help // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #ifndef MediaInfoDLL_StaticH #define MediaInfoDLL_StaticH //*************************************************************************** // 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 /*-------------------------------------------------------------------------*/ #undef MEDIAINFO_EXP #if defined(__WINDOWS__) && !defined(__MINGW32__) //MinGW32 does not support _declspec #ifdef MEDIAINFO_DLL_EXPORT #if defined(MEDIAINFODLL_EXPORTS_NODLLEXPORT) #define MEDIAINFO_EXP extern #else //!defined(MEDIAINFODLL_EXPORTS_NODLLEXPORT) #define MEDIAINFO_EXP extern _declspec(dllexport) #endif //!defined(MEDIAINFODLL_EXPORTS_NODLLEXPORT) #else #define MEDIAINFO_EXP extern _declspec(dllimport) #endif #else //defined(__WINDOWS__) && !defined(__MINGW32__) #if __GNUC__ >= 4 #define MEDIAINFO_EXP __attribute__ ((visibility("default"))) #else #define MEDIAINFO_EXP #endif #endif //defined(__WINDOWS__) && !defined(__MINGW32__) #if !defined(__WINDOWS__) #define __stdcall //Supported only on windows #endif //!defined(__WINDOWS__) /*-------------------------------------------------------------------------*/ #include /*-------------------------------------------------------------------------*/ /*8-bit int */ #if UCHAR_MAX==0xff #undef MAXTYPE_INT #define MAXTYPE_INT 8 typedef unsigned char MediaInfo_int8u; #else #pragma message This machine has no 8-bit integertype? #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; #elif defined(__WIN32__) || defined(_WIN32) #undef MAXTYPE_INT #define MAXTYPE_INT 64 typedef unsigned __int64 MediaInfo_int64u; #else #pragma message This machine has no 64-bit integer type? #endif /*-------------------------------------------------------------------------*/ /** @brief Kinds of Stream */ typedef enum MediaInfo_stream_t { MediaInfo_Stream_General, MediaInfo_Stream_Video, MediaInfo_Stream_Audio, MediaInfo_Stream_Text, MediaInfo_Stream_Other, MediaInfo_Stream_Image, MediaInfo_Stream_Menu, MediaInfo_Stream_Max } MediaInfo_stream_C; /** @brief Kinds of Info */ typedef enum MediaInfo_info_t { MediaInfo_Info_Name, MediaInfo_Info_Text, MediaInfo_Info_Measure, MediaInfo_Info_Options, MediaInfo_Info_Name_Text, MediaInfo_Info_Measure_Text, MediaInfo_Info_Info, MediaInfo_Info_HowTo, MediaInfo_Info_Max } MediaInfo_info_C; /** @brief Option if InfoKind = Info_Options */ typedef enum MediaInfo_infooptions_t { MediaInfo_InfoOption_ShowInInform, MediaInfo_InfoOption_Reserved, MediaInfo_InfoOption_ShowInSupported, MediaInfo_InfoOption_TypeOfValue, MediaInfo_InfoOption_Max } MediaInfo_infooptions_C; /** @brief File opening options */ typedef enum MediaInfo_fileoptions_t { MediaInfo_FileOption_Nothing = 0x00, MediaInfo_FileOption_NoRecursive = 0x01, MediaInfo_FileOption_CloseAll = 0x02, MediaInfo_FileOption_Max = 0x04 } MediaInfo_fileoptions_C; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /***************************************************************************/ /*! \file MediaInfoDll.h \brief DLL wrapper for MediaInfo.h. DLL wrapper for MediaInfo.h \n Can be used for C and C++\n "Handle" replaces class definition */ /***************************************************************************/ #if defined(MEDIAINFO_DLL_EXPORT) || (defined(UNICODE) || defined(_UNICODE)) //DLL construction or Unicode /** @brief A 'new' MediaInfo interface, return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfo_New (); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ /** @brief A 'new' MediaInfo interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfo_New_Quick (const wchar_t* File, const wchar_t* Options); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ /** @brief Delete a MediaInfo interface*/ MEDIAINFO_EXP void __stdcall MediaInfo_Delete (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a filename)*/ MEDIAINFO_EXP size_t __stdcall MediaInfo_Open (void* Handle, const wchar_t* File); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer) */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Init) */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_Buffer_Init (void* Handle, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Continue) */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_Buffer_Continue (void* Handle, MediaInfo_int8u* Buffer, size_t Buffer_Size); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Continue_GoTo_Get) */ MEDIAINFO_EXP MediaInfo_int64u __stdcall MediaInfo_Open_Buffer_Continue_GoTo_Get (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Finalize) */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_Buffer_Finalize (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (NextPacket) */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Open_NextPacket (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Save */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Save (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Close */ MEDIAINFO_EXP void __stdcall MediaInfo_Close (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Inform */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Inform (void* Handle, size_t Reserved); /*Default : Reserved=0*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_GetI (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfo_SetI (void* Handle, const wchar_t* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter); /** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Set (void* Handle, const wchar_t* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter); /** @brief Wrapper for MediaInfoLib::MediaInfo::Output_Buffer_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Output_Buffer_Get (void* Handle, const wchar_t* Value); /** @brief Wrapper for MediaInfoLib::MediaInfo::Output_Buffer_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Output_Buffer_GetI (void* Handle, size_t Pos); /** @brief Wrapper for MediaInfoLib::MediaInfo::Option */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfo_Option (void* Handle, const wchar_t* Option, const wchar_t* Value); /** @brief Wrapper for MediaInfoLib::MediaInfo::State_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfo_State_Get (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Count_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfo_Count_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ #else //defined(MEDIAINFO_DLL_EXPORT) || (defined(UNICODE) || defined(_UNICODE)) #define MediaInfo_New MediaInfoA_New #define MediaInfo_New_Quick MediaInfoA_New_Quick #define MediaInfo_Delete MediaInfoA_Delete #define MediaInfo_Open MediaInfoA_Open #define MediaInfo_Open_Buffer MediaInfoA_Open_Buffer #define MediaInfo_Open_Buffer_Init MediaInfoA_Open_Buffer_Init #define MediaInfo_Open_Buffer_Continue MediaInfoA_Open_Buffer_Continue #define MediaInfo_Open_Buffer_Continue_GoTo_Get MediaInfoA_Open_Buffer_Continue_GoTo_Get #define MediaInfo_Open_Buffer_Finalize MediaInfoA_Open_Buffer_Finalize #define MediaInfo_Open_NextPacket MediaInfoA_Open_NextPacket #define MediaInfo_Save MediaInfoA_Save #define MediaInfo_Close MediaInfoA_Close #define MediaInfo_Inform MediaInfoA_Inform #define MediaInfo_GetI MediaInfoA_GetI #define MediaInfo_Get MediaInfoA_Get #define MediaInfo_SetI MediaInfoA_SetI #define MediaInfo_Set MediaInfoA_Set #define MediaInfo_Output_Buffer_Get MediaInfoA_Output_Buffer_Get #define MediaInfo_Output_Buffer_GetI MediaInfoA_Output_Buffer_GetI #define MediaInfo_Option MediaInfoA_Option #define MediaInfo_State_Get MediaInfoA_State_Get #define MediaInfo_Count_Get MediaInfoA_Count_Get #endif //defined(MEDIAINFO_DLL_EXPORT) || (defined(UNICODE) || defined(_UNICODE)) /** @brief A 'new' MediaInfo interface, return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfoA_New (); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ /** @brief A 'new' MediaInfo interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfoA_New_Quick (const char* File, const char* Options); /*you must ALWAYS call MediaInfo_Delete(Handle) in order to free memory*/ /** @brief Delete a MediaInfo interface*/ MEDIAINFO_EXP void __stdcall MediaInfoA_Delete (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a filename)*/ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Open (void* Handle, const char* File); /*you must ALWAYS call MediaInfo_Close(Handle) in order to free memory*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer) */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Init) */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Open_Buffer_Init (void* Handle, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Continue) */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Open_Buffer_Continue (void* Handle, MediaInfo_int8u* Buffer, size_t Buffer_Size); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Continue_GoTo_Get) */ MEDIAINFO_EXP MediaInfo_int64u __stdcall MediaInfoA_Open_Buffer_Continue_GoTo_Get (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (with a buffer, Finalize) */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Open_Buffer_Finalize (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Open (NextPacket) */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Open_NextPacket (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Save */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Save (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Close */ MEDIAINFO_EXP void __stdcall MediaInfoA_Close (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Inform */ MEDIAINFO_EXP const char* __stdcall MediaInfoA_Inform (void* Handle, size_t Reserved); /*Default : Reserved=MediaInfo_*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ MEDIAINFO_EXP const char* __stdcall MediaInfoA_GetI (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Get */ MEDIAINFO_EXP const char* __stdcall MediaInfoA_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber, const char* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ /** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_SetI (void* Handle, const char* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const char* OldParameter); /** @brief Wrapper for MediaInfoLib::MediaInfo::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Set (void* Handle, const char* ToSet, MediaInfo_stream_C StreamKind, size_t StreamNumber, const char* Parameter, const char* OldParameter); /** @brief Wrapper for MediaInfoLib::MediaInfo::Output_Buffer_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Output_Buffer_Get (void* Handle, const char* Value); /** @brief Wrapper for MediaInfoLib::MediaInfo::Output_Buffer_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Output_Buffer_GetI (void* Handle, size_t Pos); /** @brief Wrapper for MediaInfoLib::MediaInfo::Option */ MEDIAINFO_EXP const char* __stdcall MediaInfoA_Option (void* Handle, const char* Option, const char* Value); /** @brief Wrapper for MediaInfoLib::MediaInfo::State_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_State_Get (void* Handle); /** @brief Wrapper for MediaInfoLib::MediaInfo::Count_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoA_Count_Get (void* Handle, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ #if defined(MEDIAINFO_DLL_EXPORT) || (defined(UNICODE) || defined(_UNICODE)) //DLL construction or Unicode /** @brief A 'new' MediaInfoList interface, return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfoList_New (); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ /** @brief A 'new' MediaInfoList interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfoList_New_Quick (const wchar_t* Files, const wchar_t* Config); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ /** @brief Delete a MediaInfoList interface*/ MEDIAINFO_EXP void __stdcall MediaInfoList_Delete (void* Handle); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a filename)*/ MEDIAINFO_EXP size_t __stdcall MediaInfoList_Open (void* Handle, const wchar_t* Files, const MediaInfo_fileoptions_C Options); /*Default : Options=MediaInfo_FileOption_Nothing*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a buffer) */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Save */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_Save (void* Handle, size_t FilePos); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Close */ MEDIAINFO_EXP void __stdcall MediaInfoList_Close (void* Handle, size_t FilePos); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Inform */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Inform (void* Handle, size_t FilePos, size_t Reserved); /*Default : Reserved=0*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_GetI (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_SetI (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_Set (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Option */ MEDIAINFO_EXP const wchar_t* __stdcall MediaInfoList_Option (void* Handle, const wchar_t* Option, const wchar_t* Value); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::State_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_State_Get (void* Handle); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_Count_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoList_Count_Get_Files (void* Handle); #else //defined(MEDIAINFO_DLL_EXPORT) || (defined(UNICODE) || defined(_UNICODE)) #define MediaInfoList_New MediaInfoListA_New #define MediaInfoList_New_Quick MediaInfoListA_New_Quick #define MediaInfoList_Delete MediaInfoListA_Delete #define MediaInfoList_Open MediaInfoListA_Open #define MediaInfoList_Open_Buffer MediaInfoListA_Open_Buffer #define MediaInfoList_Save MediaInfoListA_Save #define MediaInfoList_Save_All MediaInfoListA_Save_All #define MediaInfoList_Close MediaInfoListA_Close #define MediaInfoList_Close_All MediaInfoListA_Close_All #define MediaInfoList_Inform MediaInfoListA_Inform #define MediaInfoList_Inform_All MediaInfoListA_Inform_All #define MediaInfoList_GetI MediaInfoListA_GetI #define MediaInfoList_Get MediaInfoListA_Get #define MediaInfoList_SetI MediaInfoListA_SetI #define MediaInfoList_Set MediaInfoListA_Set #define MediaInfoList_Option MediaInfoListA_Option #define MediaInfoList_State_Get MediaInfoListA_State_Get #define MediaInfoList_Count_Get MediaInfoListA_Count_Get #define MediaInfoList_Count_Get_Files MediaInfoListA_Count_Get_Files #endif //defined(MEDIAINFO_DLL_EXPORT) || (defined(UNICODE) || defined(_UNICODE)) /* Warning : Deprecated, use MediaInfo_Option("Info_Version", "**YOUR VERSION COMPATIBLE**") instead */ MEDIAINFO_EXP const char* __stdcall MediaInfo_Info_Version (); /** @brief A 'new' MediaInfoList interface, return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfoListA_New (); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ /** @brief A 'new' MediaInfoList interface (with a quick init of useful options : "**VERSION**;**APP_NAME**;**APP_VERSION**", but without debug information, use it only if you know what you do), return a Handle, don't forget to delete it after using it*/ MEDIAINFO_EXP void* __stdcall MediaInfoListA_New_Quick (const char* Files, const char* Config); /*you must ALWAYS call MediaInfoList_Delete(Handle) in order to free memory*/ /** @brief Delete a MediaInfoList interface*/ MEDIAINFO_EXP void __stdcall MediaInfoListA_Delete (void* Handle); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a filename)*/ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_Open (void* Handle, const char* Files, const MediaInfo_fileoptions_C Options); /*Default : Options=0*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Open (with a buffer) */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size); /*return Handle*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Save */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_Save (void* Handle, size_t FilePos); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Close */ MEDIAINFO_EXP void __stdcall MediaInfoListA_Close (void* Handle, size_t FilePos); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Inform */ MEDIAINFO_EXP const char* __stdcall MediaInfoListA_Inform (void* Handle, size_t FilePos, size_t Reserved); /*Default : Reserved=0*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ MEDIAINFO_EXP const char* __stdcall MediaInfoListA_GetI (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C InfoKind); /*Default : InfoKind=Info_Text*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Get */ MEDIAINFO_EXP const char* __stdcall MediaInfoListA_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const char* Parameter, MediaInfo_info_C InfoKind, MediaInfo_info_C SearchKind); /*Default : InfoKind=Info_Text, SearchKind=Info_Name*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_SetI (void* Handle, const char* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, const char* OldParameter); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Set */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_Set (void* Handles, const char* ToSet, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber, const char* Parameter, const char* OldParameter); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Option */ MEDIAINFO_EXP const char* __stdcall MediaInfoListA_Option (void* Handle, const char* Option, const char* Value); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::State_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_State_Get (void* Handle); /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_Count_Get (void* Handle, size_t FilePos, MediaInfo_stream_C StreamKind, size_t StreamNumber); /*Default : StreamNumber=-1*/ /** @brief Wrapper for MediaInfoListLib::MediaInfoList::Count_Get */ MEDIAINFO_EXP size_t __stdcall MediaInfoListA_Count_Get_Files (void* Handle); #ifdef __cplusplus } #endif /*__cplusplus*/ #ifdef __cplusplus //DLL C++ wrapper for C functions #if !defined(MediaInfoH) && !defined(MEDIAINFO_DLL_EXPORT) //No Lib include and No DLL construction //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- namespace MediaInfoDLL { //--------------------------------------------------------------------------- //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 String; typedef std::basic_stringstream StringStream; typedef std::basic_istringstream tiStringStream; typedef std::basic_ostringstream toStringStream; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- /// @brief Kinds of Stream enum stream_t { Stream_General, ///< StreamKind = General Stream_Video, ///< StreamKind = Video Stream_Audio, ///< StreamKind = Audio Stream_Text, ///< StreamKind = Text Stream_Other, ///< StreamKind = Other 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 = Information : how data is found 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 }; //--------------------------------------------------------------------------- class MediaInfo { public : MediaInfo () {Handle=MediaInfo_New();}; ~MediaInfo () {MediaInfo_Delete(Handle);}; //File size_t Open (const String &File) {return MediaInfo_Open(Handle, File.c_str());}; size_t Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=NULL) {return MediaInfo_Open_Buffer(Handle, Begin, Begin_Size, End, End_Size);}; size_t Save () {return MediaInfo_Save(Handle);}; void Close () {return MediaInfo_Close(Handle);}; //General information String Inform () {return MediaInfo_Inform(Handle, 0);}; String Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text) {return MediaInfo_GetI (Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);}; String Get (stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name) {return MediaInfo_Get (Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);}; size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T("")) {return MediaInfo_SetI (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());}; size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T("")) {return MediaInfo_Set (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());}; String Option (const String &Option, const String &Value=__T("")) {return MediaInfo_Option (Handle, Option.c_str(), Value.c_str());}; static String Option_Static (const String &Option, const String &Value=__T("")) {return MediaInfo_Option (NULL, Option.c_str(), Value.c_str());}; size_t State_Get () {return MediaInfo_State_Get(Handle);}; size_t Count_Get (stream_t StreamKind, size_t StreamNumber=-1) {return MediaInfo_Count_Get(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber);}; private : void* Handle; }; class MediaInfoList { public : MediaInfoList () {Handle=MediaInfoList_New();}; ~MediaInfoList () {MediaInfoList_Delete(Handle);}; //File size_t Open (const String &File, const fileoptions_t Options=FileOption_Nothing) {return MediaInfoList_Open(Handle, File.c_str(), (MediaInfo_fileoptions_C)Options);}; size_t Open (const unsigned char* Begin, size_t Begin_Size, const unsigned char* End=NULL, size_t End_Size=NULL) {return MediaInfoList_Open_Buffer(Handle, Begin, Begin_Size, End, End_Size);}; size_t Save (size_t FilePos) {return MediaInfoList_Save(Handle, FilePos);}; void Close (size_t FilePos=-1) {return MediaInfoList_Close(Handle, FilePos);}; //General information String Inform (size_t FilePos=-1) {return MediaInfoList_Inform(Handle, FilePos, 0);}; String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text) {return MediaInfoList_GetI (Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);}; String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name) {return MediaInfoList_Get (Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);}; size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T("")) {return MediaInfoList_SetI (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());}; size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T("")) {return MediaInfoList_Set (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());}; String Option (const String &Option, const String &Value=__T("")) {return MediaInfoList_Option (Handle, Option.c_str(), Value.c_str());}; static String Option_Static (const String &Option, const String &Value=__T("")) {return MediaInfoList_Option (NULL, Option.c_str(), Value.c_str());}; size_t State_Get () {return MediaInfoList_State_Get(Handle);}; size_t Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber=-1) {return MediaInfoList_Count_Get(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber);}; size_t Count_Get () {return MediaInfoList_Count_Get_Files(Handle);}; private : void* Handle; }; } //NameSpace #endif//#if !defined(MediaInfoH) && !defined(MEDIAINFO_DLL_EXPORT) && !(defined(UNICODE) || defined(_UNICODE)) #endif /*__cplusplus*/ #endif MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.vb0000664000000000000000000001115312652076434020221 0ustar rootroot'' Copyright (c) MediaArea.net SARL. All Rights Reserved. '' '' Use of this source code is governed by a BSD-style license that can '' be found in the License.html file in the root of the source tree. '' ''+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '' '' Microsoft Visual Basic wrapper for MediaInfo Library '' See MediaInfo.h for help '' '' To make it working, you must put MediaInfo.Dll '' in the executable folder '' ''+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Imports System.Runtime.InteropServices Public Enum StreamKind As UInteger General Video Visual = Video 'Deprecated Audio Text Other Image Menu Max End Enum Public Enum InfoKind As UInteger Name Text Measure Options NameText MeasureText Info HowTo Max End Enum Public Enum InfoOptions As UInteger ShowInInform Reserved ShowInSupported TypeOfValue Max End Enum Public Class MediaInfo Private Declare Unicode Function MediaInfo_New Lib "MediaInfo.DLL" () As IntPtr Private Declare Unicode Sub MediaInfo_Delete Lib "MediaInfo.DLL" (ByVal Handle As IntPtr) Private Declare Unicode Function MediaInfo_Open Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal FileName As String) As UIntPtr Private Declare Unicode Sub MediaInfo_Close Lib "MediaInfo.DLL" (ByVal Handle As IntPtr) Private Declare Unicode Function MediaInfo_Inform Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal Reserved As UIntPtr) As IntPtr Private Declare Unicode Function MediaInfo_GetI Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal StreamKind As UIntPtr, ByVal StreamNumber As UIntPtr, ByVal Parameter As UIntPtr, ByVal KindOfInfo As UIntPtr) As IntPtr 'See MediaInfoDLL.h for enumeration values Private Declare Unicode Function MediaInfo_Get Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal StreamKind As UIntPtr, ByVal StreamNumber As UIntPtr, ByVal Parameter As String, ByVal KindOfInfo As UIntPtr, ByVal KindOfSearch As UIntPtr) As IntPtr Private Declare Unicode Function MediaInfo_Option Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal Option_ As String, ByVal Value As String) As IntPtr Private Declare Unicode Function MediaInfo_State_Get Lib "MediaInfo.DLL" (ByVal Handle As IntPtr) As UIntPtr 'see MediaInfo.h for details Private Declare Unicode Function MediaInfo_Count_Get Lib "MediaInfo.DLL" (ByVal Handle As IntPtr, ByVal StreamKind As UIntPtr, ByVal StreamNumber As IntPtr) As UIntPtr 'see MediaInfoDLL.h for enumeration values Dim Handle As IntPtr Sub New() Handle = MediaInfo_New() End Sub Protected Overrides Sub Finalize() MediaInfo_Delete(Handle) End Sub Function Open(ByVal FileName As String) As System.UIntPtr Return MediaInfo_Open(Handle, FileName) End Function Sub Close() MediaInfo_Close(Handle) End Sub Function Inform() As String Return Marshal.PtrToStringUni(MediaInfo_Inform(Handle, CType(0, UIntPtr))) End Function Function Get_(ByVal StreamKind As StreamKind, ByVal StreamNumber As Integer, ByVal Parameter As Integer, Optional ByVal KindOfInfo As InfoKind = InfoKind.Text) As String Return Marshal.PtrToStringUni(MediaInfo_GetI(Handle, CType(StreamKind, UIntPtr), CType(StreamNumber, UIntPtr), CType(Parameter, UIntPtr), CType(KindOfInfo, UIntPtr))) End Function Function Get_(ByVal StreamKind As StreamKind, ByVal StreamNumber As Integer, ByVal Parameter As String, Optional ByVal KindOfInfo As InfoKind = InfoKind.Text, Optional ByVal KindOfSearch As InfoKind = InfoKind.Name) As String Return Marshal.PtrToStringUni(MediaInfo_Get(Handle, CType(StreamKind, UIntPtr), CType(StreamNumber, UIntPtr), Parameter, CType(KindOfInfo, UIntPtr), CType(KindOfSearch, UIntPtr))) End Function Function Option_(ByVal Option__ As String, Optional ByVal Value As String = "") As String Return Marshal.PtrToStringUni(MediaInfo_Option(Handle, Option__, Value)) End Function Function State_Get() As Integer Return CInt(MediaInfo_State_Get(Handle)) End Function Function Count_Get(ByVal StreamKind As StreamKind, Optional ByVal StreamNumber As UInteger = UInteger.MaxValue) As Integer If StreamNumber = UInteger.MaxValue Then Return CInt(MediaInfo_Count_Get(Handle, CType(StreamKind, UIntPtr), CType(-1, IntPtr))) Else Return CInt(MediaInfo_Count_Get(Handle, CType(StreamKind, UIntPtr), CType(StreamNumber, IntPtr))) End If End Function End Class MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.cs0000664000000000000000000003536612652076434020233 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Microsoft Visual C# wrapper for MediaInfo Library // See MediaInfo.h for help // // To make it working, you must put MediaInfo.Dll // in the executable folder // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ using System; using System.Runtime.InteropServices; #pragma warning disable 1591 // Disable XML documentation warnings namespace MediaInfoLib { public enum StreamKind { General, Video, Audio, Text, Other, Image, Menu, } public enum InfoKind { Name, Text, Measure, Options, NameText, MeasureText, Info, HowTo } public enum InfoOptions { ShowInInform, Support, ShowInSupported, TypeOfValue } public enum InfoFileOptions { FileOption_Nothing = 0x00, FileOption_NoRecursive = 0x01, FileOption_CloseAll = 0x02, FileOption_Max = 0x04 }; public enum Status { None = 0x00, Accepted = 0x01, Filled = 0x02, Updated = 0x04, Finalized = 0x08, } public class MediaInfo { //Import of DLL functions. DO NOT USE until you know what you do (MediaInfo DLL do NOT use CoTaskMemAlloc to allocate memory) [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_New(); [DllImport("MediaInfo.dll")] private static extern void MediaInfo_Delete(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Open(IntPtr Handle, [MarshalAs(UnmanagedType.LPWStr)] string FileName); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Open(IntPtr Handle, IntPtr FileName); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Open_Buffer_Init(IntPtr Handle, Int64 File_Size, Int64 File_Offset); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Open(IntPtr Handle, Int64 File_Size, Int64 File_Offset); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Open_Buffer_Continue(IntPtr Handle, IntPtr Buffer, IntPtr Buffer_Size); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Open_Buffer_Continue(IntPtr Handle, Int64 File_Size, byte[] Buffer, IntPtr Buffer_Size); [DllImport("MediaInfo.dll")] private static extern Int64 MediaInfo_Open_Buffer_Continue_GoTo_Get(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern Int64 MediaInfoA_Open_Buffer_Continue_GoTo_Get(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Open_Buffer_Finalize(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Open_Buffer_Finalize(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern void MediaInfo_Close(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Inform(IntPtr Handle, IntPtr Reserved); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Inform(IntPtr Handle, IntPtr Reserved); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_GetI(IntPtr Handle, IntPtr StreamKind, IntPtr StreamNumber, IntPtr Parameter, IntPtr KindOfInfo); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_GetI(IntPtr Handle, IntPtr StreamKind, IntPtr StreamNumber, IntPtr Parameter, IntPtr KindOfInfo); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Get(IntPtr Handle, IntPtr StreamKind, IntPtr StreamNumber, [MarshalAs(UnmanagedType.LPWStr)] string Parameter, IntPtr KindOfInfo, IntPtr KindOfSearch); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Get(IntPtr Handle, IntPtr StreamKind, IntPtr StreamNumber, IntPtr Parameter, IntPtr KindOfInfo, IntPtr KindOfSearch); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Option(IntPtr Handle, [MarshalAs(UnmanagedType.LPWStr)] string Option, [MarshalAs(UnmanagedType.LPWStr)] string Value); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoA_Option(IntPtr Handle, IntPtr Option, IntPtr Value); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_State_Get(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfo_Count_Get(IntPtr Handle, IntPtr StreamKind, IntPtr StreamNumber); //MediaInfo class public MediaInfo() { try { Handle = MediaInfo_New(); } catch { Handle = (IntPtr)0; } if (Environment.OSVersion.ToString().IndexOf("Windows") == -1) MustUseAnsi=true; else MustUseAnsi=false; } ~MediaInfo() { if (Handle == (IntPtr)0) return; MediaInfo_Delete(Handle); } public int Open(String FileName) { if (Handle == (IntPtr)0) return 0; if (MustUseAnsi) { IntPtr FileName_Ptr = Marshal.StringToHGlobalAnsi(FileName); int ToReturn = (int)MediaInfoA_Open(Handle, FileName_Ptr); Marshal.FreeHGlobal(FileName_Ptr); return ToReturn; } else return (int)MediaInfo_Open(Handle, FileName); } public int Open_Buffer_Init(Int64 File_Size, Int64 File_Offset) { if (Handle == (IntPtr)0) return 0; return (int)MediaInfo_Open_Buffer_Init(Handle, File_Size, File_Offset); } public int Open_Buffer_Continue(IntPtr Buffer, IntPtr Buffer_Size) { if (Handle == (IntPtr)0) return 0; return (int)MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size); } public Int64 Open_Buffer_Continue_GoTo_Get() { if (Handle == (IntPtr)0) return 0; return (Int64)MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle); } public int Open_Buffer_Finalize() { if (Handle == (IntPtr)0) return 0; return (int)MediaInfo_Open_Buffer_Finalize(Handle); } public void Close() { if (Handle == (IntPtr)0) return; MediaInfo_Close(Handle); } public String Inform() { if (Handle == (IntPtr)0) return "Unable to load MediaInfo library"; if (MustUseAnsi) return Marshal.PtrToStringAnsi(MediaInfoA_Inform(Handle, (IntPtr)0)); else return Marshal.PtrToStringUni(MediaInfo_Inform(Handle, (IntPtr)0)); } public String Get(StreamKind StreamKind, int StreamNumber, String Parameter, InfoKind KindOfInfo, InfoKind KindOfSearch) { if (Handle == (IntPtr)0) return "Unable to load MediaInfo library"; if (MustUseAnsi) { IntPtr Parameter_Ptr=Marshal.StringToHGlobalAnsi(Parameter); String ToReturn=Marshal.PtrToStringAnsi(MediaInfoA_Get(Handle, (IntPtr)StreamKind, (IntPtr)StreamNumber, Parameter_Ptr, (IntPtr)KindOfInfo, (IntPtr)KindOfSearch)); Marshal.FreeHGlobal(Parameter_Ptr); return ToReturn; } else return Marshal.PtrToStringUni(MediaInfo_Get(Handle, (IntPtr)StreamKind, (IntPtr)StreamNumber, Parameter, (IntPtr)KindOfInfo, (IntPtr)KindOfSearch)); } public String Get(StreamKind StreamKind, int StreamNumber, int Parameter, InfoKind KindOfInfo) { if (Handle == (IntPtr)0) return "Unable to load MediaInfo library"; if (MustUseAnsi) return Marshal.PtrToStringAnsi(MediaInfoA_GetI(Handle, (IntPtr)StreamKind, (IntPtr)StreamNumber, (IntPtr)Parameter, (IntPtr)KindOfInfo)); else return Marshal.PtrToStringUni(MediaInfo_GetI(Handle, (IntPtr)StreamKind, (IntPtr)StreamNumber, (IntPtr)Parameter, (IntPtr)KindOfInfo)); } public String Option(String Option, String Value) { if (Handle == (IntPtr)0) return "Unable to load MediaInfo library"; if (MustUseAnsi) { IntPtr Option_Ptr=Marshal.StringToHGlobalAnsi(Option); IntPtr Value_Ptr=Marshal.StringToHGlobalAnsi(Value); String ToReturn=Marshal.PtrToStringAnsi(MediaInfoA_Option(Handle, Option_Ptr, Value_Ptr)); Marshal.FreeHGlobal(Option_Ptr); Marshal.FreeHGlobal(Value_Ptr); return ToReturn; } else return Marshal.PtrToStringUni(MediaInfo_Option(Handle, Option, Value)); } public int State_Get() { if (Handle == (IntPtr)0) return 0; return (int)MediaInfo_State_Get(Handle); } public int Count_Get(StreamKind StreamKind, int StreamNumber) { if (Handle == (IntPtr)0) return 0; return (int)MediaInfo_Count_Get(Handle, (IntPtr)StreamKind, (IntPtr)StreamNumber); } private IntPtr Handle; private bool MustUseAnsi; //Default values, if you know how to set default values in C#, say me public String Get(StreamKind StreamKind, int StreamNumber, String Parameter, InfoKind KindOfInfo) { return Get(StreamKind, StreamNumber, Parameter, KindOfInfo, InfoKind.Name); } public String Get(StreamKind StreamKind, int StreamNumber, String Parameter) { return Get(StreamKind, StreamNumber, Parameter, InfoKind.Text, InfoKind.Name); } public String Get(StreamKind StreamKind, int StreamNumber, int Parameter) { return Get(StreamKind, StreamNumber, Parameter, InfoKind.Text); } public String Option(String Option_) { return Option(Option_, ""); } public int Count_Get(StreamKind StreamKind) { return Count_Get(StreamKind, -1); } } public class MediaInfoList { //Import of DLL functions. DO NOT USE until you know what you do (MediaInfo DLL do NOT use CoTaskMemAlloc to allocate memory) [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_New(); [DllImport("MediaInfo.dll")] private static extern void MediaInfoList_Delete(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_Open(IntPtr Handle, [MarshalAs(UnmanagedType.LPWStr)] string FileName, IntPtr Options); [DllImport("MediaInfo.dll")] private static extern void MediaInfoList_Close(IntPtr Handle, IntPtr FilePos); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_Inform(IntPtr Handle, IntPtr FilePos, IntPtr Reserved); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_GetI(IntPtr Handle, IntPtr FilePos, IntPtr StreamKind, IntPtr StreamNumber, IntPtr Parameter, IntPtr KindOfInfo); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_Get(IntPtr Handle, IntPtr FilePos, IntPtr StreamKind, IntPtr StreamNumber, [MarshalAs(UnmanagedType.LPWStr)] string Parameter, IntPtr KindOfInfo, IntPtr KindOfSearch); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_Option(IntPtr Handle, [MarshalAs(UnmanagedType.LPWStr)] string Option, [MarshalAs(UnmanagedType.LPWStr)] string Value); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_State_Get(IntPtr Handle); [DllImport("MediaInfo.dll")] private static extern IntPtr MediaInfoList_Count_Get(IntPtr Handle, IntPtr FilePos, IntPtr StreamKind, IntPtr StreamNumber); //MediaInfo class public MediaInfoList() { Handle = MediaInfoList_New(); } ~MediaInfoList() { MediaInfoList_Delete(Handle); } public int Open(String FileName, InfoFileOptions Options) { return (int)MediaInfoList_Open(Handle, FileName, (IntPtr)Options); } public void Close(int FilePos) { MediaInfoList_Close(Handle, (IntPtr)FilePos); } public String Inform(int FilePos) { return Marshal.PtrToStringUni(MediaInfoList_Inform(Handle, (IntPtr)FilePos, (IntPtr)0)); } public String Get(int FilePos, StreamKind StreamKind, int StreamNumber, String Parameter, InfoKind KindOfInfo, InfoKind KindOfSearch) { return Marshal.PtrToStringUni(MediaInfoList_Get(Handle, (IntPtr)FilePos, (IntPtr)StreamKind, (IntPtr)StreamNumber, Parameter, (IntPtr)KindOfInfo, (IntPtr)KindOfSearch)); } public String Get(int FilePos, StreamKind StreamKind, int StreamNumber, int Parameter, InfoKind KindOfInfo) { return Marshal.PtrToStringUni(MediaInfoList_GetI(Handle, (IntPtr)FilePos, (IntPtr)StreamKind, (IntPtr)StreamNumber, (IntPtr)Parameter, (IntPtr)KindOfInfo)); } public String Option(String Option, String Value) { return Marshal.PtrToStringUni(MediaInfoList_Option(Handle, Option, Value)); } public int State_Get() { return (int)MediaInfoList_State_Get(Handle); } public int Count_Get(int FilePos, StreamKind StreamKind, int StreamNumber) { return (int)MediaInfoList_Count_Get(Handle, (IntPtr)FilePos, (IntPtr)StreamKind, (IntPtr)StreamNumber); } private IntPtr Handle; //Default values, if you know how to set default values in C#, say me public void Open(String FileName) { Open(FileName, 0); } public void Close() { Close(-1); } public String Get(int FilePos, StreamKind StreamKind, int StreamNumber, String Parameter, InfoKind KindOfInfo) { return Get(FilePos, StreamKind, StreamNumber, Parameter, KindOfInfo, InfoKind.Name); } public String Get(int FilePos, StreamKind StreamKind, int StreamNumber, String Parameter) { return Get(FilePos, StreamKind, StreamNumber, Parameter, InfoKind.Text, InfoKind.Name); } public String Get(int FilePos, StreamKind StreamKind, int StreamNumber, int Parameter) { return Get(FilePos, StreamKind, StreamNumber, Parameter, InfoKind.Text); } public String Option(String Option_) { return Option(Option_, ""); } public int Count_Get(int FilePos, StreamKind StreamKind) { return Count_Get(FilePos, StreamKind, -1); } } } //NameSpace MediaInfoLib/Source/MediaInfoDLL/MediaInfoDLL.cpp0000664000000000000000000012205612652076434020401 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Public DLL interface implementation // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- // For user: you can disable or enable it //#define MEDIAINFO_DEBUG //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifdef UNICODE //DLL C Interface is currently done only in UNICODE mode //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //#if defined(MUST_INCLUDE_STDAFX) //Windows ATL for Shell Extension request stdafx.h // #include "stdafx.h" //#endif //MUST_INCLUDE_STDAFX #include "MediaInfo/MediaInfoList.h" #include "MediaInfo/MediaInfo.h" #define MEDIAINFO_DLL_EXPORT #include "MediaInfoDLL_Static.h" #include "ZenLib/Ztring.h" #include "ZenLib/CriticalSection.h" #include #include #include using namespace MediaInfoLib; using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- //*************************************************************************** // //*************************************************************************** //--------------------------------------------------------------------------- struct mi_output { std::string Ansi; //One-Byte-sized characters std::wstring Unicode; //Unicode characters }; typedef std::map mi_outputs; struct mi_input { Ztring Unicode[8]; //Unicode characters multiple times }; typedef std::map mi_inputs; mi_outputs MI_Outputs; mi_inputs MI_Inputs; static CriticalSection Critical; static bool utf8=false; //--------------------------------------------------------------------------- const char* WC2MB(void* Handle, const wchar_t* Text) { //Coherancy Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(Handle); if (MI_Outputs.find(Handle)==MI_Outputs.end()) { MI_Outputs[Handle]=new mi_output; //Generic Handle MI_Output=MI_Outputs.find(Handle); } Critical.Leave(); //Adaptation if (utf8) MI_Output->second->Ansi=Ztring(Text).To_UTF8(); else MI_Output->second->Ansi=Ztring(Text).To_Local(); return MI_Output->second->Ansi.c_str(); } //--------------------------------------------------------------------------- const wchar_t* MB2WC(void* Handle, size_t Pos, const char* Text) { //Coherancy Critical.Enter(); mi_inputs::iterator MI_Input=MI_Inputs.find(Handle); if (MI_Input==MI_Inputs.end()) { MI_Inputs[Handle]=new mi_input; //Generic Handle MI_Input=MI_Inputs.find(Handle); } Critical.Leave(); //Adaptation if (utf8) return MI_Input->second->Unicode[Pos].From_UTF8(Text).c_str(); else return MI_Input->second->Unicode[Pos].From_Local(Text).c_str(); } //*************************************************************************** // //*************************************************************************** //--------------------------------------------------------------------------- // For Widgets with DEBUG in BCB // Here only because this is useful in all MediaInfo #ifdef _DEBUG void wxOnAssert(const wchar_t*, int, const char*, const wchar_t*, const wchar_t*) {} #endif //_DEBUG //--------------------------------------------------------------------------- // Debug #ifdef MEDIAINFO_DEBUG #include #include namespace MediaInfoDLL_Debug { FILE* F; std::string Debug; SYSTEMTIME st_In; void Debug_Open(bool Out) { F=fopen("C:\\Temp\\MediaInfo_Debug.txt", "a+t"); Debug.clear(); SYSTEMTIME st; GetLocalTime( &st ); char Duration[100]; if (Out) { FILETIME ft_In; if (SystemTimeToFileTime(&st_In, &ft_In)) { FILETIME ft_Out; if (SystemTimeToFileTime(&st, &ft_Out)) { ULARGE_INTEGER UI_In; UI_In.HighPart=ft_In.dwHighDateTime; UI_In.LowPart=ft_In.dwLowDateTime; ULARGE_INTEGER UI_Out; UI_Out.HighPart=ft_Out.dwHighDateTime; UI_Out.LowPart=ft_Out.dwLowDateTime; ULARGE_INTEGER UI_Diff; UI_Diff.QuadPart=UI_Out.QuadPart-UI_In.QuadPart; FILETIME ft_Diff; ft_Diff.dwHighDateTime=UI_Diff.HighPart; ft_Diff.dwLowDateTime=UI_Diff.LowPart; SYSTEMTIME st_Diff; if (FileTimeToSystemTime(&ft_Diff, &st_Diff)) { sprintf(Duration, "%02hd:%02hd:%02hd.%03hd", st_Diff.wHour, st_Diff.wMinute, st_Diff.wSecond, st_Diff.wMilliseconds); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else { st_In=st; strcpy(Duration, " "); } fprintf(F,"%02hd:%02hd:%02hd.%03hd %s", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, Duration); } void Debug_Close() { Debug += "\r\n"; fwrite(Debug.c_str(), Debug.size(), 1, F); \ fclose(F); } } using namespace MediaInfoDLL_Debug; #define MEDIAINFO_DEBUG1(_NAME,_TOAPPEND) \ Debug_Open(false); \ { \ Ztring HandleTemp=Ztring::ToZtring((size_t)Handle, 16); \ while (HandleTemp.size()<8) \ HandleTemp.insert(0, 1, __T('0')); \ Debug+=", H=";Debug+=HandleTemp.To_UTF8(); \ } \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #define MEDIAINFO_DEBUG2(_NAME,_TOAPPEND) \ Debug_Open(true); \ { \ Ztring HandleTemp=Ztring::ToZtring((size_t)Handle, 16); \ while (HandleTemp.size()<8) \ HandleTemp.insert(0, 1, __T('0')); \ Debug+=", H=";Debug+=HandleTemp.To_UTF8(); \ } \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #else // MEDIAINFO_DEBUG #define MEDIAINFO_DEBUG1(_NAME,_TOAPPEND) #define MEDIAINFO_DEBUG2(_NAME,_TOAPPEND) #endif // MEDIAINFO_DEBUG //--------------------------------------------------------------------------- //To clarify the code #define INTEGRITY_VOID(_NAME,_DEBUGA) \ MEDIAINFO_DEBUG1(_NAME,_DEBUGA) \ Critical.Enter(); \ mi_outputs::iterator MI_Output=MI_Outputs.find(Handle); \ bool MI_Output_IsOk=MI_Outputs.find(Handle)!=MI_Outputs.end(); \ Critical.Leave(); \ if (Handle==NULL || !MI_Output_IsOk) \ { \ MEDIAINFO_DEBUG2(_NAME,Debug+="Handle error") \ return; \ } \ #define INTEGRITY_SIZE_T(_NAME,_DEBUGA) \ MEDIAINFO_DEBUG1(_NAME,_DEBUGA) \ Critical.Enter(); \ mi_outputs::iterator MI_Output=MI_Outputs.find(Handle); \ bool MI_Output_IsOk=MI_Outputs.find(Handle)!=MI_Outputs.end(); \ Critical.Leave(); \ if (Handle==NULL || !MI_Output_IsOk) \ { \ MEDIAINFO_DEBUG2(_NAME, Debug+="Handle error") \ return 0; \ } \ #define INTEGRITY_INT64U(_NAME,_DEBUGA) \ MEDIAINFO_DEBUG1(_NAME,_DEBUGA) \ Critical.Enter(); \ mi_outputs::iterator MI_Output=MI_Outputs.find(Handle); \ bool MI_Output_IsOk=MI_Outputs.find(Handle)!=MI_Outputs.end(); \ Critical.Leave(); \ if (Handle==NULL || !MI_Output_IsOk) \ { \ MEDIAINFO_DEBUG2(_NAME, Debug+="Handle error") \ return 0; \ } \ #define INTEGRITY_STRING(_NAME,_DEBUGA) \ MEDIAINFO_DEBUG1(_NAME,_DEBUGA) \ Critical.Enter(); \ mi_outputs::iterator MI_Output=MI_Outputs.find(Handle); \ bool MI_Output_IsOk=MI_Outputs.find(Handle)!=MI_Outputs.end(); \ Critical.Leave(); \ if (Handle==NULL || !MI_Output_IsOk) \ { \ MEDIAINFO_DEBUG2(_NAME, Debug+="Handle error") \ Critical.Enter(); \ MI_Output=MI_Outputs.find(NULL); \ if (MI_Output==MI_Outputs.end()) \ { \ MI_Outputs[NULL]=new mi_output; \ MI_Output=MI_Outputs.find(NULL); \ } \ Critical.Leave(); \ MI_Output->second->Unicode=L"Note to developer : you must create an object before"; \ return MI_Output->second->Unicode.c_str(); \ } \ #ifndef MEDIAINFO_DEBUG #define EXECUTE_VOID(_NAME,_CLASS,_METHOD) \ try \ { \ ((_CLASS*)Handle)->_METHOD; \ } catch (...) {return;} #else //MEDIAINFO_DEBUG #define EXECUTE_VOID(_NAME,_CLASS,_METHOD) \ try \ { \ ((_CLASS*)Handle)->_METHOD; \ MEDIAINFO_DEBUG2(_NAME, "") \ } catch (...) {return;} #endif //MEDIAINFO_DEBUG #ifndef MEDIAINFO_DEBUG #define EXECUTE_SIZE_T(_NAME,_CLASS,_METHOD) \ try \ { \ return ((_CLASS*)Handle)->_METHOD; \ } catch (...) {return (size_t)-1;} #else //MEDIAINFO_DEBUG #define EXECUTE_SIZE_T(_NAME,_CLASS,_METHOD) \ try \ { \ size_t ToReturn=((_CLASS*)Handle)->_METHOD; \ MEDIAINFO_DEBUG2(_NAME, Debug+=", returns ";Debug+=Ztring::ToZtring((size_t)ToReturn).To_UTF8();) \ return ToReturn; \ } catch (...) {MEDIAINFO_DEBUG2(_NAME, Debug+="!!!Exception thrown!!!";) return (size_t)-1;} #endif //MEDIAINFO_DEBUG #ifndef MEDIAINFO_DEBUG #define EXECUTE_INT64U(_NAME,_CLASS,_METHOD) \ try \ { \ return ((_CLASS*)Handle)->_METHOD; \ } catch (...) {return (size_t)-1;} #else //MEDIAINFO_DEBUG #define EXECUTE_INT64U(_NAME,_CLASS,_METHOD) \ try \ { \ int64u ToReturn=((_CLASS*)Handle)->_METHOD; \ MEDIAINFO_DEBUG2(_NAME, Debug+=", returns ";Debug+=Ztring::ToZtring((size_t)ToReturn).To_UTF8();) \ return ToReturn; \ } catch (...) {MEDIAINFO_DEBUG2(_NAME, Debug+="!!!Exception thrown!!!";) return (size_t)-1;} #endif //MEDIAINFO_DEBUG #ifndef MEDIAINFO_DEBUG #define EXECUTE_STRING(_NAME,_CLASS,_METHOD) \ try \ { \ MI_Output->second->Unicode=((_CLASS*)Handle)->_METHOD; \ } catch (...) {MI_Output->second->Unicode.clear();} \ return MI_Output->second->Unicode.c_str(); #else //MEDIAINFO_DEBUG #define EXECUTE_STRING(_NAME,_CLASS,_METHOD) \ try \ { \ MI_Output->second->Unicode=((_CLASS*)Handle)->_METHOD; \ } catch (...) {MEDIAINFO_DEBUG2(_NAME, Debug+="!!!Exception thrown!!!";) MI_Output->second->Unicode.clear();} \ Ztring ToReturn=MI_Output->second->Unicode; \ MEDIAINFO_DEBUG2(_NAME, Debug+=", returns ";Debug+=ToReturn.To_UTF8();) \ return MI_Output->second->Unicode.c_str(); #endif //MEDIAINFO_DEBUG #define MANAGE_VOID(_NAME,_CLASS,_METHOD,_DEBUGA) \ INTEGRITY_VOID(_NAME,_DEBUGA) EXECUTE_VOID(_NAME,_CLASS,_METHOD) #define MANAGE_SIZE_T(_NAME,_CLASS,_METHOD,_DEBUGA) \ INTEGRITY_SIZE_T(_NAME,_DEBUGA) EXECUTE_SIZE_T(_NAME,_CLASS,_METHOD) #define MANAGE_INT64U(_NAME,_CLASS,_METHOD,_DEBUGA) \ INTEGRITY_INT64U(_NAME,_DEBUGA) EXECUTE_INT64U(_NAME,_CLASS,_METHOD) #define MANAGE_STRING(_NAME,_CLASS,_METHOD,_DEBUGA) \ INTEGRITY_STRING(_NAME,_DEBUGA) EXECUTE_STRING(_NAME,_CLASS,_METHOD) //*************************************************************************** // //*************************************************************************** //--------------------------------------------------------------------------- void* __stdcall MediaInfoA_New () { return MediaInfo_New(); } void* __stdcall MediaInfoA_New_Quick (const char* File, const char* Options) { return MediaInfo_New_Quick(MB2WC(NULL, 0, File), MB2WC(NULL, 1, Options)); } void __stdcall MediaInfoA_Delete (void* Handle) { MediaInfo_Delete(Handle); } size_t __stdcall MediaInfoA_Open (void* Handle, const char* File) { return MediaInfo_Open(Handle, MB2WC(Handle, 0, File)); } size_t __stdcall MediaInfoA_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size) { return MediaInfo_Open_Buffer(Handle, Begin, Begin_Size, End, End_Size); } size_t __stdcall MediaInfoA_Open_Buffer_Init (void* Handle, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset) { return MediaInfo_Open_Buffer_Init(Handle, File_Size, File_Offset); } size_t __stdcall MediaInfoA_Open_Buffer_Continue (void* Handle, MediaInfo_int8u* Buffer, size_t Buffer_Size) { return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size); } MediaInfo_int64u __stdcall MediaInfoA_Open_Buffer_Continue_GoTo_Get (void* Handle) { return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle); } size_t __stdcall MediaInfoA_Open_Buffer_Finalize (void* Handle) { return MediaInfo_Open_Buffer_Finalize(Handle); } size_t __stdcall MediaInfoA_Open_NextPacket (void* Handle) { return MediaInfo_Open_NextPacket(Handle); } size_t __stdcall MediaInfoA_Save (void* Handle) { return MediaInfo_Save(Handle); } void __stdcall MediaInfoA_Close (void* Handle) { MediaInfo_Close(Handle); } const char* __stdcall MediaInfoA_Inform (void* Handle, size_t Reserved) { return WC2MB(Handle, MediaInfo_Inform(Handle, 0)); } const char* __stdcall MediaInfoA_GetI (void* Handle, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo) { return WC2MB(Handle, MediaInfo_GetI(Handle, StreamKind, StreamNumber, Parameter, KindOfInfo)); } const char* __stdcall MediaInfoA_Get (void* Handle, MediaInfo_stream_t StreamKind, size_t StreamNumber, const char* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch) { return WC2MB(Handle, MediaInfo_Get(Handle, StreamKind, StreamNumber, MB2WC(Handle, 0, Parameter), KindOfInfo, KindOfSearch)); } size_t __stdcall MediaInfoA_SetI (void* Handle, const char* ToSet, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, const char* OldParameter) { return MediaInfo_SetI(Handle, MB2WC(Handle, 0, ToSet), StreamKind, StreamNumber, Parameter, MB2WC(Handle, 1, OldParameter)); } size_t __stdcall MediaInfoA_Set (void* Handle, const char* ToSet, MediaInfo_stream_t StreamKind, size_t StreamNumber, const char* Parameter, const char* OldParameter) { return MediaInfo_Set(Handle, MB2WC(Handle, 0, ToSet), StreamKind, StreamNumber, MB2WC(Handle, 1, Parameter), MB2WC(Handle, 2, OldParameter)); } size_t __stdcall MediaInfoA_Output_Buffer_Get (void* Handle, const char* Value) { return MediaInfo_Output_Buffer_Get(Handle, MB2WC(Handle, 0, Value)); } size_t __stdcall MediaInfoA_Output_Buffer_GetI (void* Handle, size_t Pos) { return MediaInfo_Output_Buffer_GetI(Handle, Pos); } const char* __stdcall MediaInfoA_Option (void* Handle, const char* Option, const char* Value) { return WC2MB(Handle, MediaInfo_Option(Handle, MB2WC(Handle, 0, Option), MB2WC(Handle, 1, Value))); } size_t __stdcall MediaInfoA_State_Get(void* Handle) { return MediaInfo_State_Get(Handle); } size_t __stdcall MediaInfoA_Count_Get(void* Handle, MediaInfo_stream_t StreamKind, size_t StreamNumber) { return MediaInfo_Count_Get(Handle, StreamKind, StreamNumber); } //--------------------------------------------------------------------------- void* __stdcall MediaInfoListA_New () { return MediaInfoList_New(); } void* __stdcall MediaInfoListA_New_Quick (const char* File, const char* Options) { return MediaInfoList_New_Quick(MB2WC(NULL, 0, File), MB2WC(NULL, 1, Options)); } void __stdcall MediaInfoListA_Delete (void* Handle) { MediaInfoList_Delete(Handle); } size_t __stdcall MediaInfoListA_Open (void* Handle, const char* File, const MediaInfo_fileoptions_C Options) { return MediaInfoList_Open(Handle, MB2WC(Handle, 0, File), Options); } size_t __stdcall MediaInfoListA_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size) { return MediaInfoList_Open_Buffer(Handle, Begin, Begin_Size, End, End_Size); } size_t __stdcall MediaInfoListA_Save (void* Handle, size_t FilePos) { return MediaInfoList_Save(Handle, FilePos); } void __stdcall MediaInfoListA_Close (void* Handle, size_t FilePos) { MediaInfoList_Close(Handle, FilePos); } const char* __stdcall MediaInfoListA_Inform (void* Handle, size_t FilePos, size_t Reserved) { return WC2MB(Handle, MediaInfoList_Inform(Handle, FilePos, 0)); } const char* __stdcall MediaInfoListA_GetI (void* Handle, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo) { return WC2MB(Handle, MediaInfoList_GetI(Handle, FilePos, StreamKind, StreamNumber, Parameter, KindOfInfo)); } const char* __stdcall MediaInfoListA_Get (void* Handle, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, const char* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch) { return WC2MB(Handle, MediaInfoList_Get(Handle, FilePos, StreamKind, StreamNumber, MB2WC(Handle, 1, Parameter), KindOfInfo, KindOfSearch)); } size_t __stdcall MediaInfoListA_SetI (void* Handle, const char* ToSet, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, const char* OldParameter) { return MediaInfoList_SetI(Handle, MB2WC(Handle, 0, ToSet), FilePos, StreamKind, StreamNumber, Parameter, MB2WC(Handle, 1, OldParameter)); } size_t __stdcall MediaInfoListA_Set (void* Handle, const char* ToSet, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, const char* Parameter, const char* OldParameter) { return MediaInfoList_Set(Handle, MB2WC(Handle, 0, ToSet), FilePos, StreamKind, StreamNumber, MB2WC(Handle, 1, Parameter), MB2WC(Handle, 2, OldParameter)); } const char* __stdcall MediaInfoListA_Option (void* Handle, const char* Option, const char* Value) { return WC2MB(Handle, MediaInfoList_Option(Handle, MB2WC(Handle, 0, Option), MB2WC(Handle, 1, Value))); } size_t __stdcall MediaInfoListA_State_Get(void* Handle) { return MediaInfoList_State_Get(Handle); } size_t __stdcall MediaInfoListA_Count_Get(void* Handle, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber) { return MediaInfoList_Count_Get(Handle, FilePos, StreamKind, StreamNumber); } size_t __stdcall MediaInfoListA_Count_Get_Files(void* Handle) { return MediaInfoList_Count_Get_Files(Handle); } //--------------------------------------------------------------------------- void* __stdcall MediaInfo_New () { #ifdef MEDIAINFO_DEBUG Debug_Open(false); Debug+=", New, Build="; Debug+=__DATE__; Debug+=' '; Debug+=__TIME__; Debug_Close(); #endif //MEDIAINFO_DEBUG //First init Critical.Enter(); if (MI_Outputs.find(NULL)==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; //Generic Handle } Critical.Leave(); //New MediaInfo* Handle=NULL; try { Handle=new MediaInfo; } catch(...) { MEDIAINFO_DEBUG2( "New", Debug+="!!!Exception thrown!!!";) delete Handle; return NULL; } Critical.Enter(); MI_Outputs[Handle]=new mi_output; Critical.Leave(); MEDIAINFO_DEBUG2( "New", Debug+=", returns ";Debug+=Ztring::ToZtring((size_t)Handle).To_UTF8();) return Handle; } void* __stdcall MediaInfo_New_Quick (const wchar_t* File, const wchar_t* Options) { MediaInfo_Option(NULL, L"QuickInit", Options); void* Handle=MediaInfo_New(); if (MediaInfo_Open(Handle, File)==0) { //No valid files, return NULL delete (MediaInfo*)Handle; return NULL; } return Handle; } void __stdcall MediaInfo_Delete (void* Handle) { INTEGRITY_VOID( "Delete" ,) //Delete the object delete (MediaInfo*)Handle; //Delete strings Critical.Enter(); delete MI_Outputs[Handle]; MI_Outputs.erase(Handle); if (MI_Outputs.size()==1 && MI_Outputs.find(NULL)!=MI_Outputs.end()) //In case of the last object : delete the NULL object, no more need { delete MI_Outputs[NULL]; MI_Outputs.erase(NULL); } Critical.Leave(); MEDIAINFO_DEBUG2( "Delete", ) } size_t __stdcall MediaInfo_Open (void* Handle, const wchar_t* File) { MANAGE_SIZE_T( "Open", MediaInfo, Open(File), Debug+=", File=";Debug+=Ztring(File).To_UTF8();) } size_t __stdcall MediaInfo_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size) { MANAGE_SIZE_T( "Open_Buffer", MediaInfo, Open(Begin, Begin_Size, End, End_Size), Debug+=", Begin_Size=";Debug+=Ztring::ToZtring(Begin_Size).To_UTF8();Debug+=", End_Size=";Debug+=Ztring::ToZtring(End_Size).To_UTF8();) } size_t __stdcall MediaInfo_Open_Buffer_Init (void* Handle, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset) { MANAGE_SIZE_T( "Open_Buffer_Init", MediaInfo, Open_Buffer_Init(File_Size, File_Offset), Debug+=", File_Size=";Debug+=Ztring::ToZtring(File_Size).To_UTF8();Debug+=", File_Offset=";Debug+=Ztring::ToZtring(File_Offset).To_UTF8();) } size_t __stdcall MediaInfo_Open_Buffer_Continue (void* Handle, MediaInfo_int8u* Buffer, size_t Buffer_Size) { MANAGE_SIZE_T( "Open_Buffer_Continue", MediaInfo, Open_Buffer_Continue(Buffer, Buffer_Size), Debug+=", Buffer_Size=";Debug+=Ztring::ToZtring(Buffer_Size).To_UTF8();) } MediaInfo_int64u __stdcall MediaInfo_Open_Buffer_Continue_GoTo_Get (void* Handle) { MANAGE_INT64U( "Open_Buffer_Continue_GoTo_Get", MediaInfo, Open_Buffer_Continue_GoTo_Get(), ) } size_t __stdcall MediaInfo_Open_Buffer_Finalize (void* Handle) { MANAGE_SIZE_T( "Open_Buffer_Finalize", MediaInfo, Open_Buffer_Finalize(), ) } size_t __stdcall MediaInfo_Open_NextPacket (void* Handle) { MANAGE_SIZE_T( "Open_NextPacket", MediaInfo, Open_NextPacket(), ) } size_t __stdcall MediaInfo_Save (void* Handle) { MANAGE_SIZE_T( "Save", MediaInfo, Save(), ) } void __stdcall MediaInfo_Close (void* Handle) { MANAGE_VOID( "Close", MediaInfo, Close(), ) } const wchar_t* __stdcall MediaInfo_Inform (void* Handle, size_t Reserved) { MANAGE_STRING( "Inform", MediaInfo, Inform(), ) } const wchar_t* __stdcall MediaInfo_GetI (void* Handle, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); KindOfInfo=(MediaInfo_info_C) (((size_t)KindOfInfo)&0xFF); MANAGE_STRING( "GetI", MediaInfo, Get((stream_t)StreamKind, StreamNumber, Parameter, (info_t)KindOfInfo), Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring::ToZtring(Parameter).To_UTF8();Debug+=", KindOfInfo=";Debug+=Ztring::ToZtring(KindOfInfo).To_UTF8();) } const wchar_t* __stdcall MediaInfo_Get (void* Handle, MediaInfo_stream_t StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); KindOfInfo=(MediaInfo_info_C) (((size_t)KindOfInfo)&0xFF); KindOfSearch=(MediaInfo_info_C)(((size_t)KindOfSearch)&0xFF); MANAGE_STRING( "Get", MediaInfo, Get((stream_t)StreamKind, StreamNumber, Parameter, (info_t)KindOfInfo, (info_t)KindOfSearch), Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring(Parameter).To_UTF8();Debug+=", KindOfInfo=";Debug+=Ztring::ToZtring(KindOfInfo).To_UTF8();Debug+=", KindOfSearch=";Debug+=Ztring::ToZtring(KindOfSearch).To_UTF8();) } size_t __stdcall MediaInfo_SetI (void* Handle, const wchar_t* ToSet, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); MANAGE_SIZE_T( "SetI", MediaInfo, Set(ToSet, (stream_t)StreamKind, StreamNumber, Parameter, OldParameter), Debug+=", ToSet=";Debug+=Ztring(ToSet).To_UTF8();Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring::ToZtring(Parameter).To_UTF8();) } size_t __stdcall MediaInfo_Set (void* Handle, const wchar_t* ToSet, MediaInfo_stream_t StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); MANAGE_SIZE_T( "Set", MediaInfo, Set(ToSet, (stream_t)StreamKind, StreamNumber, Parameter, OldParameter), Debug+=", ToSet=";Debug+=Ztring(ToSet).To_UTF8();Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring(Parameter).To_UTF8();) } size_t __stdcall MediaInfo_Output_Buffer_Get (void* Handle, const wchar_t* Value) { MANAGE_SIZE_T( "Output_Buffer_Get", MediaInfo, Output_Buffer_Get(Value), Debug+=", Value=";Debug+=Ztring(Value).To_UTF8();) } size_t __stdcall MediaInfo_Output_Buffer_GetI (void* Handle, size_t Pos) { MANAGE_SIZE_T( "Output_Buffer_GetI", MediaInfo, Output_Buffer_Get(Pos), Debug+=", Pos=";Debug+=Ztring::ToZtring(Pos).To_UTF8();) } const wchar_t* __stdcall MediaInfo_Option (void* Handle, const wchar_t* Option, const wchar_t* Value) { //DLL only option if (Ztring(Option).Compare(L"CharSet", L"==")) { MEDIAINFO_DEBUG1( "Option", Debug+=", Option=";Debug+=Ztring(Option).To_UTF8();Debug+=", Value=";Debug+=Ztring(Value).To_UTF8();) //Coherancy Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(NULL); if (MI_Outputs.find(NULL)==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; //Generic Handle MI_Output=MI_Outputs.find(NULL); } Critical.Leave(); if (Ztring(Value).Compare(L"UTF-8", L"==")) utf8=true; else utf8=false; MI_Output->second->Unicode.clear(); MEDIAINFO_DEBUG2( "CharSet", ) return MI_Output->second->Unicode.c_str(); } if (Ztring(Option).Compare(L"setlocale_LC_CTYPE", L"==")) { //Coherancy Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(NULL); if (MI_Outputs.find(NULL)==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; //Generic Handle MI_Output=MI_Outputs.find(NULL); } Critical.Leave(); setlocale(LC_CTYPE, utf8?Ztring(Value).To_UTF8().c_str():Ztring(Value).To_Local().c_str()); MI_Output->second->Unicode.clear(); MEDIAINFO_DEBUG2( "setlocale_LC_CTYPE", ) return MI_Output->second->Unicode.c_str(); } if (Handle) { MANAGE_STRING( "Option", MediaInfo, Option(Option, Value), ) } else { //MANAGE_STRING Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(NULL); if (MI_Output==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; MI_Output=MI_Outputs.find(NULL); } Critical.Leave(); EXECUTE_STRING( "Option_Static", MediaInfo, Option_Static(Option, Value)); } } size_t __stdcall MediaInfo_State_Get(void* Handle) { MANAGE_SIZE_T( "State_Get", MediaInfo, State_Get(), ) } size_t __stdcall MediaInfo_Count_Get(void* Handle, MediaInfo_stream_t StreamKind, size_t StreamNumber) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); MANAGE_SIZE_T( "Count_Get", MediaInfo, Count_Get((stream_t)StreamKind, StreamNumber), Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring((size_t)StreamNumber).To_UTF8();) } //--------------------------------------------------------------------------- void* __stdcall MediaInfoList_New () { #ifdef MEDIAINFO_DEBUG Debug_Open(false); Debug+=", New, Build="; Debug+=__DATE__; Debug+=' '; Debug+=__TIME__; Debug_Close(); #endif //MEDIAINFO_DEBUG //First init Critical.Enter(); if (MI_Outputs.find(NULL)==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; //Generic Handle } Critical.Leave(); //New MediaInfoList* Handle=NULL; try { Handle=new MediaInfoList; } catch(...) { MEDIAINFO_DEBUG2( "New", Debug+="!!!Exception thrown!!!";) delete Handle; return NULL; } Critical.Enter(); MI_Outputs[Handle]=new mi_output; Critical.Leave(); MEDIAINFO_DEBUG2( "New", Debug+=", returns ";Debug+=Ztring::ToZtring((size_t)Handle).To_UTF8();) return Handle; } void* __stdcall MediaInfoList_New_Quick (const wchar_t* File, const wchar_t* Options) { MediaInfoList_Option(NULL, L"QuickInit", Options); void* Handle=MediaInfoList_New(); if (MediaInfoList_Open(Handle, File, MediaInfo_FileOption_Nothing)==0) { //No valid files, return NULL delete (MediaInfoList*)Handle; return NULL; } return Handle; } void __stdcall MediaInfoList_Delete (void* Handle) { INTEGRITY_VOID( "Delete" ,) //Delete the object delete (MediaInfoList*)Handle; //Delete strings Critical.Enter(); delete MI_Outputs[Handle]; MI_Outputs.erase(Handle); if (MI_Outputs.size()==1 && MI_Outputs.find(NULL)!=MI_Outputs.end()) //In case of the last object : delete the NULL object, no more need { delete MI_Outputs[NULL]; MI_Outputs.erase(NULL); } Critical.Leave(); MEDIAINFO_DEBUG2( "Delete", ) } size_t __stdcall MediaInfoList_Open (void* Handle, const wchar_t* File, const MediaInfo_fileoptions_C Options) { MANAGE_SIZE_T( "Open", MediaInfoList, Open(File), Debug+=", File=";Debug+=Ztring(File).To_UTF8();) } size_t __stdcall MediaInfoList_Open_Buffer (void* Handle, const unsigned char* Begin, size_t Begin_Size, const unsigned char* End, size_t End_Size) { return 0; // Not implemented } size_t __stdcall MediaInfoList_Save (void* Handle, size_t FilePos) { MANAGE_SIZE_T( "Save", MediaInfoList, Save(FilePos), ) } void __stdcall MediaInfoList_Close (void* Handle, size_t FilePos) { MANAGE_VOID( "Close", MediaInfoList, Close(FilePos), ) } const wchar_t* __stdcall MediaInfoList_Inform (void* Handle, size_t FilePos, size_t Reserved) { MANAGE_STRING( "Inform", MediaInfoList, Inform(FilePos), ) } const wchar_t* __stdcall MediaInfoList_GetI (void* Handle, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); KindOfInfo=(MediaInfo_info_C) (((size_t)KindOfInfo)&0xFF); MANAGE_STRING( "GetI", MediaInfoList, Get(FilePos, (stream_t)StreamKind, StreamNumber, Parameter, (info_t)KindOfInfo), Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring::ToZtring(Parameter).To_UTF8();Debug+=", KindOfInfo=";Debug+=Ztring::ToZtring(KindOfInfo).To_UTF8();) } const wchar_t* __stdcall MediaInfoList_Get (void* Handle, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, const wchar_t* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); KindOfInfo=(MediaInfo_info_C) (((size_t)KindOfInfo)&0xFF); MANAGE_STRING( "Get", MediaInfoList, Get(FilePos, (stream_t)StreamKind, StreamNumber, Parameter, (info_t)KindOfInfo, (info_t)KindOfSearch), Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring(Parameter).To_UTF8();Debug+=", KindOfInfo=";Debug+=Ztring::ToZtring(KindOfInfo).To_UTF8();Debug+=", KindOfSearch=";Debug+=Ztring::ToZtring(KindOfSearch).To_UTF8();) } size_t __stdcall MediaInfoList_SetI (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, size_t Parameter, const wchar_t* OldParameter) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); MANAGE_SIZE_T( "SetI", MediaInfoList, Set(ToSet, FilePos, (stream_t)StreamKind, StreamNumber, Parameter), Debug+=", ToSet=";Debug+=Ztring(ToSet).To_UTF8();Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring::ToZtring(Parameter).To_UTF8();) } size_t __stdcall MediaInfoList_Set (void* Handle, const wchar_t* ToSet, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber, const wchar_t* Parameter, const wchar_t* OldParameter) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); MANAGE_SIZE_T( "Set", MediaInfoList, Set(ToSet, FilePos, (stream_t)StreamKind, StreamNumber, Parameter, OldParameter), Debug+=", ToSet=";Debug+=Ztring(ToSet).To_UTF8();Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring(StreamNumber).To_UTF8();Debug+=", Parameter=";Debug+=Ztring(Parameter).To_UTF8();) } const wchar_t* __stdcall MediaInfoList_Option (void* Handle, const wchar_t* Option, const wchar_t* Value) { //DLL only option if (Ztring(Option).Compare(L"CharSet", L"==")) { MEDIAINFO_DEBUG1( "Option", Debug+=", Option=";Debug+=Ztring(Option).To_UTF8();Debug+=", Value=";Debug+=Ztring(Value).To_UTF8();) //Coherancy Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(NULL); if (MI_Outputs.find(NULL)==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; //Generic Handle MI_Output=MI_Outputs.find(NULL); } Critical.Leave(); if (Ztring(Value).Compare(L"UTF-8", L"==")) utf8=true; else utf8=false; MI_Output->second->Unicode.clear(); MEDIAINFO_DEBUG2( "CharSet", ) return MI_Output->second->Unicode.c_str(); } if (Ztring(Option).Compare(L"setlocale_LC_CTYPE", L"==")) { //Coherancy Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(NULL); if (MI_Outputs.find(NULL)==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; //Generic Handle MI_Output=MI_Outputs.find(NULL); } Critical.Leave(); setlocale(LC_CTYPE, utf8?Ztring(Value).To_UTF8().c_str():Ztring(Value).To_Local().c_str()); MI_Output->second->Unicode.clear(); MEDIAINFO_DEBUG2( "setlocale_LC_CTYPE", ) return MI_Output->second->Unicode.c_str(); } if (Handle) { MANAGE_STRING( "Option", MediaInfoList, Option(Option, Value), ) } else { //MANAGE_STRING Critical.Enter(); mi_outputs::iterator MI_Output=MI_Outputs.find(NULL); if (MI_Output==MI_Outputs.end()) { MI_Outputs[NULL]=new mi_output; MI_Output=MI_Outputs.find(NULL); } Critical.Leave(); EXECUTE_STRING( "Option_Static", MediaInfoList, Option_Static(Option, Value)); } } size_t __stdcall MediaInfoList_State_Get(void* Handle) { MANAGE_SIZE_T( "State_Get", MediaInfoList, State_Get(), ) } size_t __stdcall MediaInfoList_Count_Get(void* Handle, size_t FilePos, MediaInfo_stream_t StreamKind, size_t StreamNumber) { StreamKind=(MediaInfo_stream_t)(((size_t)StreamKind)&0xFF); MANAGE_SIZE_T( "Count_Get", MediaInfoList, Count_Get(FilePos, (stream_t)StreamKind, StreamNumber), Debug+=", StreamKind=";Debug+=Ztring::ToZtring((size_t)StreamKind).To_UTF8();Debug+=", StreamNumber=";Debug+=Ztring::ToZtring((size_t)StreamNumber).To_UTF8();) } size_t __stdcall MediaInfoList_Count_Get_Files(void* Handle) { MANAGE_SIZE_T( "Count_Get", MediaInfoList, Count_Get(), ) } //--------------------------------------------------------------------------- const char* __stdcall MediaInfo_Info_Version() { #ifdef MEDIAINFO_DEBUG Debug_Open(false); Debug+=", MediaInfo_Info_Version"; Debug_Close(); #endif //MEDIAINFO_DEBUG #ifdef MEDIAINFO_DEBUG Debug_Open(true); Debug+=", MediaInfo_Info_Version"; Debug_Close(); #endif //MEDIAINFO_DEBUG return "Your software uses an outdated interface, You must use MediaInfo.DLL 0.4.1.1 instead"; //wchar_t* MediaInfo_wChar=new wchar_t[1000]; //GetModuleFileNameW (NULL, MediaInfo_wChar, 1000); //return WC2MB(MediaInfo_wChar); } //*************************************************************************** // //*************************************************************************** #endif //UNICODE MediaInfoLib/Source/Example/0000775000000000000000000000000012652076434014704 5ustar rootrootMediaInfoLib/Source/Example/HowToUse_Dll_CLI.cs0000664000000000000000000000616712652076434020244 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Microsoft Visual C# example // // To make this example working, you must put MediaInfo.Dll and Example.ogg // in the "./Bin/__ConfigurationName__" folder // and add MediaInfoDll.cs to your project // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ using System; using MediaInfoLib; namespace MediaInfoLib_MSCS { public class CLI { [STAThread] static void Main(string[] Args) { String ToDisplay; MediaInfo MI = new MediaInfo(); ToDisplay = MI.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0"); if (ToDisplay.Length == 0) { Console.Out.WriteLine("MediaInfo.Dll: this version of the DLL is not compatible"); return; } //Information about MediaInfo ToDisplay += "\r\n\r\nInfo_Parameters\r\n"; ToDisplay += MI.Option("Info_Parameters"); ToDisplay += "\r\n\r\nInfo_Capacities\r\n"; ToDisplay += MI.Option("Info_Capacities"); ToDisplay += "\r\n\r\nInfo_Codecs\r\n"; ToDisplay += MI.Option("Info_Codecs"); //An example of how to use the library ToDisplay += "\r\n\r\nOpen\r\n"; String File_Name; if (Args.Length == 0) File_Name = "Example.ogg"; else File_Name = Args[0]; MI.Open(File_Name); ToDisplay += "\r\n\r\nInform with Complete=false\r\n"; MI.Option("Complete"); ToDisplay += MI.Inform(); ToDisplay += "\r\n\r\nInform with Complete=true\r\n"; MI.Option("Complete", "1"); ToDisplay += MI.Inform(); ToDisplay += "\r\n\r\nCustom Inform\r\n"; MI.Option("Inform", "General;File size is %FileSize% bytes"); ToDisplay += MI.Inform(); ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='FileSize'\r\n"; ToDisplay += MI.Get(0, 0, "FileSize"); ToDisplay += "\r\n\r\nGet with Stream=General and Parameter=46\r\n"; ToDisplay += MI.Get(0, 0, 46); ToDisplay += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n"; ToDisplay += MI.Count_Get(StreamKind.Audio); ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='AudioCount'\r\n"; ToDisplay += MI.Get(StreamKind.General, 0, "AudioCount"); ToDisplay += "\r\n\r\nGet with Stream=Audio and Parameter='StreamCount'\r\n"; ToDisplay += MI.Get(StreamKind.Audio, 0, "StreamCount"); ToDisplay += "\r\n\r\nClose\r\n"; MI.Close(); //Displaying the text Console.Out.WriteLine(ToDisplay); } } } MediaInfoLib/Source/Example/HowToUse_Dll.cs0000664000000000000000000001755712652076434017562 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Microsoft Visual C# example // // To make this example working, you must put MediaInfo.Dll and Example.ogg // in the "./Bin/__ConfigurationName__" folder // and add MediaInfoDll.cs to your project // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Text; using System.IO; using MediaInfoLib; namespace MediaInfoLib_MSCS { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.RichTextBox richTextBox1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Methode requise pour la prise en charge du concepteur - ne modifiez pas /// le contenu de cette méthode avec l'éditeur de code. /// private void InitializeComponent() { this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.SuspendLayout(); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(0, 0); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(768, 512); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = ""; // // Form1 // this.ClientSize = new System.Drawing.Size(770, 514); this.Controls.Add(this.richTextBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "How to use MediaInfo.Dll"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { //Test if version of DLL is compatible : 3rd argument is "version of DLL tested;Your application name;Your application version" String ToDisplay; MediaInfo MI = new MediaInfo(); ToDisplay = MI.Option("Info_Version", "0.7.0.0;MediaInfoDLL_Example_CS;0.7.0.0"); if (ToDisplay.Length == 0) { richTextBox1.Text = "MediaInfo.Dll: this version of the DLL is not compatible"; return; } //Information about MediaInfo ToDisplay += "\r\n\r\nInfo_Parameters\r\n"; ToDisplay += MI.Option("Info_Parameters"); ToDisplay += "\r\n\r\nInfo_Capacities\r\n"; ToDisplay += MI.Option("Info_Capacities"); ToDisplay += "\r\n\r\nInfo_Codecs\r\n"; ToDisplay += MI.Option("Info_Codecs"); //An example of how to use the library ToDisplay += "\r\n\r\nOpen\r\n"; MI.Open("Example.ogg"); ToDisplay += "\r\n\r\nInform with Complete=false\r\n"; MI.Option("Complete"); ToDisplay += MI.Inform(); ToDisplay += "\r\n\r\nInform with Complete=true\r\n"; MI.Option("Complete", "1"); ToDisplay += MI.Inform(); ToDisplay += "\r\n\r\nCustom Inform\r\n"; MI.Option("Inform", "General;File size is %FileSize% bytes"); ToDisplay += MI.Inform(); ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='FileSize'\r\n"; ToDisplay += MI.Get(0, 0, "FileSize"); ToDisplay += "\r\n\r\nGet with Stream=General and Parameter=46\r\n"; ToDisplay += MI.Get(0, 0, 46); ToDisplay += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n"; ToDisplay += MI.Count_Get(StreamKind.Audio); ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='AudioCount'\r\n"; ToDisplay += MI.Get(StreamKind.General, 0, "AudioCount"); ToDisplay += "\r\n\r\nGet with Stream=Audio and Parameter='StreamCount'\r\n"; ToDisplay += MI.Get(StreamKind.Audio, 0, "StreamCount"); ToDisplay += "\r\n\r\nClose\r\n"; MI.Close(); //Example with a stream //ToDisplay+="\r\n"+ExampleWithStream()+"\r\n"; //Displaying the text richTextBox1.Text = ToDisplay; } String ExampleWithStream() { //Initilaizing MediaInfo MediaInfo MI = new MediaInfo(); //From: preparing an example file for reading FileStream From = new FileStream("Example.ogg", FileMode.Open, FileAccess.Read); //From: preparing a memory buffer for reading byte[] From_Buffer = new byte[64*1024]; int From_Buffer_Size; //The size of the read file buffer //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(From.Length, 0); //The parsing loop do { //Reading data somewhere, do what you want for this. From_Buffer_Size = From.Read(From_Buffer, 0, 64 * 1024); //Sending the buffer to MediaInfo System.Runtime.InteropServices.GCHandle GC = System.Runtime.InteropServices.GCHandle.Alloc(From_Buffer, System.Runtime.InteropServices.GCHandleType.Pinned); IntPtr From_Buffer_IntPtr = GC.AddrOfPinnedObject(); Status Result = (Status)MI.Open_Buffer_Continue(From_Buffer_IntPtr, (IntPtr)From_Buffer_Size); GC.Free(); if ((Result & Status.Finalized) == Status.Finalized) break; //Testing if MediaInfo request to go elsewhere if (MI.Open_Buffer_Continue_GoTo_Get() != -1) { Int64 Position = From.Seek(MI.Open_Buffer_Continue_GoTo_Get(), SeekOrigin.Begin); //Position the file MI.Open_Buffer_Init(From.Length, Position); //Informing MediaInfo we have seek } } while (From_Buffer_Size > 0); //Finalizing MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work //Get() example return "Container format is " + MI.Get(StreamKind.General, 0, "Format"); } } } MediaInfoLib/Source/Example/HowToUse_Dll.au30000664000000000000000000001353612652076434017636 0ustar rootroot;Loading the DLL $DLL=DllOpen("MediaInfo.dll") ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; General info ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;Info $Info_Parameters=DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Info_Parameters", "wstr", "") MsgBox(0, "MediaInfo_Option - Info_Parameters", $Info_Parameters[0]) $Info_Capacities=DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Info_Capacities", "wstr", "") MsgBox(0, "MediaInfo_Option - Info_Capacities", $Info_Capacities[0]) $Info_Codecs=DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Info_Codecs", "wstr", "") MsgBox(0, "MediaInfo_Option - Info_Codecs", $Info_Codecs[0]) ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; MediaInfo ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;New MediaInfo handle $Handle=DllCall($DLL, "ptr", "MediaInfo_New") ;Open $Open_Result=DllCall($DLL, "int", "MediaInfo_Open", "ptr", $Handle[0], "wstr", "Example.ogg") ;Inform with Complete=false DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Complete", "wstr", "") $Inform=DllCall($DLL, "wstr", "MediaInfo_Inform", "ptr", $Handle[0], "int", 0) MsgBox(0, "Inform with Complete=false", $Inform[0]) ;Inform with Complete=true DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Complete", "wstr", "1") $Inform=DllCall($DLL, "wstr", "MediaInfo_Inform", "ptr", $Handle[0], "int", 0) MsgBox(0, "Inform with Complete=true", $Inform[0]) ;Custom Inform DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;Example : FileSize=%FileSize%") $Inform=DllCall($DLL, "wstr", "MediaInfo_Inform", "ptr", $Handle[0], "int", 0) MsgBox(0, "Custom Inform", $Inform[0]) ;Get with Stream=General and Parameter=FileSize $Info_Get=DllCall($DLL, "wstr", "MediaInfo_Get", "ptr", $Handle[0], "int", 0, "int", 0, "wstr", "FileSize", "int", 1, "int", 0) MsgBox(0, "Get with Stream=General and Parameter=FileSize", $Info_Get[0]) ;GetI with Stream=General and Parameter=46 $Info_GetI=DllCall($DLL, "wstr", "MediaInfo_GetI", "ptr", $Handle[0], "int", 0, "int", 0, "int", 46, "int", 1) MsgBox(0, "Get with Stream=General and Parameter=46", $Info_GetI[0]) ;Count_Get with StreamKind=Stream_Audio $Count_Get=DllCall($DLL, "int", "MediaInfo_Count_Get", "ptr", $Handle[0], "int", 2, "int", 0) MsgBox(0, "Count_Get with StreamKind=Stream_Audio", $Count_Get[0]) ;Get with Stream=General and Parameter=AudioCount $Info_Get=DllCall($DLL, "wstr", "MediaInfo_Get", "ptr", $Handle[0], "int", 0, "int", 0, "wstr", "AudioCount", "int", 1, "int", 0) MsgBox(0, "Get with Stream=General and Parameter=AudioCount", $Info_Get[0]) ;Get with Stream=Audio and Parameter=StreamCount $Info_Get=DllCall($DLL, "wstr", "MediaInfo_Get", "ptr", $Handle[0], "int", 2, "int", 0, "wstr", "StreamCount", "int", 1, "int", 0) MsgBox(0, "Get with Stream=Audio and Parameter=StreamCount", $Info_Get[0]) ;Delete MediaInfo handle $Handle=DllCall($DLL, "none", "MediaInfo_Delete", "ptr", $Handle[0]) ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; MediaInfoList ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;New MediaInfoList handle $Handle=DllCall($DLL, "ptr", "MediaInfoList_New") ;Open $Open_Result=DllCall($DLL, "int", "MediaInfoList_Open", "ptr", $Handle[0], "wstr", "Example.ogg", "int", 0) ;Count_Get $Count_Get=DllCall($DLL, "int", "MediaInfoList_Count_Get_Files", "ptr", $Handle[0]) MsgBox(0, "Count_Get", $Count_Get[0]) For $i = 0 to $Count_Get[0]-1 ;Inform with Complete=true ;Inform with Complete=false DllCall($DLL, "wstr", "MediaInfoList_Option", "ptr", 0, "wstr", "Complete", "wstr", "") $Inform=DllCall($DLL, "wstr", "MediaInfoList_Inform", "ptr", $Handle[0], "int", $i, "int", 0) MsgBox(0, "Inform with Complete=false", $Inform[0]) ;Inform with Complete=true DllCall($DLL, "wstr", "MediaInfoList_Option", "ptr", 0, "wstr", "Complete", "wstr", "1") $Inform=DllCall($DLL, "wstr", "MediaInfoList_Inform", "ptr", $Handle[0], "int", $i, "int", 0) MsgBox(0, "Inform with Complete=true", $Inform[0]) ;Custom Inform DllCall($DLL, "wstr", "MediaInfoList_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;Example : FileSize=%FileSize%") $Inform=DllCall($DLL, "wstr", "MediaInfoList_Inform", "ptr", $Handle[0], "int", $i, "int", 0) MsgBox(0, "Custom Inform", $Inform[0]) ;Get with Stream=General and Parameter=FileSize $Info_Get=DllCall($DLL, "wstr", "MediaInfoList_Get", "ptr", $Handle[0], "int", $i, "int", 0, "int", 0, "wstr", "FileSize", "int", 1, "int", 0) MsgBox(0, "Get with Stream=General and Parameter=FileSize", $Info_Get[0]) ;GetI with Stream=General and Parameter=46 $Info_GetI=DllCall($DLL, "wstr", "MediaInfoList_GetI", "ptr", $Handle[0], "int", $i, "int", 0, "int", 0, "int", 46, "int", 1) MsgBox(0, "Get with Stream=General and Parameter=46", $Info_GetI[0]) ;Count_Get with StreamKind=Stream_Audio $Count_Get=DllCall($DLL, "int", "MediaInfoList_Count_Get", "ptr", $Handle[0], "int", $i, "int", 2, "int", 0) MsgBox(0, "Count_Get with StreamKind=Stream_Audio", $Count_Get[0]) ;Get with Stream=General and Parameter=AudioCount $Info_Get=DllCall($DLL, "wstr", "MediaInfoList_Get", "ptr", $Handle[0], "int", $i, "int", 0, "int", 0, "wstr", "AudioCount", "int", 1, "int", 0) MsgBox(0, "Get with Stream=General and Parameter=AudioCount", $Info_Get[0]) ;Get with Stream=Audio and Parameter=StreamCount $Info_Get=DllCall($DLL, "wstr", "MediaInfoList_Get", "ptr", $Handle[0], "int", $i, "int", 2, "int", 0, "wstr", "StreamCount", "int", 1, "int", 0) MsgBox(0, "Get with Stream=Audio and Parameter=StreamCount", $Info_Get[0]) Next ;Delete MediaInfoList handle $Handle=DllCall($DLL, "none", "MediaInfoList_Delete", "ptr", $Handle[0]) ;Close the DLL DllClose($dll) MediaInfoLib/Source/Example/HowToUse_Dll.JNative.java0000664000000000000000000000472012652076434021421 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ class HowToUse_Dll { public static void main(String... args) throws Exception { String File_Name = "Example.ogg"; if (args.length > 0) File_Name = args[0]; String To_Display = ""; //Info about the library To_Display += MediaInfo.Option_Static("Info_Version"); To_Display += "\r\n\r\nInfo_Parameters\r\n"; To_Display += MediaInfo.Option_Static("Info_Parameters"); To_Display += "\r\n\r\nInfo_Capacities\r\n"; To_Display += MediaInfo.Option_Static("Info_Capacities"); To_Display += "\r\n\r\nInfo_Codecs\r\n"; To_Display += MediaInfo.Option_Static("Info_Codecs"); //An example of how to use the library MediaInfo MI = new MediaInfo(); To_Display += "\r\n\r\nOpen\r\n"; if (MI.Open(File_Name)>0) To_Display+="is OK\r\n"; else To_Display+="has a problem\r\n"; To_Display += "\r\n\r\nInform with Complete=false\r\n"; MI.Option("Complete", ""); To_Display += MI.Inform(); To_Display += "\r\n\r\nInform with Complete=true\r\n"; MI.Option("Complete", "1"); To_Display += MI.Inform(); To_Display += "\r\n\r\nCustom Inform\r\n"; MI.Option("Inform", "General;Example : FileSize=%FileSize%"); To_Display += MI.Inform(); To_Display += "\r\n\r\nGetI with Stream=General and Parameter=2\r\n"; To_Display += MI.Get(MediaInfo.Stream_General, 0, 2, MediaInfo.Info_Text); To_Display += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n"; To_Display += MI.Count_Get(MediaInfo.Stream_Audio, -1); To_Display += "\r\n\r\nGet with Stream=General and Parameter=\"AudioCount\"\r\n"; To_Display += MI.Get(MediaInfo.Stream_General, 0, "AudioCount", MediaInfo.Info_Text, MediaInfo.Info_Name); To_Display += "\r\n\r\nGet with Stream=Audio and Parameter=\"StreamCount\"\r\n"; To_Display += MI.Get(MediaInfo.Stream_Audio, 0, "StreamCount", MediaInfo.Info_Text, MediaInfo.Info_Name); To_Display += "\r\n\r\nGet with Stream=General and Parameter=\"FileSize\"\r\n"; To_Display += MI.Get(MediaInfo.Stream_General, 0, "FileSize", MediaInfo.Info_Text, MediaInfo.Info_Name); To_Display += "\r\n\r\nClose\r\n"; MI.Close(); System.out.println(To_Display); } } MediaInfoLib/Source/Example/HowToUse_Dll.JNA.java0000664000000000000000000002665712652076434020506 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ // Example with the possibilty to call MediaInfo library with: // - a file name // - a buffer // - data is from a RandomAccessFile object (local file) // - data is from a FileUrl object (an URL, HTTP or HTTPS) // - without authentication // - with Amazon S3 authentication (input format is in the form "https://AWSAccessKeyId:AWSSecretAccessKey@s3.amazonaws.com/bucketname/filename" // For "By buffer" interface, example from a file import java.io.RandomAccessFile; // For "By buffer" interface, example from an URL import java.net.URL; import java.net.HttpURLConnection; import java.io.InputStream; // For "By buffer" interface, example from an URL and with Amazon S3 authentication import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.security.SignatureException; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import javax.xml.bind.DatatypeConverter; class HowToUse_Dll { public static void main(String... args) throws Exception { String FileName = "Example.ogg"; if (args.length > 0) FileName = args[0]; //Comment this line and uncomment the next one if you would like to test the "by buffer" interface if (false) //if (true) { if (FileName.startsWith("http://") || FileName.startsWith("https://")) ByBuffer_URL (FileName); else ByBuffer_LocalFile (FileName); } else ByFileName (FileName); } private static void ByFileName(String FileName) throws Exception { String To_Display = ""; //Info about the library To_Display += MediaInfo.Option_Static("Info_Version"); To_Display += "\r\n\r\nInfo_Parameters\r\n"; To_Display += MediaInfo.Option_Static("Info_Parameters"); To_Display += "\r\n\r\nInfo_Capacities\r\n"; To_Display += MediaInfo.Option_Static("Info_Capacities"); To_Display += "\r\n\r\nInfo_Codecs\r\n"; To_Display += MediaInfo.Option_Static("Info_Codecs"); //An example of how to use the library MediaInfo MI = new MediaInfo(); To_Display += "\r\n\r\nOpen\r\n"; if (MI.Open(FileName)>0) To_Display+="is OK\r\n"; else To_Display+="has a problem\r\n"; To_Display += "\r\n\r\nInform with Complete=false\r\n"; MI.Option("Complete", ""); To_Display += MI.Inform(); To_Display += "\r\n\r\nInform with Complete=true\r\n"; MI.Option("Complete", "1"); To_Display += MI.Inform(); To_Display += "\r\n\r\nCustom Inform\r\n"; MI.Option("Inform", "General;Example : FileSize=%FileSize%"); To_Display += MI.Inform(); To_Display += "\r\n\r\nGetI with Stream=General and Parameter=2\r\n"; To_Display += MI.Get(MediaInfo.StreamKind.General, 0, 2, MediaInfo.InfoKind.Text); To_Display += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n"; To_Display += MI.Count_Get(MediaInfo.StreamKind.Audio, -1); To_Display += "\r\n\r\nGet with Stream=General and Parameter=\"AudioCount\"\r\n"; To_Display += MI.Get(MediaInfo.StreamKind.General, 0, "AudioCount", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); To_Display += "\r\n\r\nGet with Stream=Audio and Parameter=\"StreamCount\"\r\n"; To_Display += MI.Get(MediaInfo.StreamKind.Audio, 0, "StreamCount", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); To_Display += "\r\n\r\nGet with Stream=General and Parameter=\"FileSize\"\r\n"; To_Display += MI.Get(MediaInfo.StreamKind.General, 0, "FileSize", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); To_Display += "\r\n\r\nClose\r\n"; MI.Close(); System.out.println(To_Display); } private static void ByBuffer_LocalFile(String FileName) throws Exception { FileName=FileName.replace(" ", "%20"); //Initializing MediaInfo MediaInfo MI = new MediaInfo(); //From: preparing an example file for reading RandomAccessFile From = new RandomAccessFile(FileName, "r"); //From file //From: preparing a memory buffer for reading byte[] From_Buffer = new byte[64*1024]; int From_Buffer_Size; //The size of the read file buffer //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(From.length(), 0); //The parsing loop do { //Reading data somewhere, do what you want for this. From_Buffer_Size = From.read(From_Buffer); //Sending the buffer to MediaInfo int Result = MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size); if ((Result & 8) == 8) // Status.Finalized break; //Testing if MediaInfo request to go elsewhere if (MI.Open_Buffer_Continue_GoTo_Get() != -1) { long newPos = MI.Open_Buffer_Continue_GoTo_Get(); From.seek(newPos); //Position the file MI.Open_Buffer_Init(From.length(), newPos); //Informing MediaInfo we have seek } } while (From_Buffer_Size > 0); //Finalizing MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work //Get() example String To_Display = new String(); To_Display += "Get with Stream=General and Parameter=\"Format\": "; To_Display += MI.Get(MediaInfo.StreamKind.General, 0, "Format", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); To_Display += "\r\n"; To_Display += "Get with Stream=Video and Parameter=\"Format_Settings_GOP\": "; To_Display += MI.Get(MediaInfo.StreamKind.Video, 0, "Format_Settings_GOP", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); System.out.println(To_Display); } private static void ByBuffer_URL(String FileName) throws Exception { String Amazon_S3_Date = new String(); // Amazon only String Amazon_S3_Authorization = new String(); // Amazon only // Parsing user input FileName = FileName.replace(" ", "%20"); int FileName_Amazon_S3_End = FileName.indexOf("@s3.amazonaws.com/"); //Testing if Amazon is used and a AccessKeyId/SecretAccessKey is provided, TODO: use a less ugly method if (FileName_Amazon_S3_End != -1) { // Amazon only, computing the Authorization value // See http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html int FileName_Amazon_S3_Begin = FileName.indexOf("://") + 3; int FileName_Amazon_S3_Middle = FileName.indexOf(":", FileName_Amazon_S3_Begin); String Amazon_S3_AWSAccessKeyId = FileName.substring(FileName_Amazon_S3_Begin, FileName_Amazon_S3_Middle); String Amazon_S3_AWSSecretAccessKey = FileName.substring(FileName_Amazon_S3_Middle + 1, FileName_Amazon_S3_End); FileName = FileName.replace(FileName.substring(FileName_Amazon_S3_Begin, FileName_Amazon_S3_End + 1), new String()); Amazon_S3_Date = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(new Date()); String Amazon_S3_ToSign = "GET\n\n\n"+Amazon_S3_Date+"\n"+new URL(FileName).getPath(); Amazon_S3_Authorization = "AWS "+Amazon_S3_AWSAccessKeyId+":"+calculateHmacSHA1(Amazon_S3_ToSign, Amazon_S3_AWSSecretAccessKey); } URL FileUrl = new URL(FileName); //From: preparing an example file for reading HttpURLConnection HttpFrom = (HttpURLConnection ) FileUrl.openConnection(); if (!Amazon_S3_Authorization.isEmpty()) { HttpFrom.setRequestProperty("Date", Amazon_S3_Date); // Amazon only HttpFrom.setRequestProperty("Authorization", Amazon_S3_Authorization); // Amazon only } HttpFrom.connect(); if (HttpFrom.getResponseCode() != 200) { java.util.Scanner S = new java.util.Scanner(HttpFrom.getErrorStream()); S.useDelimiter("\\Z"); System.out.println(S.next()); return; } InputStream From = HttpFrom.getInputStream(); long From_Length = Long.parseLong(HttpFrom.getHeaderField("Content-Length")); //.getContentLengthLong(), for 2GB+ file support is available only in Java 7 and lot of distros have Java 6 //From: preparing a memory buffer for reading byte[] From_Buffer = new byte[64*1024]; int From_Buffer_Size; //The size of the read file buffer //Initializing MediaInfo MediaInfo MI = new MediaInfo(); //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(From_Length, 0); //The parsing loop do { //Reading data somewhere, do what you want for this. From_Buffer_Size = From.read(From_Buffer); //Sending the buffer to MediaInfo int Result = MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size); if ((Result & 8) == 8) // Status.Finalized break; //Testing if MediaInfo request to go elsewhere if (MI.Open_Buffer_Continue_GoTo_Get() != -1) { long newPos = MI.Open_Buffer_Continue_GoTo_Get(); From.close(); HttpFrom.disconnect(); HttpFrom = (HttpURLConnection ) FileUrl.openConnection(); if (!Amazon_S3_Authorization.isEmpty()) { HttpFrom.setRequestProperty("Date", Amazon_S3_Date); // Amazon only HttpFrom.setRequestProperty("Authorization", Amazon_S3_Authorization); // Amazon only } HttpFrom.setRequestProperty("Range", "bytes=" + newPos + "-"); HttpFrom.connect(); if (HttpFrom.getResponseCode() != 206) { java.util.Scanner S = new java.util.Scanner(HttpFrom.getErrorStream()); S.useDelimiter("\\Z"); System.out.println(S.next()); return; } From = HttpFrom.getInputStream(); MI.Open_Buffer_Init(From_Length, newPos); //Informing MediaInfo we have seek, TODO: take newPos from HTTP Content-Range value } } while (From_Buffer_Size > 0); //Finalizing MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finish some work //Get() example String To_Display = new String(); To_Display += "Get with Stream=General and Parameter=\"Format\": "; To_Display += MI.Get(MediaInfo.StreamKind.General, 0, "Format", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); To_Display += "\r\n"; To_Display += "Get with Stream=Video and Parameter=\"Format_Settings_GOP\": "; To_Display += MI.Get(MediaInfo.StreamKind.Video, 0, "Format_Settings_GOP", MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name); System.out.println(To_Display); } /** * Computes HMAC signature. * @param data The data to be signed. * @param secretKey The signing secret key. * @return The Base64-encoded HMAC signature. * @throws java.security.SignatureException when signature generation fails */ private static String calculateHmacSHA1(String data, String secretKey) throws java.security.SignatureException { String Result; try { Mac mac = Mac.getInstance("HmacSHA1"); // Create an HMAC instance mac.init(new SecretKeySpec(secretKey.getBytes(), "HmacSHA1")); // Initialize the HMAC instance with the secret key Result = DatatypeConverter.printBase64Binary(mac.doFinal(data.getBytes())); } catch (Exception e) { throw new SignatureException(e.getMessage()); } return Result; } } MediaInfoLib/Source/Example/HowToUse.cpp0000664000000000000000000000563212652076434017133 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Example for MediaInfoLib // Command line version // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include #include #include "ZenLib/Ztring.h" //Note : I need it for universal atoi, but you have not to use it for be able to use MediaInfoLib #include "MediaInfo/MediaInfo.h" using namespace MediaInfoLib; using namespace ZenLib; int main (int argc, char *argv[]) { //Information about MediaInfo MediaInfo MI; ZenLib::Ztring To_Display=MI.Option(__T("Info_Version"), __T("0.7.0.0;MediaInfoDLL_Example_MSVC;0.7.0.0")).c_str(); To_Display += __T("\r\n\r\nInfo_Parameters\r\n"); To_Display += MI.Option(__T("Info_Parameters")).c_str(); To_Display += __T("\r\n\r\nInfo_Capacities\r\n"); To_Display += MI.Option(__T("Info_Capacities")).c_str(); To_Display += __T("\r\n\r\nInfo_Codecs\r\n"); To_Display += MI.Option(__T("Info_Codecs")).c_str(); //An example of how to use the library To_Display += __T("\r\n\r\nOpen\r\n"); MI.Open(__T("Example.ogg")); To_Display += __T("\r\n\r\nInform with Complete=false\r\n"); MI.Option(__T("Complete")); To_Display += MI.Inform().c_str(); To_Display += __T("\r\n\r\nInform with Complete=true\r\n"); MI.Option(__T("Complete"), __T("1")); To_Display += MI.Inform().c_str(); To_Display += __T("\r\n\r\nCustom Inform\r\n"); MI.Option(__T("Inform"), __T("General;Example : FileSize=%FileSize%")); To_Display += MI.Inform().c_str(); To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"FileSize\"\r\n"); To_Display += MI.Get(Stream_General, 0, __T("FileSize"), Info_Text, Info_Name).c_str(); To_Display += __T("\r\n\r\nGetI with Stream=General and Parameter=46\r\n"); To_Display += MI.Get(Stream_General, 0, 46, Info_Text).c_str(); To_Display += __T("\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n"); To_Display += ZenLib::Ztring::ToZtring(MI.Count_Get(Stream_Audio, -1)); //Warning : this is an integer To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"AudioCount\"\r\n"); To_Display += MI.Get(Stream_General, 0, __T("AudioCount"), Info_Text, Info_Name).c_str(); To_Display += __T("\r\n\r\nGet with Stream=Audio and Parameter=\"StreamCount\"\r\n"); To_Display += MI.Get(Stream_Audio, 0, __T("StreamCount"), Info_Text, Info_Name).c_str(); To_Display += __T("\r\n\r\nClose\r\n"); MI.Close(); std::cout< #include using namespace MediaInfoNameSpace; #ifdef __MINGW32__ #ifdef _UNICODE #define _itot _itow #else //_UNICODE #define _itot itoa #endif //_UNICODE #endif //__MINGW32 int main (int /*argc*/, Char * /*argv[]*/) { //Information about MediaInfo MediaInfo MI; String To_Display=MI.Option(__T("Info_Version"), __T("0.7.13;MediaInfoDLL_Example_MSVC;0.7.13")).c_str(); To_Display += __T("\r\n\r\nInfo_Parameters\r\n"); To_Display += MI.Option(__T("Info_Parameters")).c_str(); To_Display += __T("\r\n\r\nInfo_Codecs\r\n"); To_Display += MI.Option(__T("Info_Codecs")).c_str(); //An example of how to use the library To_Display += __T("\r\n\r\nOpen\r\n"); MI.Open(__T("Example.ogg")); To_Display += __T("\r\n\r\nInform with Complete=false\r\n"); MI.Option(__T("Complete")); To_Display += MI.Inform().c_str(); To_Display += __T("\r\n\r\nInform with Complete=true\r\n"); MI.Option(__T("Complete"), __T("1")); To_Display += MI.Inform().c_str(); To_Display += __T("\r\n\r\nCustom Inform\r\n"); MI.Option(__T("Inform"), __T("General;Example : FileSize=%FileSize%")); To_Display += MI.Inform().c_str(); To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"FileSize\"\r\n"); To_Display += MI.Get(Stream_General, 0, __T("FileSize"), Info_Text, Info_Name).c_str(); To_Display += __T("\r\n\r\nGetI with Stream=General and Parameter=46\r\n"); To_Display += MI.Get(Stream_General, 0, 46, Info_Text).c_str(); To_Display += __T("\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n"); #ifdef __MINGW32__ Char* C1=new Char[33]; _itot (MI.Count_Get(Stream_Audio), C1, 10); To_Display +=C1; delete[] C1; #else toStringStream SS; SS << std::setbase(10) << MI.Count_Get(Stream_Audio); To_Display += SS.str(); #endif To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"AudioCount\"\r\n"); To_Display += MI.Get(Stream_General, 0, __T("AudioCount"), Info_Text, Info_Name).c_str(); To_Display += __T("\r\n\r\nGet with Stream=Audio and Parameter=\"StreamCount\"\r\n"); To_Display += MI.Get(Stream_Audio, 0, __T("StreamCount"), Info_Text, Info_Name).c_str(); To_Display += __T("\r\n\r\nClose\r\n"); MI.Close(); #ifdef _UNICODE std::wcout << To_Display; #else std::cout << To_Display; #endif return 0; } //*************************************************************************** // By buffer example //*************************************************************************** /* //--------------------------------------------------------------------------- //Note: you can replace file operations by your own buffer management class #include int main (int argc, Char *argv[]) { //From: preparing an example file for reading FILE* F=fopen("Example.ogg", "rb"); //You can use something else than a file if (F==0) return 1; //From: preparing a memory buffer for reading unsigned char* From_Buffer=new unsigned char[7*188]; //Note: you can do your own buffer size_t From_Buffer_Size; //The size of the read file buffer //From: retrieving file size fseek(F, 0, SEEK_END); long F_Size=ftell(F); fseek(F, 0, SEEK_SET); //Initializing MediaInfo MediaInfo MI; //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(F_Size, 0); //The parsing loop do { //Reading data somewhere, do what you want for this. From_Buffer_Size=fread(From_Buffer, 1, 7*188, F); //Sending the buffer to MediaInfo size_t Status=MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size); if (Status&0x08) //Bit3=Finished break; //Testing if there is a MediaInfo request to go elsewhere if (MI.Open_Buffer_Continue_GoTo_Get()!=(MediaInfo_int64u)-1) { fseek(F, (long)MI.Open_Buffer_Continue_GoTo_Get(), SEEK_SET); //Position the file MI.Open_Buffer_Init(F_Size, ftell(F)); //Informing MediaInfo we have seek } } while (From_Buffer_Size>0); //Finalizing MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work //Get() example String To_Display=MI.Get(Stream_General, 0, __T("Format")); #ifdef _UNICODE std::wcout << To_Display; #else std::cout << To_Display; #endif } */ MediaInfoLib/Source/Example/HowToUse_Dll3.py0000664000000000000000000000423512652076434017655 0ustar rootroot## Copyright (c) MediaArea.net SARL. All Rights Reserved. # # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. ## #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # Python example # # To make this example working, you must put MediaInfo.Dll, MediaInfoDLL.py # and example.ogg in the same folder # # HowToUse_Dll.py and HowToUse_Dll3.py are same # MediaInfoDLL.py and MediaInfoDLL3.py are same # but all files are kept in order to not break programs calling them. # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ from MediaInfoDLL3 import * MI = MediaInfo() Version=MI.Option_Static("Info_Version", "0.7.7.0;MediaInfoDLL_Example_Python;0.7.7.0") if Version=="": print("MediaInfo.Dll: this version of the DLL is not compatible") exit #Information about MediaInfo print("Info_Parameters") MI.Option_Static("Info_Parameters") print("") print("Info_Capacities") print(MI.Option_Static("Info_Capacities")) print("") print("Info_Codecs") print(MI.Option_Static("Info_Codecs")) #An example of how to use the library print("") print("Open") MI.Open("Example.ogg") print("") print("Inform with Complete=false") MI.Option_Static("Complete") print(MI.Inform()) print("") print("Inform with Complete=true") MI.Option_Static("Complete", "1") print(MI.Inform()) print("") print("Custom Inform") MI.Option_Static("Inform", "General;Example : FileSize=%FileSize%") print(MI.Inform()) print("") print("Get with Stream=General and Parameter='FileSize'") print(MI.Get(Stream.General, 0, "FileSize")) print("") print("GetI with Stream=General and Parameter=46") print(MI.GetI(Stream.General, 0, 46)) print("") print("Count_Get with StreamKind=Stream_Audio") print(MI.Count_Get(Stream.Audio)) print("") print("Get with Stream=General and Parameter='AudioCount'") print(MI.Get(Stream.General, 0, "AudioCount")) print("") print("Get with Stream=Audio and Parameter='StreamCount'") print(MI.Get(Stream.Audio, 0, "StreamCount")) print("") print("Close") MI.Close() MediaInfoLib/ToDo.txt0000664000000000000000000000027312652076434013461 0ustar rootrootDV in MOV handling DV MPEG-4V false positive MPEG-4, Cover MPEG-4, in one example (vobsub.mp4), framerate is 1 fps, wrong Language change: General --> Container Text --> SubtitleMediaInfoLib/.travis.yml0000664000000000000000000000110412652076434014156 0ustar rootrootsudo: required language: cpp compiler: gcc before_install: - sudo apt-get update -qq - sudo apt-get install -y libcurl4-gnutls-dev libmms-dev libglib2.0-dev zlib1g-dev pkg-config - wget http://mediaarea.net/download/binary/libzen0/0.4.32/libzen0_0.4.32-1_amd64.xUbuntu_12.04.deb - sudo dpkg -i libzen0_0.4.32-1_amd64.xUbuntu_12.04.deb - wget http://mediaarea.net/download/binary/libzen0/0.4.32/libzen-dev_0.4.32-1_amd64.xUbuntu_12.04.deb - sudo dpkg -i libzen-dev_0.4.32-1_amd64.xUbuntu_12.04.deb script: cd Project/GNU/Library/ && ./autogen.sh && ./configure && make MediaInfoLib/License.html0000664000000000000000000001042012652076434014316 0ustar rootroot MediaInfo(Lib) License

MediaInfo(Lib) License

Copyright (c) 2002-2015 MediaArea.net SARL. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Alternate license for redistributions of the library in binary form:
Redistributions in binary form must reproduce the following sentence (including the link to the website) in the documentation and/or other materials provided with the distribution.
This product uses MediaInfo library, Copyright (c) 2002-2015 MediaArea.net SARL.


Third party libraries

The software relies on third party libraries. Such libraries have their own license:


Contributors

  • Jérôme Martinez (main developper)
  • Lionel Duchateau (odd formats support)
  • XhmikosR from MPC-HC Team (tests)
  • FlylinkDC++ team (tests, crash corrections)
  • Max Pozdeev (former native Mac GUI developper)
MediaInfoLib/Release/0000775000000000000000000000000012652076434013431 5ustar rootrootMediaInfoLib/Release/Release_DLL_Linux_x64.sh0000664000000000000000000000071112652076434017717 0ustar rootroot## Copyright (c) MediaArea.net SARL. All Rights Reserved. # # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. ## #! /bin/sh #----------------------------------------------------------------------- # Default script . ./Release_DLL_GNU.sub #----------------------------------------------------------------------- # Launch Release_DLL Linux x64 so so.0 so.0.0.0 MediaInfoLib/Release/Release_Source.bat0000664000000000000000000002044112652076434017022 0ustar rootroot@rem Copyright (c) MediaArea.net SARL. All Rights Reserved. @rem @rem Use of this source code is governed by a BSD-style license that can @rem be found in the License.html file in the root of the source tree. @rem @echo off rem --- Clean up --- del MediaInfo_Lib_Source.tar del libmediainfo_.tar.bz2 del libmediainfo_-1.tar.gz del libmediainfo__AllInclusive.7z rmdir MediaInfo_Lib_Source /S /Q rmdir ZenLib /S /Q rmdir zlib /S /Q mkdir MediaInfo_Lib_Source @rem --- Copying : debian --- xcopy ..\debian\* MediaInfo_Lib_Source\debian\ /S @rem --- Copying : Sources --- xcopy ..\Source\*.c MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.cpp MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.h MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.rc MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.def MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.pas MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.cs MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.aspx MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.config MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.jsl MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.vb MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.java MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\Resource\*.txt MediaInfo_Lib_Source\Source\Resource\ /S xcopy ..\Source\*.csv MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.dfm MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.au3 MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.pb MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\*.py MediaInfo_Lib_Source\Source\ /S xcopy ..\Source\Doc\* MediaInfo_Lib_Source\Source\Doc\ /S xcopy ..\Source\Install\*.nsi MediaInfo_Lib_Source\Source\Install\ @rem --- Copying : Projects --- xcopy ..\Project\*.bpg MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.bpf MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.bpr MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.dfm MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.cpp MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.bdsgroup MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.bdsproj MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.groupproj MediaInfo_Lib_Source\Project\ /S /Y xcopy ..\Project\*.cbproj MediaInfo_Lib_Source\Project\ /S /Y xcopy ..\Project\*.dpr MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.pas MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.dof MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.dev MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.sln MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.cs MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.csproj MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.jsl MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vjsproj MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vbproj MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vb MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vc MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vcproj MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vcxproj MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.vcxproj.filters MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.ico MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.workspace MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.cbp MediaInfo_Lib_Source\Project\ /S /Y xcopy ..\Project\*.resx MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.rc MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.def MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\*.idl MediaInfo_Lib_Source\Project\ /S xcopy ..\Project\BCB\*.h MediaInfo_Lib_Source\Project\BCB\ /S xcopy ..\Project\CMake\* MediaInfo_Lib_Source\Project\CMake\ /S xcopy ..\Project\MSVC2013\*.h MediaInfo_Lib_Source\Project\MSVC2013\ /S xcopy ..\Project\MSVC2012\*.h MediaInfo_Lib_Source\Project\MSVC2012\ /S xcopy ..\Project\MSVC2010\*.h MediaInfo_Lib_Source\Project\MSVC2010\ /S xcopy ..\Project\MSVC2008\*.h MediaInfo_Lib_Source\Project\MSVC2008\ /S xcopy ..\Project\MSVC2005\*.h MediaInfo_Lib_Source\Project\MSVC2005\ /S xcopy ..\Project\MSCS\*.aspx MediaInfo_Lib_Source\Project\MSCS2010\ /S xcopy ..\Project\MSCS\*.config MediaInfo_Lib_Source\Project\MSCS2010\ /S xcopy ..\Project\BCB\*.res MediaInfo_Lib_Source\Project\BCB /S xcopy ..\Project\Delphi\*.res MediaInfo_Lib_Source\Project\Delphi /S xcopy ..\Project\MSVB\*.rc MediaInfo_Lib_Source\Project\MSVB\ /S xcopy "..\Project\MSVB\Example\My Project\*.*" "MediaInfo_Lib_Source\Project\MSVB\Example\My Project\" /Y xcopy "..\Project\MSVB\Example VB6\*.*" "MediaInfo_Lib_Source\Project\MSVB\Example VB6\" /Y xcopy ..\Project\GNU\* MediaInfo_Lib_Source\Project\GNU\ /S xcopy ..\Project\Java\Example.JNA\*.bat MediaInfo_Lib_Source\Project\Java\Example.JNA\ /S xcopy ..\Project\Java\Example.JNA\*.sh MediaInfo_Lib_Source\Project\Java\Example.JNA\ /S xcopy ..\Project\Java\Example.JNA\*.java MediaInfo_Lib_Source\Project\Java\Example.JNA\ /S xcopy ..\Project\Java\Example.JNA\*.txt MediaInfo_Lib_Source\Project\Java\Example.JNA\ /S xcopy ..\Project\Java\Example.JNative\*.bat MediaInfo_Lib_Source\Project\Java\Example.JNative\ /S xcopy ..\Project\Java\Example.JNative\*.sh MediaInfo_Lib_Source\Project\Java\Example.JNative\ /S xcopy ..\Project\Java\Example.JNative\*.java MediaInfo_Lib_Source\Project\Java\Example.JNative\ /S xcopy ..\Project\Java\Example.JNative\*.txt MediaInfo_Lib_Source\Project\Java\Example.JNative\ /S xcopy ..\Project\NetBeans\Example.JNA\*.xml MediaInfo_Lib_Source\Project\NetBeans\Example.JNA\ /s xcopy ..\Project\NetBeans\Example.JNA\*.properties MediaInfo_Lib_Source\Project\NetBeans\Example.JNA\ /s xcopy ..\Project\NetBeans\Example.JNA\*.mf MediaInfo_Lib_Source\Project\NetBeans\Example.JNA\ xcopy ..\Project\NetBeans\Example.JNA\*.txt MediaInfo_Lib_Source\Project\NetBeans\Example.JNA\ xcopy ..\Project\NetBeans\Example.JNA\src\*.java MediaInfo_Lib_Source\Project\NetBeans\Example.JNA\src\ xcopy ..\Project\NetBeans\Example.JNative\*.xml MediaInfo_Lib_Source\Project\NetBeans\Example.JNative\ /s xcopy ..\Project\NetBeans\Example.JNative\*.properties MediaInfo_Lib_Source\Project\NetBeans\Example.JNative\ /s xcopy ..\Project\NetBeans\Example.JNative\*.mf MediaInfo_Lib_Source\Project\NetBeans\Example.JNative\ xcopy ..\Project\NetBeans\Example.JNative\*.txt MediaInfo_Lib_Source\Project\NetBeans\Example.JNative\ xcopy ..\Project\NetBeans\Example.JNative\src\*.java MediaInfo_Lib_Source\Project\NetBeans\Example.JNative\src\ xcopy ..\Project\Solaris\* MediaInfo_Lib_Source\Project\Solaris\ /S @rem --- Copying : Release --- xcopy *.txt MediaInfo_Lib_Source\Release\ xcopy *.bat MediaInfo_Lib_Source\Release\ xcopy *.ogg MediaInfo_Lib_Source\Release\ xcopy *.sh MediaInfo_Lib_Source\Release\ xcopy *.sub MediaInfo_Lib_Source\Release\ xcopy BCB\*.txt MediaInfo_Lib_Source\Release\BCB\ /S xcopy MSVC2010\*.txt MediaInfo_Lib_Source\Release\MSVC2010\ /S xcopy GCC_MinGW32\*.txt MediaInfo_Lib_Source\Release\GCC_MinGW32\ /S xcopy GCC_Linux_i386\*.txt MediaInfo_Lib_Source\Release\GCC_Linux_i386\ /S @rem --- Copying : Contrib --- xcopy ..\Contrib\* MediaInfo_Lib_Source\Contrib\ /S rem --- Copying : Information files --- copy ..\*.txt MediaInfo_Lib_Source\ copy ..\*.html MediaInfo_Lib_Source\ rem --- Copying : CVS files --- copy ..\*.cvsignore MediaInfo_Lib_Source\ rem --- Copying : ZenLib files --- cd ..\..\ZenLib\Release call Release_Source.bat SkipCleanUp SkipCompression cd ..\..\MediaInfoLib\Release move ..\..\ZenLib\Release\ZenLib_Source .\ZenLib rem --- Copying : zlib files --- xcopy ..\..\Shared\Source\zlib .\zlib\ /S xcopy ..\..\Shared\Project\zlib\Template .\zlib\ /S rem --- Compressing Archive --- if "%2"=="SkipCompression" goto SkipCompression move MediaInfo_Lib_Source MediaInfoLib ..\..\Shared\Binary\Windows_i386\7-zip\7z a -r -ttar -mx9 MediaInfo_Lib_Source.tar MediaInfoLib\* ..\..\Shared\Binary\Windows_i386\7-zip\7z a -r -tbzip2 -mx9 libmediainfo_.tar.bz2 MediaInfo_Lib_Source.tar ..\..\Shared\Binary\Windows_i386\7-zip\7z a -r -tgzip -mx9 libmediainfo_-1.tar.gz MediaInfo_Lib_Source.tar del MediaInfo_Lib_Source.tar ..\..\Shared\Binary\Windows_i386\7-zip\7z a -r -t7z -mx9 libmediainfo__AllInclusive.7z MediaInfoLib\* ZenLib\* zlib\* move MediaInfoLib MediaInfo_Lib_Source :SkipCompression rem --- Clean up --- if "%1"=="SkipCleanUp" goto SkipCleanUp rmdir MediaInfo_Lib_Source /S /Q :SkipCleanUp rmdir ZenLib /S /Q rmdir zlib /S /Q MediaInfoLib/Release/Release_Lib_GNU_FromSource.sh0000664000000000000000000001707512652076434021022 0ustar rootroot## Copyright (c) MediaArea.net SARL. All Rights Reserved. # # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. ## #! /bin/sh #----------------------------------------------------------------------- # Clean up test -e MediaInfo_Lib_GNU_FromSource.tar && rm MediaInfo_Lib_GNU_FromSource.tar test -e MediaInfo_Lib_GNU_FromSource.tar.bz2 && rm MediaInfo_Lib_GNU_FromSource.tar.bz2 test -d MediaInfo_Lib_GNU_FromSource && rm -r MediaInfo_Lib_GNU_FromSource mkdir MediaInfo_Lib_GNU_FromSource #----------------------------------------------------------------------- # Preparing : Project cd ../Project/GNU/Library chmod u+x autogen.sh ./autogen.sh cd ../../../Release #----------------------------------------------------------------------- # Copying : Project mkdir -p MediaInfo_Lib_GNU_FromSource/Project/GNU/Library cp ../Project/GNU/Library/aclocal.m4 MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/autogen.sh MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/config.guess MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/config.sub MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/configure MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/configure.ac MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/depcomp MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/install-sh MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/ltmain.sh MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/Makefile.am MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/Makefile.in MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/missing MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/libmediainfo.pc.in MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/libmediainfo-config.in MediaInfo_Lib_GNU_FromSource/Project/GNU/Library/ #----------------------------------------------------------------------- # Copying : Source mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/aes-gladman cp -r ../Source/ThirdParty/aes-gladman/*.asm MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/aes-gladman/ cp -r ../Source/ThirdParty/aes-gladman/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/aes-gladman/ cp -r ../Source/ThirdParty/aes-gladman/*.c MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/aes-gladman/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/base64 cp -r ../Source/ThirdParty/base64/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/base64/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/hmac-gladman cp -r ../Source/ThirdParty/hmac-gladman/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/hmac-gladman/ cp -r ../Source/ThirdParty/hmac-gladman/*.c MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/hmac-gladman/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/md5 cp -r ../Source/ThirdParty/md5/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/md5/ cp -r ../Source/ThirdParty/md5/*.c MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/md5/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/sha1-gladman cp -r ../Source/ThirdParty/sha1-gladman/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/sha1-gladman/ cp -r ../Source/ThirdParty/sha1-gladman/*.c MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/sha1-gladman/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/sha2-gladman cp -r ../Source/ThirdParty/sha2-gladman/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/sha2-gladman/ cp -r ../Source/ThirdParty/sha2-gladman/*.c MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/sha2-gladman/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/tinyxml2 cp -r ../Source/ThirdParty/tinyxml2/*.h MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/tinyxml2/ cp -r ../Source/ThirdParty/tinyxml2/*.cpp MediaInfo_Lib_GNU_FromSource/Source/ThirdParty/tinyxml2/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/MediaInfo cp -r ../Source/MediaInfo/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/ cp -r ../Source/MediaInfo/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Archive cp -r ../Source/MediaInfo/Archive/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Archive/ cp -r ../Source/MediaInfo/Archive/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Archive/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Audio cp -r ../Source/MediaInfo/Audio/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Audio/ cp -r ../Source/MediaInfo/Audio/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Audio/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Duplicate cp -r ../Source/MediaInfo/Duplicate/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Duplicate/ cp -r ../Source/MediaInfo/Duplicate/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Duplicate/ mkdir -p MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Export cp -r ../Source/MediaInfo/Export/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Export/ cp -r ../Source/MediaInfo/Export/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Export/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Image cp -r ../Source/MediaInfo/Image/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Image/ cp -r ../Source/MediaInfo/Image/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Image/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Reader cp -r ../Source/MediaInfo/Reader/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Reader/ cp -r ../Source/MediaInfo/Reader/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Reader/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Multiple cp -r ../Source/MediaInfo/Multiple/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Multiple/ cp -r ../Source/MediaInfo/Multiple/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Multiple/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Tag cp -r ../Source/MediaInfo/Tag/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Tag/ cp -r ../Source/MediaInfo/Tag/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Tag/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Text cp -r ../Source/MediaInfo/Text/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Text/ cp -r ../Source/MediaInfo/Text/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Text/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Video cp -r ../Source/MediaInfo/Video/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Video/ cp -r ../Source/MediaInfo/Video/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfo/Video/ mkdir MediaInfo_Lib_GNU_FromSource/Source/MediaInfoDLL cp -r ../Source/MediaInfoDLL/*.h MediaInfo_Lib_GNU_FromSource/Source/MediaInfoDLL/ cp -r ../Source/MediaInfoDLL/*.cpp MediaInfo_Lib_GNU_FromSource/Source/MediaInfoDLL/ #----------------------------------------------------------------------- # Copying : Information cp ../License.html MediaInfo_Lib_GNU_FromSource/ cp ../History_DLL.txt MediaInfo_Lib_GNU_FromSource/ cp ../Changes.txt MediaInfo_Lib_GNU_FromSource/ test -d MediaInfo_Lib_GNU_FromSource/Release || mkdir MediaInfo_Lib_GNU_FromSource/Release cp ReadMe_DLL_Linux.txt MediaInfo_Lib_GNU_FromSource/Release/ cp ReadMe_DLL_Mac.txt MediaInfo_Lib_GNU_FromSource/Release/ #----------------------------------------------------------------------- # Compressing Archive tar jchf MediaInfo_Lib_GNU_FromSource.tar.bz2 MediaInfo_Lib_GNU_FromSource/* #----------------------------------------------------------------------- # Clean up rm -r MediaInfo_Lib_GNU_FromSource MediaInfoLib/Release/CleanUp.bat0000664000000000000000000000605212652076434015453 0ustar rootroot@rem Copyright (c) MediaArea.net SARL. All Rights Reserved. @rem @rem Use of this source code is governed by a BSD-style license that can @rem be found in the License.html file in the root of the source tree. @rem @rem echo off @rem --- General --- cd .. del *.~* *.obj *.o *.tds *.dcu *.ddp *.opt *.ncb *.suo *.ilk *.idb *.pdb *.pch *.plg *.aps *.user *.win *.layout *.local *.depend *.identcache *.tgs *.tgw *.sdf /Q /S del *.~* *.obj *.o *.tds *.dcu *.ddp *.opt *.ncb *.suo *.ilk *.idb *.pdb *.pch *.plg *.aps *.user *.win *.layout *.local *.depend *.identcache *.tgs *.tgw *.sdf /AH /Q /S del *.ogg *.ogm *.avi *.mkv /Q /S del *.ogg *.ogm *.avi *.mkv /AH /Q /S cd Release @rem --- In Project files --- cd ..\Project del *.exe *.dll *.a *.lib *.exp *.class *.zip *.7z /Q /S del *.exe *.dll *.a *.lib *.exp *.class *.zip *.7z /AH /Q /S cd ..\Release @rem MS Visual Studio specific --- cd ..\Project rmdir MSCS\Example\bin /Q /S rmdir MSCS\Example\obj /Q /S rmdir MSJS\Example\bin /Q /S rmdir MSJS\Example\obj /Q /S rmdir MSVB\Example\bin /Q /S rmdir MSVB\Example\obj /Q /S rmdir MSVC\Dll\Release /Q /S rmdir MSVC\Dll\Release_Ansi /Q /S rmdir MSVC\Example\Release /Q /S rmdir MSVC\Example\Release_Ansi /Q /S rmdir MSVC\Library\Release /Q /S rmdir MSVC\Library\Release_Ansi /Q /S cd ..\Release @rem Borland Developper Studio specific --- cd ..\Source rmdir Example\__history /Q /S rmdir MediaInfo\__history /Q /S rmdir MediaInfo\Archive\__history /Q /S rmdir MediaInfo\Audio\__history /Q /S rmdir MediaInfo\Image\__history /Q /S rmdir MediaInfo\Multiple\__history /Q /S rmdir MediaInfo\Text\__history /Q /S rmdir MediaInfo\Video\__history /Q /S rmdir MediaInfoDLL\__history /Q /S rmdir PreRelease\__history /Q /S rmdir PreRelease\VCL\__history /Q /S rmdir PreRelease\WxWidgets\__history /Q /S cd ..\Release cd ..\Project rmdir BCB\__history /Q /S rmdir BCB\Dll\__history /Q /S rmdir BCB\Dll\Debug_Build /Q /S rmdir BCB\Dll\Release_Build /Q /S rmdir BCB\Example\__history /Q /S rmdir BCB\Example\Debug_Build /Q /S rmdir BCB\Example\Release_Build /Q /S rmdir BCB\Library\__history /Q /S rmdir BCB\Library\Debug_Build /Q /S rmdir BCB\Library\Release_Build /Q /S rmdir BCB\PreRelease\__history /Q /S rmdir BCB\PreRelease\Debug_Build /Q /S rmdir BCB\PreRelease\Release_Build /Q /S rmdir Delphi\__history /Q /S rmdir Delphi\Example\__history /Q /S rmdir Delphi\Example\ModelSupport /Q /S rmdir MSVC\DLL\Win32 /Q /S rmdir MSVC\DLL\x64 /Q /S rmdir MSVC\Example\Win32 /Q /S rmdir MSVC\Example\x64 /Q /S rmdir MSVC\Library\Win32 /Q /S rmdir MSVC\Library\x64 /Q /S cd ..\Release @rem Code::Blocks specific --- cd ..\Project rmdir CodeBlocks\Dll\.objs /Q /S rmdir CodeBlocks\Library\.objs /Q /S rmdir CodeBlocks\PreRelease\.objs /Q /S cd ..\Release @rem GCC specific --- cd ..\Project rmdir GCC\Example\.deps /Q /S rmdir GCC\Example\.objs /Q /S rmdir GCC\Library\.deps /Q /S rmdir GCC\Library\.objs /Q /S cd ..\Release @rem Release specific --- del *.zip *.gz *.bz2 *.lib *.dll *.exp *.a *.so *.7z /Q /S del MediaInfo*.exe MediaInfoLib/Release/PrepareSource.sh0000664000000000000000000001211612652076434016545 0ustar rootroot# MediaInfoLib/Release/PrepareSource.sh # Prepare the source of MediaInfoLib # Copyright (c) MediaArea.net SARL. All Rights Reserved. # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. function _get_source () { # Determine where are the sources of the project if [ $(b.opt.get_opt --source-path) ]; then MIL_source=$(sanitize_arg $(b.opt.get_opt --source-path)) else if [ $(b.opt.get_opt --repo-url) ]; then RepoURL=$(sanitize_arg $(b.opt.get_opt --repo-url)) else RepoURL="https://github.com/MediaArea/" fi getRepo MediaInfoLib $RepoURL $Path MIL_source=$Path/$Project fi # Dependency : ZenLib if [ $(b.opt.get_opt --repo-url) ]; then RepoURL=$(sanitize_arg $(b.opt.get_opt --repo-url)) else RepoURL="https://github.com/MediaArea/" fi echo getRepo ZenLib $RepoURL $Path ZL_source=$Path/ZenLib # Dependency : zlib echo getRepo zlib https://github.com/madler/ $Path zlib_source=$Path/zlib } function _linux_compil () { echo echo "Create the archive for compilation on Linux:" echo "1: copy what is wanted..." cd $Path mkdir MediaInfo_DLL_${Version}_GNU_FromSource cd MediaInfo_DLL_${Version}_GNU_FromSource cp -r $ZL_source . cp -r $MIL_source . mv MediaInfoLib/Project/GNU/Library/AddThisToRoot_DLL_compile.sh SO_Compile.sh # TODO: call the function who build a clean ZenLib compil archive mkdir -p Shared/Project/_Common cp -r $zlib_source Shared/Project #cp -r $curl_source Shared/Project echo "2: remove what isn't wanted..." cd MediaInfoLib rm -f .cvsignore .gitignore rm -fr .git rm -f ToDo.txt rm -f ReadMe.txt rm -fr debian cd Project rm -f GNU/libmediainfo.dsc GNU/libmediainfo.spec rm -fr Solaris rm -fr BCB CMake CodeBlocks Coverity Delphi Java NetBeans rm -fr MSCS2008 MSCS2010 MSJS MSVB MSVB2010 rm -fr MSVC2005 MSVC2008 MSVC2010 MSVC2012 MSVC2013 rm -fr PureBasic cd .. rm -fr Contrib rm -fr Release #cd Release # rm -f CleanUp.bat Example.ogg ReadMe_DLL_Windows.txt # rm -f Release_DLL_GNU_Prepare.bat Release_Lib_GNU_Prepare.bat # rm -f Release_DLL_Windows_i386.bat Release_DLL_Windows_x64.bat # rm -f Release_Source.bat UpgradeVersion.sh #cd .. cd Source rm -f Doc/setlocale.txt rm -fr Install rm -fr PreRelease rm -fr RegressionTest rm -fr Resource rm -f MediaInfoDLL/MediaInfoDLL.def rm -f MediaInfoDLL/MediaInfoDLL.jsl rm -f MediaInfoDLL/MediaInfoDLL.pas rm -f MediaInfoDLL/MediaInfoDLL.pb rm -f MediaInfoDLL/MediaInfoDLL.vb rm -f ThirdParty/aes-gladman/aes_amd64.asm rm -f ThirdParty/aes-gladman/aes.txt rm -f ThirdParty/aes-gladman/aes_x86_v1.asm rm -f ThirdParty/aes-gladman/aes_x86_v2.asm rm -f ThirdParty/aes-gladman/via_ace.txt cd .. cd .. if $MakeArchives; then echo "3: compressing..." cd $Path mkdir archives # To specify the compression level #$(/bin/tar -cf MediaInfo_Lib_Source.tar MediaInfoLib/) (GZIP=-9 tar -czf archives/MediaInfo_DLL_${Version}_GNU_FromSource.tgz MediaInfo_DLL_${Version}_GNU_FromSource) (BZIP=-9 tar -cjf archives/MediaInfo_DLL_${Version}_GNU_FromSource.tbz MediaInfo_DLL_${Version}_GNU_FromSource) (XZ_OPT=-9e tar -cJf archives/MediaInfo_DLL_${Version}_GNU_FromSource.txz MediaInfo_DLL_${Version}_GNU_FromSource) fi } function btask.PrepareSource.run () { Project=MediaInfoLib Path=/tmp/ma LinuxCompil=false if b.opt.has_flag? --linux-compil; then LinuxCompil=true fi WindowsCompil=false if b.opt.has_flag? --windows-compil; then WindowsCompil=true fi LinuxPackages=false if b.opt.has_flag? --linux-packages; then LinuxPackages=true fi AllTarget=false if b.opt.has_flag? --all; then AllTarget=true fi MakeArchives=true if b.opt.has_flag? --no-archives; then MakeArchives=false fi #CleanUp=true #if [ $(b.opt.get_opt --no-cleanup) ]; then # CleanUp=false #fi #mkdir $Path cd $Path rm -fr archives rm -fr MediaInfo_DLL_${Version}_GNU_FromSource if $LinuxCompil || $WindowsCompil || $LinuxPackages || $AllTarget; then _get_source else echo "Besides --project and --version, you must specify at least" echo "one of this options:" echo echo "--linux-compil|-lc" echo " Create the archive for compilation on Linux" echo echo "--windows-compil|-wc" echo " Create the archive for compilation on Windows" echo echo "--linux-packages|-lp|--linux-package" echo " Create the archive for Linux packages creation" echo echo "--all|-a" echo " Create all the targets for this project" fi if $LinuxCompil; then _linux_compil fi if $WindowsCompil; then echo _windows_compil fi if $LinuxPackages; then echo _linux_packages fi if $AllTarget; then _linux_compil echo _windows_compil echo _linux_packages fi #..\..\Shared\Binary\Windows_i386\7-zip\7z a -r -t7z -mx9 libmediainfo__AllInclusive.7z MediaInfoLib\* ZenLib\* zlib\* # unix (look the man): #7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1 # Clean up # TODO: ??? existing in Release_Source.bat but not in Release_Source.sh #unset -v MIL_files index MIL_source } MediaInfoLib/Release/Release_DLL_GNU.sub0000664000000000000000000000676012652076434016741 0ustar rootroot## Copyright (c) MediaArea.net SARL. All Rights Reserved. # # Use of this source code is governed by a BSD-style license that can # be found in the License.html file in the root of the source tree. ## #! /bin/sh #----------------------------------------------------------------------- # $1=OS, $2=Platform, $3=so name, $4=so.0 name, $5=so.0.0.0 name Release_DLL() { #----------------------------------------------------------------------- # Clean up test -e MediaInfo_DLL_$1_$2.tar && rm MediaInfo_DLL_$1_$2.tar test -e MediaInfo_DLL_$1_$2.tar.bz2 && rm MediaInfo_DLL_$1_$2.tar.bz2 test -d MediaInfo_DLL_$1_$2 && rm -r MediaInfo_DLL_$1_$2 mkdir MediaInfo_DLL_$1_$2 #----------------------------------------------------------------------- # Copying : so cp -R ../Project/GNU/Library/.libs/libmediainfo.$3 MediaInfo_DLL_$1_$2/ cp -R ../Project/GNU/Library/.libs/libmediainfo.$4 MediaInfo_DLL_$1_$2/ cp ../Project/GNU/Library/.libs/libmediainfo.$5 MediaInfo_DLL_$1_$2/ cd MediaInfo_DLL_$1_$2 strip libmediainfo.$3 cd .. #----------------------------------------------------------------------- # Copying : Information file cp ../License.html MediaInfo_DLL_$1_$2/ cp ../History_DLL.txt MediaInfo_DLL_$1_$2/History.txt cp ../Changes.txt MediaInfo_DLL_$1_$2/ cp ReadMe_DLL_$1.txt MediaInfo_DLL_$1_$2/ReadMe.txt #----------------------------------------------------------------------- # Copying : Developpers, Documentation cd ../Source/Doc doxygen cd ../../Release mkdir MediaInfo_DLL_$1_$2/Developpers cp ../Source/Doc/Documentation.html MediaInfo_DLL_$1_$2/Developpers/ mv ../Doc MediaInfo_DLL_$1_$2/Developpers/ #----------------------------------------------------------------------- # Copying : Developpers, Source mkdir -p MediaInfo_DLL_$1_$2/Developpers/Source/Example cp ../Source/Example/HowToUse* MediaInfo_DLL_$1_$2/Developpers/Source/Example/ mkdir -p MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo cp ../Source/MediaInfo/MediaInfo.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/ cp ../Source/MediaInfo/MediaInfo_Const.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/ cp ../Source/MediaInfo/MediaInfo_Events.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/ cp ../Source/MediaInfo/MediaInfoList.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfo/ mkdir -p MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL cp ../Source/MediaInfoDLL/MediaInfoDLL.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ cp ../Source/MediaInfoDLL/MediaInfoDLL_Static.h MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ cp ../Source/MediaInfoDLL/MediaInfoDLL.cs MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ cp ../Source/MediaInfoDLL/MediaInfoDLL.JNA.java MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ cp ../Source/MediaInfoDLL/MediaInfoDLL.JNative.java MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ cp ../Source/MediaInfoDLL/MediaInfoDLL.py MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ cp ../Source/MediaInfoDLL/MediaInfoDLL3.py MediaInfo_DLL_$1_$2/Developpers/Include/MediaInfoDLL/ #----------------------------------------------------------------------- # Compressing Archive mv MediaInfo_DLL_$1_$2 MediaInfoLib if test "$3" = "dylib"; then #special case, should be put elsewhere codesign -f -s "Developer ID Application: MediaArea.net" --verbose MediaInfoLib/libmediainfo.dylib fi tar jcf MediaInfo_DLL_$1_$2.tar.bz2 MediaInfoLib mv MediaInfoLib MediaInfo_DLL_$1_$2 #----------------------------------------------------------------------- # Clean up rm -r MediaInfo_DLL_$1_$2 } MediaInfoLib/Release/Example.ogg0000664000000000000000000001136712652076434015532 0ustar rootrootOggSF7vorbisDOggSFj "IvorbisXiph.Org libVorbis I 20030308 TITLE=Test for Unicode (UTF-8)5ARABIC=ئابةتثجحخدذرزسشصضطظعغـف9HEBREW=אבגדהוזחטיךכלםמןנסעףפץצְֱ$COMBINERS=ˆˇˉ˘˙˚˛˜̣̀́̃̉%CYRILLIC=ЁЂЃЄЅІЇЈЉЊЋЌЎЏ#ENGLISH=abcdefghaijklmnopqrstuvwxyz2FRENCH=aàäâåáãæÅÆ cçÇ eéèëê uùüû8GREEK=αβγδεζηθικλμνξοπρςστυφχψωLATIN=ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņvorbis)BCV"L ÀАU6kc(Fbj1c,Fb1c1c1c 4d@1B9Q)9ʼn0X!R̡J9 Y@H!RH!RH!RJ)b)b)r1 2褓N:$B RJk{{{{9BCV B!B!RH!b)АU KMS%S2%Sr-2-S3=3EUtUSUeueS6eS6eU6eS6eS6eՕeYeYeYeYeYe 4d #9#)8Hd`(H$YeYg陞ii iiiiiiifYeYeYeYeYeYeYeYeYeYeYeYeY@h*@@qqqGr$ Y@R$r4Gs4s