Git commit f45aec23602d0a41076b11ae63645c98f5cf1949 by Urs Fleisch. Committed on 06/06/2022 at 16:19. Pushed by ufleisch into branch 'master'.
libmp4v2: Update to version 2.1.1 from https://mp4v2.org/ M +12 -23 build.sh M +1 -1 doc/en/index.docbook M +8 -11 packaging/flatpak/org.kde.kid3-local.json D +0 -20 packaging/patches/mp4v2-1.0.0-0001-Fix_mp4tags_corruption.patch D +0 -27 packaging/patches/mp4v2-1.0.0-0002-Fix_m4_error.patch D +0 -20 packaging/patches/mp4v2-1.0.0-0003-Reproducible_build.patch D +0 -16 packaging/patches/mp4v2-1.0.0-0004-Pointer_comparison.patch D +0 -435 packaging/patches/mp4v2-1.0.0-0005-Cxx11_compiler.patch D +0 -1192 packaging/patches/mp4v2-1.0.0-win00-platform.patch https://invent.kde.org/multimedia/kid3/commit/f45aec23602d0a41076b11ae63645c98f5cf1949 diff --git a/build.sh b/build.sh index 0449259e..1e0e1054 100755 --- a/build.sh +++ b/build.sh @@ -355,8 +355,7 @@ taglib_version=1.12 taglib_githash=c4a0855f42c05ad9fab8915f27439c8194b6bb94 chromaprint_version=1.5.0 chromaprint_patchlevel=2 -mp4v2_version=2.0.0 -mp4v2_patchlevel=5 +mp4v2_version=2.1.1 # Try to find the configuration from an existing build. if test -z "$COMPILER"; then @@ -391,8 +390,11 @@ if [[ "$QTPREFIX" =~ /([0-9]+)\.([0-9]+)\.([0-9]+)/ ]]; then qt_version=$(printf "%d.%d.%d" ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]}) qt_version_major=${BASH_REMATCH[1]} else - echo "Could not extract Qt version from $QTPREFIX" - exit 1 + echo "Could not extract Qt version from $QTPREFIX, assuming $qt_version" + if [[ "$qt_version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + qt_nr=$(printf "%d%02d%02d" ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]}) + qt_version_major=${BASH_REMATCH[1]} + fi fi if test "$qt_nr" -ge 51204; then @@ -639,10 +641,8 @@ if test "$compiler" != "cross-android"; then test -f chromaprint_${chromaprint_version}-${chromaprint_patchlevel}.debian.tar.xz || $DOWNLOAD http://ftp.de.debian.org/debian/pool/main/c/chromaprint/chromaprint_${chromaprint_version}-${chromaprint_patchlevel}.debian.tar.xz - test -f mp4v2_${mp4v2_version}~dfsg0.orig.tar.bz2 || - $DOWNLOAD http://ftp.de.debian.org/debian/pool/main/m/mp4v2/mp4v2_${mp4v2_version}~dfsg0.orig.tar.bz2 - test -f mp4v2_${mp4v2_version}~dfsg0-${mp4v2_patchlevel}.debian.tar.xz || - $DOWNLOAD http://ftp.de.debian.org/debian/pool/main/m/mp4v2/mp4v2_${mp4v2_version}~dfsg0-${mp4v2_patchlevel}.debian.tar.xz + test -f mp4v2-${mp4v2_version}.tar.bz2 || + $DOWNLOAD https://github.com/enzo1982/mp4v2/releases/download/v${mp4v2_version}/mp4v2-${mp4v2_version}.tar.bz2 fi # !cross-android @@ -959,19 +959,7 @@ if test "$compiler" != "cross-android"; then if ! test -d mp4v2-${mp4v2_version}; then echo "### Extracting mp4v2" - tar xjf source/mp4v2_${mp4v2_version}~dfsg0.orig.tar.bz2 - cd mp4v2-${mp4v2_version}/ - tar xJf ../source/mp4v2_${mp4v2_version}~dfsg0-${mp4v2_patchlevel}.debian.tar.xz - for f in $(cat debian/patches/series); do patch -p1 <debian/patches/$f; done - if test $kernel = "MINGW" || test "$compiler" = "cross-mingw"; then - patch -p1 <$srcdir/packaging/patches/mp4v2-1.0.0-win00-platform.patch - if test -z "${cross_host##x86_64*}"; then - sed -i '/^# define _USE_32BIT_TIME_T/ s#^#//#' libplatform/platform_win32.h - fi - fi - patch -p1 <$srcdir/packaging/patches/mp4v2-1.0.0-0005-Cxx11_compiler.patch - patch -p1 <$srcdir/packaging/patches/mp4v2-1.0.0-0004-Pointer_comparison.patch - cd .. + tar xjf source/mp4v2-${mp4v2_version}.tar.bz2 fi fi # !cross-android @@ -1442,10 +1430,11 @@ else # cross-android echo "### Building mp4v2" cd mp4v2-${mp4v2_version}/ - autoreconf -i - test -f Makefile || CXXFLAGS="$CXXFLAGS -g -O2 -DMP4V2_USE_STATIC_LIB" ./configure --enable-shared=no --enable-static=yes --disable-gch $CONFIGURE_OPTIONS + test -f Makefile || eval cmake -DBUILD_SHARED=OFF -DBUILD_UTILS=OFF -DBUILD_SHARED_LIBS=OFF $CMAKE_BUILD_OPTION $CMAKE_OPTIONS + make VERBOSE=1 mkdir -p inst make install DESTDIR=`pwd`/inst + fixcmakeinst cd inst tar czf ../../bin/mp4v2-${mp4v2_version}.tgz usr cd ../.. diff --git a/doc/en/index.docbook b/doc/en/index.docbook index 069861ab..786aabd6 100644 --- a/doc/en/index.docbook +++ b/doc/en/index.docbook @@ -2587,7 +2587,7 @@ Uses <ulink url="http://taglib.github.io/">TagLib</ulink> which supports a lot of audio file formats. It can be used for all audio files supported by &kid3;.</para></listitem> <listitem><para><guilabel>Mp4v2Metadata</guilabel>: -<ulink url="http://code.google.com/p/mp4v2">mp4v2</ulink> was originally used +<ulink url="https://mp4v2.org/">mp4v2</ulink> was originally used by &kid3; to support M4A files. Can be used in case of problems with the M4A support of TagLib. </para></listitem> diff --git a/packaging/flatpak/org.kde.kid3-local.json b/packaging/flatpak/org.kde.kid3-local.json index 7af77699..e02c5133 100644 --- a/packaging/flatpak/org.kde.kid3-local.json +++ b/packaging/flatpak/org.kde.kid3-local.json @@ -91,20 +91,17 @@ }, { "name": "mp4v2", - "buildsystem": "autotools", - "config-opts": [], - "cleanup": [ "/bin" ], + "buildsystem": "cmake-ninja", + "config-opts": [ + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + "-DBUILD_UTILS=OFF" + ], "sources": [ { "type": "archive", - "url": "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/mp4v2/mp4v2-2.0.0.tar.bz2", - "sha256": "0319b9a60b667cf10ee0ec7505eb7bdc0a2e21ca7a93db96ec5bd758e3428338" - }, - { "type": "patch", "path": "../patches/mp4v2-1.0.0-0001-Fix_mp4tags_corruption.patch" }, - { "type": "patch", "path": "../patches/mp4v2-1.0.0-0002-Fix_m4_error.patch" }, - { "type": "patch", "path": "../patches/mp4v2-1.0.0-0003-Reproducible_build.patch" }, - { "type": "patch", "path": "../patches/mp4v2-1.0.0-0004-Pointer_comparison.patch" }, - { "type": "patch", "path": "../patches/mp4v2-1.0.0-0005-Cxx11_compiler.patch" } + "url": "https://github.com/enzo1982/mp4v2/releases/download/v2.1.1/mp4v2-2.1.1.tar.bz2", + "sha256": "29420c62e56a2e527fd8979d59d05ed6d83ebe27e0e2c782c1ec19a3a402eaee" + } ] }, { diff --git a/packaging/patches/mp4v2-1.0.0-0001-Fix_mp4tags_corruption.patch b/packaging/patches/mp4v2-1.0.0-0001-Fix_mp4tags_corruption.patch deleted file mode 100644 index 182d41bb..00000000 --- a/packaging/patches/mp4v2-1.0.0-0001-Fix_mp4tags_corruption.patch +++ /dev/null @@ -1,20 +0,0 @@ -From: "Matteo F. Vescovi" <m...@debian.org> -Date: Thu, 5 Nov 2015 15:26:00 +0100 -Subject: Fix_mp4tags_corruption - ---- - util/mp4tags.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/util/mp4tags.cpp b/util/mp4tags.cpp -index 1b9e866..80e89d4 100644 ---- a/util/mp4tags.cpp -+++ b/util/mp4tags.cpp -@@ -539,6 +539,7 @@ extern "C" int - else { - fprintf( stderr, "Art file %s not found\n", tags[i] ); - } -+ break; - } - case OPT_ALBUM_ARTIST: - MP4TagsSetAlbumArtist( mdata, tags[i] ); diff --git a/packaging/patches/mp4v2-1.0.0-0002-Fix_m4_error.patch b/packaging/patches/mp4v2-1.0.0-0002-Fix_m4_error.patch deleted file mode 100644 index c17998c6..00000000 --- a/packaging/patches/mp4v2-1.0.0-0002-Fix_m4_error.patch +++ /dev/null @@ -1,27 +0,0 @@ -From: Sebastian Ramacher <sramac...@debian.org> -Date: Thu, 5 Nov 2015 20:53:13 +0100 -Subject: Fix_m4_error - -Fix m4 error while running autoreconf - -Origin: upstream, https://code.google.com/p/mp4v2/source/detail?r=496 -Last-Update: 2014-08-30 - -Signed-off-by: Matteo F. Vescovi <m...@debian.org> ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 7c514eb..83e9dce 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -20,7 +20,7 @@ m4_define([PRJ_version_hex],m4_format([0x%04x%02x%02x],PRJ_version_major,PRJ_ver - - m4_define([PRJ_version],ifelse( - PRJ_repo_type,[stable],m4_format([%s],PRJ_repo_branch), -- m4_format([%s-r%d],PRJ_repo_branch,PRJ_repo_rev))) -+ m4_format([%s-r%s],PRJ_repo_branch,PRJ_repo_rev))) - - ############################################################################### - # initialization diff --git a/packaging/patches/mp4v2-1.0.0-0003-Reproducible_build.patch b/packaging/patches/mp4v2-1.0.0-0003-Reproducible_build.patch deleted file mode 100644 index ef97f6e7..00000000 --- a/packaging/patches/mp4v2-1.0.0-0003-Reproducible_build.patch +++ /dev/null @@ -1,20 +0,0 @@ -Description: Make the build reproducible -Author: Chris Lamb <la...@debian.org> -Last-Update: 2016-08-12 - ---- mp4v2-2.0.0~dfsg0.orig/configure.ac -+++ mp4v2-2.0.0~dfsg0/configure.ac -@@ -137,7 +137,12 @@ PROJECT_repo_uuid="PRJ_repo_uuid" - PROJECT_repo_rev="PRJ_repo_rev" - PROJECT_repo_date="PRJ_repo_date" - PROJECT_repo_type="PRJ_repo_type" --PROJECT_build="`date`" -+ -+if test -n "$SOURCE_DATE_EPOCH"; then -+ PROJECT_build="`LC_ALL=C date --utc --date="@$SOURCE_DATE_EPOCH"`" -+else -+ PROJECT_build="`date`" -+fi - - test -z "$PROJECT_version_hex" && PROJECT_version_hex="0x0000000000000000LL" - test -z "$PROJECT_version_major" && PROJECT_version_major="0" diff --git a/packaging/patches/mp4v2-1.0.0-0004-Pointer_comparison.patch b/packaging/patches/mp4v2-1.0.0-0004-Pointer_comparison.patch deleted file mode 100644 index 6dc5919e..00000000 --- a/packaging/patches/mp4v2-1.0.0-0004-Pointer_comparison.patch +++ /dev/null @@ -1,16 +0,0 @@ -Description: Fix pointer comparison (FTBFS on GCC 7) -Author: Philip Chung <philipchung1...@yahoo.com> -Bug-Debian: https://bugs.debian.org/853560 -Last-Update: 2017-09-04 - ---- mp4v2-2.0.0~dfsg0.orig/src/rtphint.cpp -+++ mp4v2-2.0.0~dfsg0/src/rtphint.cpp -@@ -339,7 +339,7 @@ void MP4RtpHintTrack::GetPayload( - pSlash = strchr(pSlash, '/'); - if (pSlash != NULL) { - pSlash++; -- if (pSlash != '\0') { -+ if (*pSlash != '\0') { - length = (uint32_t)strlen(pRtpMap) - (pSlash - pRtpMap); - *ppEncodingParams = (char *)MP4Calloc(length + 1); - strncpy(*ppEncodingParams, pSlash, length); diff --git a/packaging/patches/mp4v2-1.0.0-0005-Cxx11_compiler.patch b/packaging/patches/mp4v2-1.0.0-0005-Cxx11_compiler.patch deleted file mode 100644 index 31cf860e..00000000 --- a/packaging/patches/mp4v2-1.0.0-0005-Cxx11_compiler.patch +++ /dev/null @@ -1,435 +0,0 @@ -diff -ru mp4v2-2.0.0.orig/libutil/Utility.cpp mp4v2-2.0.0/libutil/Utility.cpp ---- mp4v2-2.0.0.orig/libutil/Utility.cpp 2012-05-21 00:11:53.000000000 +0200 -+++ mp4v2-2.0.0/libutil/Utility.cpp 2018-12-07 06:52:54.298395112 +0100 -@@ -531,26 +531,26 @@ - printHelp( false, false ); - return SUCCESS; - -- case LC_DEBUG: -+ case (int)LC_DEBUG: - debugUpdate( std::strtoul( prog::optarg, NULL, 0 ) ); - break; - -- case LC_VERBOSE: -+ case (int)LC_VERBOSE: - { - const uint32_t level = std::strtoul( prog::optarg, NULL, 0 ); - _verbosity = ( level < 4 ) ? level : 3; - break; - } - -- case LC_HELP: -+ case (int)LC_HELP: - printHelp( true, false ); - return SUCCESS; - -- case LC_VERSION: -+ case (int)LC_VERSION: - printVersion( false ); - return SUCCESS; - -- case LC_VERSIONX: -+ case (int)LC_VERSIONX: - printVersion( true ); - return SUCCESS; - -diff -ru mp4v2-2.0.0.orig/src/mp4.cpp mp4v2-2.0.0/src/mp4.cpp ---- mp4v2-2.0.0.orig/src/mp4.cpp 2012-05-21 00:11:53.000000000 +0200 -+++ mp4v2-2.0.0/src/mp4.cpp 2018-12-07 06:43:25.145879532 +0100 -@@ -870,7 +870,7 @@ - } - - catch (...) { -- return MP4_INVALID_TRACK_ID; -+ return (mp4v2_ismacrypParams *)MP4_INVALID_TRACK_ID; - } - } - -diff -ru mp4v2-2.0.0.orig/src/mp4util.h mp4v2-2.0.0/src/mp4util.h ---- mp4v2-2.0.0.orig/src/mp4util.h 2012-05-21 00:11:53.000000000 +0200 -+++ mp4v2-2.0.0/src/mp4util.h 2018-12-07 06:38:56.557204609 +0100 -@@ -33,7 +33,7 @@ - #ifndef ASSERT - # define ASSERT(expr) \ - if (!(expr)) { \ -- throw new Exception("assert failure: "LIBMPV42_STRINGIFY((expr)), __FILE__, __LINE__, __FUNCTION__ ); \ -+ throw new Exception("assert failure: " LIBMPV42_STRINGIFY((expr)), __FILE__, __LINE__, __FUNCTION__ ); \ - } - #endif - -diff -ru mp4v2-2.0.0.orig/util/mp4art.cpp mp4v2-2.0.0/util/mp4art.cpp ---- mp4v2-2.0.0.orig/util/mp4art.cpp 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/util/mp4art.cpp 2018-12-07 06:54:49.929641777 +0100 -@@ -377,11 +377,11 @@ - handled = true; - - switch( code ) { -- case LC_ART_ANY: -+ case (int)LC_ART_ANY: - _artFilter = numeric_limits<uint32_t>::max(); - break; - -- case LC_ART_INDEX: -+ case (int)LC_ART_INDEX: - { - istringstream iss( prog::optarg ); - iss >> _artFilter; -@@ -390,29 +390,29 @@ - break; - } - -- case LC_LIST: -+ case (int)LC_LIST: - _action = &ArtUtility::actionList; - break; - -- case LC_ADD: -+ case (int)LC_ADD: - _action = &ArtUtility::actionAdd; - _artImageFile = prog::optarg; - if( _artImageFile.empty() ) - return herrf( "invalid image file: empty-string\n" ); - break; - -- case LC_REMOVE: -+ case (int)LC_REMOVE: - _action = &ArtUtility::actionRemove; - break; - -- case LC_REPLACE: -+ case (int)LC_REPLACE: - _action = &ArtUtility::actionReplace; - _artImageFile = prog::optarg; - if( _artImageFile.empty() ) - return herrf( "invalid image file: empty-string\n" ); - break; - -- case LC_EXTRACT: -+ case (int)LC_EXTRACT: - _action = &ArtUtility::actionExtract; - break; - -diff -ru mp4v2-2.0.0.orig/util/mp4chaps.cpp mp4v2-2.0.0/util/mp4chaps.cpp ---- mp4v2-2.0.0.orig/util/mp4chaps.cpp 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/util/mp4chaps.cpp 2018-12-07 06:56:37.808767340 +0100 -@@ -634,32 +634,32 @@ - - switch( code ) { - case 'A': -- case LC_CHPT_ANY: -+ case (int)LC_CHPT_ANY: - _ChapterType = MP4ChapterTypeAny; - break; - - case 'Q': -- case LC_CHPT_QT: -+ case (int)LC_CHPT_QT: - _ChapterType = MP4ChapterTypeQt; - break; - - case 'N': -- case LC_CHPT_NERO: -+ case (int)LC_CHPT_NERO: - _ChapterType = MP4ChapterTypeNero; - break; - - case 'C': -- case LC_CHPT_COMMON: -+ case (int)LC_CHPT_COMMON: - _ChapterFormat = CHPT_FMT_COMMON; - break; - - case 'l': -- case LC_CHP_LIST: -+ case (int)LC_CHP_LIST: - _action = &ChapterUtility::actionList; - break; - - case 'e': -- case LC_CHP_EVERY: -+ case (int)LC_CHP_EVERY: - { - istringstream iss( prog::optarg ); - iss >> _ChaptersEvery; -@@ -675,7 +675,7 @@ - _action = &ChapterUtility::actionExport; - break; - -- case LC_CHP_EXPORT: -+ case (int)LC_CHP_EXPORT: - _action = &ChapterUtility::actionExport; - /* currently not supported since the chapters of n input files would be written to one chapter file - _ChapterFile = prog::optarg; -@@ -690,7 +690,7 @@ - _action = &ChapterUtility::actionImport; - break; - -- case LC_CHP_IMPORT: -+ case (int)LC_CHP_IMPORT: - _action = &ChapterUtility::actionImport; - /* currently not supported since the chapters of n input files would be read from one chapter file - _ChapterFile = prog::optarg; -@@ -702,12 +702,12 @@ - break; - - case 'c': -- case LC_CHP_CONVERT: -+ case (int)LC_CHP_CONVERT: - _action = &ChapterUtility::actionConvert; - break; - - case 'r': -- case LC_CHP_REMOVE: -+ case (int)LC_CHP_REMOVE: - _action = &ChapterUtility::actionRemove; - break; - -diff -ru mp4v2-2.0.0.orig/util/mp4file.cpp mp4v2-2.0.0/util/mp4file.cpp ---- mp4v2-2.0.0.orig/util/mp4file.cpp 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/util/mp4file.cpp 2018-12-07 06:57:29.218284178 +0100 -@@ -190,15 +190,15 @@ - handled = true; - - switch( code ) { -- case LC_LIST: -+ case (int)LC_LIST: - _action = &FileUtility::actionList; - break; - -- case LC_OPTIMIZE: -+ case (int)LC_OPTIMIZE: - _action = &FileUtility::actionOptimize; - break; - -- case LC_DUMP: -+ case (int)LC_DUMP: - _action = &FileUtility::actionDump; - break; - -diff -ru mp4v2-2.0.0.orig/util/mp4subtitle.cpp mp4v2-2.0.0/util/mp4subtitle.cpp ---- mp4v2-2.0.0.orig/util/mp4subtitle.cpp 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/util/mp4subtitle.cpp 2018-12-07 06:58:11.247535746 +0100 -@@ -165,25 +165,25 @@ - handled = true; - - switch( code ) { -- case LC_LIST: -+ case (int)LC_LIST: - _action = &SubtitleUtility::actionList; - break; - -- case LC_EXPORT: -+ case (int)LC_EXPORT: - _action = &SubtitleUtility::actionExport; - _stTextFile = prog::optarg; - if( _stTextFile.empty() ) - return herrf( "invalid TXT file: empty-string\n" ); - break; - -- case LC_IMPORT: -+ case (int)LC_IMPORT: - _action = &SubtitleUtility::actionImport; - _stTextFile = prog::optarg; - if( _stTextFile.empty() ) - return herrf( "invalid TXT file: empty-string\n" ); - break; - -- case LC_REMOVE: -+ case (int)LC_REMOVE: - _action = &SubtitleUtility::actionRemove; - break; - -diff -ru mp4v2-2.0.0.orig/util/mp4track.cpp mp4v2-2.0.0/util/mp4track.cpp ---- mp4v2-2.0.0.orig/util/mp4track.cpp 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/util/mp4track.cpp 2018-12-07 07:02:07.978741963 +0100 -@@ -789,11 +789,11 @@ - handled = true; - - switch( code ) { -- case LC_TRACK_WILDCARD: -+ case (int)LC_TRACK_WILDCARD: - _trackMode = TM_WILDCARD; - break; - -- case LC_TRACK_INDEX: -+ case (int)LC_TRACK_INDEX: - { - _trackMode = TM_INDEX; - istringstream iss( prog::optarg ); -@@ -803,7 +803,7 @@ - break; - } - -- case LC_TRACK_ID: -+ case (int)LC_TRACK_ID: - { - _trackMode = TM_ID; - istringstream iss( prog::optarg ); -@@ -813,142 +813,142 @@ - break; - } - -- case LC_LIST: -+ case (int)LC_LIST: - _action = &TrackUtility::actionList; - break; - -- case LC_COLR_PARMS: -+ case (int)LC_COLR_PARMS: - _colorParameterItem.convertFromCSV( prog::optarg ); - break; - -- case LC_COLR_PARM_HD: -+ case (int)LC_COLR_PARM_HD: - _colorParameterItem.primariesIndex = 1; - _colorParameterItem.transferFunctionIndex = 1; - _colorParameterItem.matrixIndex = 1; - break; - -- case LC_COLR_PARM_SD: -+ case (int)LC_COLR_PARM_SD: - _colorParameterItem.primariesIndex = 6; - _colorParameterItem.transferFunctionIndex = 1; - _colorParameterItem.matrixIndex = 6; - break; - -- case LC_COLR_LIST: -+ case (int)LC_COLR_LIST: - _action = &TrackUtility::actionColorParameterList; - break; - -- case LC_ENABLED: -+ case (int)LC_ENABLED: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setEnabled; - _actionTrackModifierSet_name = "enabled"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_INMOVIE: -+ case (int)LC_INMOVIE: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setInMovie; - _actionTrackModifierSet_name = "inMovie"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_INPREVIEW: -+ case (int)LC_INPREVIEW: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setInPreview; - _actionTrackModifierSet_name = "inPreview"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_LAYER: -+ case (int)LC_LAYER: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setLayer; - _actionTrackModifierSet_name = "layer"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_ALTGROUP: -+ case (int)LC_ALTGROUP: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setAlternateGroup; - _actionTrackModifierSet_name = "alternateGroup"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_VOLUME: -+ case (int)LC_VOLUME: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setVolume; - _actionTrackModifierSet_name = "volume"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_WIDTH: -+ case (int)LC_WIDTH: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setWidth; - _actionTrackModifierSet_name = "width"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_HEIGHT: -+ case (int)LC_HEIGHT: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setHeight; - _actionTrackModifierSet_name = "height"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_LANGUAGE: -+ case (int)LC_LANGUAGE: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setLanguage; - _actionTrackModifierSet_name = "language"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_HDLRNAME: -+ case (int)LC_HDLRNAME: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setHandlerName; - _actionTrackModifierSet_name = "handlerName"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_UDTANAME: -+ case (int)LC_UDTANAME: - _action = &TrackUtility::actionTrackModifierSet; - _actionTrackModifierSet_function = &TrackModifier::setUserDataName; - _actionTrackModifierSet_name = "userDataName"; - _actionTrackModifierSet_value = prog::optarg; - break; - -- case LC_UDTANAME_R: -+ case (int)LC_UDTANAME_R: - _action = &TrackUtility::actionTrackModifierRemove; - _actionTrackModifierRemove_function = &TrackModifier::removeUserDataName; - _actionTrackModifierRemove_name = "userDataName"; - break; - -- case LC_COLR_ADD: -+ case (int)LC_COLR_ADD: - _action = &TrackUtility::actionColorParameterAdd; - break; - -- case LC_COLR_SET: -+ case (int)LC_COLR_SET: - _action = &TrackUtility::actionColorParameterSet; - break; - -- case LC_COLR_REMOVE: -+ case (int)LC_COLR_REMOVE: - _action = &TrackUtility::actionColorParameterRemove; - break; - -- case LC_PASP_PARMS: -+ case (int)LC_PASP_PARMS: - _pictureAspectRatioItem.convertFromCSV( prog::optarg ); - break; - -- case LC_PASP_LIST: -+ case (int)LC_PASP_LIST: - _action = &TrackUtility::actionPictureAspectRatioList; - break; - -- case LC_PASP_ADD: -+ case (int)LC_PASP_ADD: - _action = &TrackUtility::actionPictureAspectRatioAdd; - break; - -- case LC_PASP_SET: -+ case (int)LC_PASP_SET: - _action = &TrackUtility::actionPictureAspectRatioSet; - break; - -- case LC_PASP_REMOVE: -+ case (int)LC_PASP_REMOVE: - _action = &TrackUtility::actionPictureAspectRatioRemove; - break; - diff --git a/packaging/patches/mp4v2-1.0.0-win00-platform.patch b/packaging/patches/mp4v2-1.0.0-win00-platform.patch deleted file mode 100644 index 11324c29..00000000 --- a/packaging/patches/mp4v2-1.0.0-win00-platform.patch +++ /dev/null @@ -1,1192 +0,0 @@ -diff -ruN mp4v2-2.0.0.orig/GNUmakefile.am mp4v2-2.0.0/GNUmakefile.am ---- mp4v2-2.0.0.orig/GNUmakefile.am 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/GNUmakefile.am 2014-04-14 07:22:35.904963506 +0200 -@@ -170,6 +170,7 @@ - endif - if ADD_PLATFORM_WIN32 - libmp4v2_la_SOURCES += \ -+ libplatform/platform_win32.cpp \ - libplatform/io/File_win32.cpp \ - libplatform/io/FileSystem_win32.cpp \ - libplatform/number/random_win32.cpp \ -diff -ruN mp4v2-2.0.0.orig/libplatform/platform_win32.cpp mp4v2-2.0.0/libplatform/platform_win32.cpp ---- mp4v2-2.0.0.orig/libplatform/platform_win32.cpp 1970-01-01 01:00:00.000000000 +0100 -+++ mp4v2-2.0.0/libplatform/platform_win32.cpp 2014-04-14 07:21:11.432961343 +0200 -@@ -0,0 +1,1091 @@ -+/////////////////////////////////////////////////////////////////////////////// -+// -+// The contents of this file are subject to the Mozilla Public License -+// Version 1.1 (the "License"); you may not use this file except in -+// compliance with the License. You may obtain a copy of the License at -+// http://www.mozilla.org/MPL/ -+// -+// Software distributed under the License is distributed on an "AS IS" -+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -+// License for the specific language governing rights and limitations -+// under the License. -+// -+// The Original Code is MP4v2. -+// -+// The Initial Developer of the Original Code is David Byron. -+// Portions created by David Byron are Copyright (C) 2010. -+// All Rights Reserved. -+// -+// Contributors: -+// David Byron, dby...@dbyron.com -+// -+/////////////////////////////////////////////////////////////////////////////// -+ -+#include "src/impl.h" -+#include "libplatform/impl.h" /* for platform_win32_impl.h which declares Utf8ToFilename */ -+#include <algorithm> /* for replace */ -+#include <windows.h> -+ -+namespace mp4v2 { -+ using namespace impl; -+} -+ -+/** -+ * Set this to 1 to compile in extra debugging -+ */ -+#define EXTRA_DEBUG 0 -+ -+/** -+ * @def LOG_PRINTF -+ * -+ * call log.printf if EXTRA_DEBUG is defined to 1. Do -+ * nothing otherwise -+ */ -+#if EXTRA_DEBUG -+#define LOG_PRINTF(X) log.printf X -+#else -+#define LOG_PRINTF(X) -+#endif -+ -+/** -+ * Section 2.13 "Special Characters and Noncharacters" of -+ * _The Unicode Standard, Version 5.0_ -+ * (http://www.unicode.org/versions/Unicode5.0.0/bookmarks.html) -+ * defines "The Replacement Character" U+FFFD as the -+ * "general substitute character" that "can be substituted -+ * for any 'unknown' character in another encoding that can -+ * not be mapped in terms of known Unicode characters" -+ * -+ * See also section D.7 of 10646. -+ */ -+#define REPLACEMENT_CHAR 0xFFFD -+ -+namespace mp4v2 { namespace platform { namespace win32 { -+ -+/** -+ * A structure to store the number of characters required to -+ * encode a particular UCS-4 character in UTF-8 -+ */ -+struct utf8_len_info -+{ -+ /** -+ * This structure applies to a number >= @p range_min. -+ */ -+ UINT32 range_min; -+ -+ /** -+ * This structure applies to a number <= @p range_max. -+ */ -+ UINT32 range_max; -+ -+ /** -+ * The number of characters required to encode a number -+ * in [@p range_min,@p range_max] as UTF-8. -+ */ -+ size_t num_chars; -+}; -+ -+/** -+ * A structure to store the number of characters required to -+ * encode a particular UCS-4 character in UTF-8. For now -+ * we're using wide characters (which according to -+ * http://msdn.microsoft.com/en-us/library/ms776414.aspx -+ * means UTF-16 since Windows 2000) so we're only using up -+ * to 4-byte UTF-8 sequences. Parts of the range aren't -+ * valid (e.g. [U+D800,U+DFFF] but that's handled elsewhere. -+ */ -+static struct utf8_len_info s_len_info[] = -+{ -+ { 0x00000000, 0x0000007F, 1 }, -+ { 0x00000080, 0x000007FF, 2 }, -+ { 0x00000800, 0x0000FFFF, 3 }, -+ { 0x00010000, 0x001FFFFF, 4 }, -+ { 0x00200000, 0x03FFFFFF, 5 }, -+ { 0x04000000, 0x7FFFFFFF, 6 } -+}; -+ -+/** -+ * Utf8ToFilename constructor -+ * -+ * @param utf8string a UTF-8 encoded string that does not -+ * begin with \\\?\\ nor \\\?\\UNC\\ -+ * -+ * @see IsValidUTF16 to see whether the constructor -+ * succeeded -+ */ -+Utf8ToFilename::Utf8ToFilename( const string &utf8string ) -+ : _wideCharString( NULL ) -+ , utf8( _utf8 ) -+{ -+ // See -+ // http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx -+ // for notes about path lengths, prefixes, etc. The -+ // goal is to support the longest path possible. -+ // Relative paths are limited to 260 characters but -+ // absolute paths can be up to about 32767 -+ // characters if properly prefixed. -+ -+ // If utf8string is a relative path, convert it to -+ // UTF-16 and be done. -+ if (!IsAbsolute(utf8string)) -+ { -+ _wideCharString = ConvertToUTF16(utf8string); -+ return; -+ } -+ -+ // Since the prefix has backslashes, convert any forward -+ // slashes in utf8string to backslashes to keep Windows -+ // happy -+ const string *utf8ToUse = &utf8string; -+ string forwardSlash; -+ -+ if (utf8string.find('/') != std::string::npos) -+ { -+ forwardSlash = utf8string; -+ std::replace(forwardSlash.begin(),forwardSlash.end(),'/','\\'); -+ utf8ToUse = &forwardSlash; -+ } -+ ASSERT(utf8ToUse); -+ ASSERT((*utf8ToUse).length() > 0); -+ -+ // utf8string is an absolute path. It could be a -+ // UNC path (\\host\path). The prefix is different -+ // for UNC paths than it is for non-UNC paths. -+ string prefixedPath; -+ -+ if (IsUncPath(*utf8ToUse)) -+ { -+ // utf8string begins with two backslashes, but -+ // with a prefix we only need one so we can't -+ // just prepend a prefix. -+ prefixedPath = "\\\\?\\UNC" + (*utf8ToUse).substr(1); -+ } -+ else -+ { -+ prefixedPath = "\\\\?\\" + *utf8ToUse; -+ } -+ -+ // Transform prefixedPath to UTF-16 so it's -+ // appropriate for CreateFileW -+ _wideCharString = ConvertToUTF16(prefixedPath); -+} -+ -+Utf8ToFilename::~Utf8ToFilename( ) -+{ -+ if( _wideCharString != NULL ) -+ { -+ free(_wideCharString); -+ _wideCharString = NULL; -+ } -+} -+ -+/** -+ * Convert a UTF-8 encoded string to a UTF-16 string -+ * -+ * @param utf8 the NUL-terminated UTF-8 string to decode -+ * -+ * @retval NULL error allocating memory for UTF-16 string -+ * -+ * @retval non-NULL NUL-terminated UTF-16 version of @p -+ * utf8. Invalid portions of UTF-8 are represented by a -+ * replacement character U+FFFD. The caller is -+ * responsible for freeing this memory. -+ */ -+wchar_t * -+Utf8ToFilename::ConvertToUTF16 ( const string &utf8string ) -+{ -+ int num_bytes; -+ size_t num_chars; -+ wchar_t *retval; -+ -+ ASSERT(sizeof(wchar_t) == 2); -+ -+ // Store the utf8 string in our member variable so it's -+ // available -+ _utf8 = utf8string; -+ -+ // We need to find out how many characters we're dealing -+ // with so we know how much memory to allocate. At the -+ // same time, it's possible that the string we've been -+ // given isn't valid UTF-8. So, just use the length of -+ // the string we've been given as the number of -+ // characters to allocate. The decoded string can't be -+ // longer than this, even taking into account surrogate -+ // pairs since they require 4 UTF-8 characters but only -+ // two UTF-16 character elements. -+ num_chars = utf8string.length(); -+ -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: entry point (%d character string)", -+ __FUNCTION__,num_chars)); -+ -+ /* -+ ** Allocate space for the decoded string. Add one -+ ** for the NUL terminator. -+ */ -+ num_bytes = (num_chars + 1) * sizeof(wchar_t); -+ retval = (wchar_t *)malloc(num_bytes); -+ if (!retval) -+ { -+ log.errorf("%s: error allocating memory for %d byte(s)",__FUNCTION__,num_bytes); -+ return NULL; -+ } -+ -+ /* -+ ** ConvertToUTF16Buf zeroes out the memory so don't -+ ** do it here -+ */ -+ -+ // ConvertToUTF16Buf shouldn't fail if we allocated -+ // enough memory for the entire string. Check -+ // anyway just to be safe. -+ if (!ConvertToUTF16Buf(utf8string.c_str(),retval,num_bytes)) -+ { -+ // But ASSERT so we can find the problem and fix -+ // it. -+ ASSERT(0); -+ free(retval); -+ retval = NULL; -+ return NULL; -+ } -+ -+ return retval; -+} -+ -+/** -+ * Convert a UTF-8 encoded string to a UTF-16 string in -+ * a previously allocated buffer. -+ * -+ * @param utf8 the NUL-terminated UTF-8 string to decode -+ * -+ * @param utf16_buf the buffer in which to place the -+ * UTF-16 version of @p utf8. If there's enough space -+ * to hold a NUL terminator, @p utf16_buf contains one. -+ * If not, @p utf16_buf is not NUL terminated. -+ * -+ * @param num_bytes the number of bytes that @p -+ * utf16_str points to -+ * -+ * @retval 0 error converting @p name to UTF-16, -+ * including when @p utf8 requires more space to encode -+ * in UTF-16 than indicated by @p num_bytes. In that -+ * case, @p utf16_buf contains the UTF-16 encoding of as -+ * much of @p utf8 as possible. -+ * -+ * @retval 1 successfully converted @p name to @p UTF-16 -+ * in @p utf16_buf. wide character (UTF-16) version of -+ * @p Invalid portions of UTF-8 are represented by a -+ * replacement character U+FFFD. -+ */ -+int -+Utf8ToFilename::ConvertToUTF16Buf ( const char *utf8, -+ wchar_t *utf16_buf, -+ size_t num_bytes ) -+{ -+ size_t i; -+ const UINT8 *next_char; -+ size_t num_chars; -+ size_t num_utf16_chars; -+ size_t num_input_bytes; -+ const UINT8 *p; -+ wchar_t this_utf16[2]; -+ -+ ASSERT(utf8); -+ ASSERT(utf16_buf || (num_bytes == 0)); -+ ASSERT(sizeof(wchar_t) == 2); -+ -+ ASSERT(num_bytes % sizeof(wchar_t) == 0); -+ -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: converting \"%s\"",__FUNCTION__,utf8)); -+ -+ num_chars = strlen(utf8); -+ -+ // If the input is NUL-terminated (which it better -+ // be), the NUL-terminator is a valid input byte as -+ // well -+ num_input_bytes = num_chars + 1; -+ -+ // Make sure the buffer we've been given is long -+ // enough. We might need one UTF-16 character for -+ // every UTF-8 character. And one more for the NUL -+ // terminator. -+ // -+ // Here, check that there's room for a NUL -+ // terminator in the output string. This makes it -+ // safe to dereference p in the while loop below. -+ // It's probably enough to check num_bytes == 0 here -+ // but if we did that we'd have to change the error -+ // message after the while loop to be less specific. -+ // This way we give the caller more info about the -+ // input string. -+ if (num_bytes < sizeof(wchar_t)) -+ { -+ log.errorf("%s: %u byte(s) is not enough to transform a %u byte UTF-8 string " -+ "to NUL-terminated UTF-16",__FUNCTION__,num_bytes,num_input_bytes); -+ return 0; -+ } -+ -+ ASSERT(num_bytes > 0); -+ ASSERT(utf16_buf); -+ memset(utf16_buf,0,num_bytes); -+ -+ // The number of UTF-16 characters we've got space for -+ // in utf16_buf -+ num_utf16_chars = num_bytes / sizeof(wchar_t); -+ -+ p = (const UINT8 *)utf8; -+ i = 0; -+ while (*p && (i < num_utf16_chars)) -+ { -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: decoding first UTF-8 byte 0x%02X (UTF-16 " -+ "character %d of at most %d)",__FUNCTION__,*p,(i + 1), -+ num_utf16_chars)); -+ -+ memset(this_utf16,0,sizeof(this_utf16)); -+ -+ // This function decodes illegal bytes/sequences -+ // with a replacement character and returns the -+ // pointer to the next character to decode. Pass -+ // NULL since we don't care about detecting invalid -+ // characters here. -+ next_char = Utf8DecodeChar(p,num_input_bytes,this_utf16,NULL); -+ -+ // We've always got one character to assign -+ utf16_buf[i++] = this_utf16[0]; -+ -+ // If we're dealing with a surrogate pair, -+ // assign the low half too -+ if (this_utf16[1]) -+ { -+ // We may not have any more room in the -+ // UTF-16 buffer. Check to make sure we -+ // don't step on someone else's memory. We -+ // need to return failure here instead of -+ // depending on our other logic to do it for -+ // us. We'll get out of the while loop with -+ // no extra code, but if we're dealing with -+ // the UTF-16 encoding of the last character -+ // in the input string, there won't appear -+ // to be anything wrong. -+ if (i >= num_utf16_chars) -+ { -+ log.errorf("%s: out of space in %u byte output string to store surrogate " -+ "pair low half (0x%04X)",__FUNCTION__,num_bytes,this_utf16[1]); -+ return 0; -+ } -+ -+ utf16_buf[i++] = this_utf16[1]; -+ } -+ -+ // Put this here to make it brutally clear that -+ // the cast is safe -+ ASSERT(next_char >= p); -+ num_input_bytes -= (size_t)(next_char - p); -+ p = next_char; -+ } -+ -+ if (*p) -+ { -+ // Since num_input_bytes includes 1 for the -+ // NUL-terminator, it's got to be bigger than -+ // one here. -+ ASSERT(num_input_bytes > 1); -+ log.errorf("%s: %u byte(s) of input string remain(s) undecoded (%s): out of space in " -+ "%u byte output string",__FUNCTION__,(num_input_bytes - 1),p,num_bytes); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+/** -+ * Accessor for the length of a prefix (i.e. \\\?\\ or -+ * \\\?\\UNC\\) that begins a filename -+ * -+ * @param utf8string the UTF-8 encoded filename to -+ * examine -+ * -+ * @return the length of the prefix of @p utf8string in -+ * characters -+ */ -+int -+Utf8ToFilename::GetPrefixLen ( const string &utf8string ) -+{ -+ if (utf8string.find("\\\\?\\") == 0) -+ { -+ return strlen("\\\\?\\"); -+ } -+ -+ if (utf8string.find("\\\\?\\UNC\\") == 0) -+ { -+ return strlen("\\\\?\\UNC\\"); -+ } -+ -+ return 0; -+} -+ -+/** -+ * Determine if a path is absolute or not -+ * -+ * @param utf8string the UTF-8 encoded path to examine -+ * that does not begin with \\\?\\ nor \\\?\\UNC\\ -+ * -+ * @retval 0 @p utf8string is not an absolute path -+ * @retval 1 @p utf8string is an absolute path -+ */ -+int -+Utf8ToFilename::IsAbsolute ( const string &utf8string ) -+{ -+ // Assume utf8string doesn't already start with a -+ // long filename prefix (i.e. \\?\ or \\?\UNC\) -+ // since the logic here depends on that. -+ ASSERT(GetPrefixLen(utf8string) == 0); -+ -+ // Is an empty string absolute or relative? It's -+ // not absolute since we can't tell what -+ // drive/volume it's for so say it's relative. -+ if (utf8string.length() == 0) -+ { -+ return 0; -+ } -+ -+ // Here we're looking for: -+ // x: drive relative -+ // x:\ absolute path -+ if (utf8string[1] == ':') -+ { -+ // It starts with x:, but is it x:/ ? -+ if ((utf8string.length() >= 2) && IsPathSeparator(utf8string[2])) -+ { -+ // Yup -- it's absolute -+ return 1; -+ } -+ -+ // Nope, not x:/, just x:something -+ return 0; -+ } -+ -+ // UNC paths are absolute paths too -+ return IsUncPath(utf8string); -+} -+ -+/** -+ * Determine if a character is a valid path separator -+ * -+ * @param c the character to check -+ * -+ * @retval 0 @p c is not a valid path separator -+ * @retval 1 @p c is a valid path separator -+ */ -+int -+Utf8ToFilename::IsPathSeparator ( char c ) -+{ -+ return ((c == '\\') || (c == '/')); -+} -+ -+/** -+ * Determine if a path is a UNC path -+ * -+ * @param utf8string the UTF-8 encoded path to examine -+ * that does not begin with \\\?\\ nor \\\?\\UNC\\ -+ * -+ * @retval 0 @p utf8string is not a UNC path -+ * @retval 1 @p utf8string is a UNC path -+ */ -+int -+Utf8ToFilename::IsUncPath ( const string &utf8string ) -+{ -+ const char *host; -+ int num_slashes; -+ const char *p; -+ -+ // Assume utf8string doesn't already start with a -+ // long filename prefix (i.e. \\?\ or \\?\UNC\) -+ // since the logic here depends on that. -+ ASSERT(GetPrefixLen(utf8string) == 0); -+ -+ // Is an empty string a UNC path? No. -+ if (utf8string.length() == 0) -+ { -+ return 0; -+ } -+ -+ // Recognize: -+ // //volume/path -+ // \\volume\path -+ if (!IsPathSeparator(utf8string[0])) -+ { -+ // If it doesn't start with a path separator, it's -+ // not a UNC path. -+ return 0; -+ } -+ -+ // The path starts with a slash, so it could be a UNC -+ // path. See if it starts with two slashes...Be careful -+ // though, it might have more than 2 slashes. -+ p = utf8string.c_str(); -+ num_slashes = 0; -+ while (*p && IsPathSeparator(*p)) -+ { -+ num_slashes++; -+ p++; -+ } -+ -+ // We found a slash at the beginning so we better have -+ // at least one here -+ ASSERT(num_slashes >= 1); -+ if ((num_slashes > 2) || !(*p)) -+ { -+ // If we've got more than two slashes or we've -+ // run off the end of the string (///foo or -+ // //)...who knows how the OS will handle it, -+ // but it's not a UNC path. -+ log.errorf("%s: don't understand path(%s)",__FUNCTION__,utf8string.c_str()); -+ return 0; -+ } -+ -+ // If we've only got one slash, it looks like a -+ // drive relative path. If it's something like -+ // /foo//bar it's not clear how the OS handles it, -+ // but that's someone else's problem. It's not a -+ // UNC path. -+ if (num_slashes == 1) -+ { -+ return 0; -+ } -+ -+ // If we're here, we've got two slashes followed by -+ // a non-slash. Something like //foo. To be a -+ // proper UNC path, we need to see a hostname -+ // (e.g. foo), and then another slash. If not, it's -+ // not a UNC path. -+ ASSERT(num_slashes == 2); -+ -+ // Tempting to use STRTOK_R here, but that modifies -+ // the original string. Instead of making a copy, -+ // search manually. -+ host = p; -+ while (*p && !IsPathSeparator(*p)) -+ { -+ p++; -+ } -+ -+ // We checked for separators above, so we better -+ // have moved on at least a bit -+ ASSERT(host != p); -+ if (!(*p)) -+ { -+ // We ran off the end of the string without finding -+ // another separator. So, we've got something like -+ // -+ // //foobar -+ // -+ // which isn't a UNC path. -+ log.warningf("%s: incomplete UNC path: host only(%s)",__FUNCTION__, -+ utf8string.c_str()); -+ return 0; -+ } -+ -+ // p points to a separator, so...we've got one of: -+ // //host// -+ // //host//blah -+ // //host/bar -+ // -+ // Of these, only the last is a proper UNC path. See -+ // what we've got after p. -+ num_slashes = 0; -+ while (*p && IsPathSeparator(*p)) -+ { -+ num_slashes++; -+ p++; -+ } -+ -+ // We better have at least one slash or our logic is -+ // broken -+ ASSERT(num_slashes >= 1); -+ if (!(*p)) -+ { -+ // //host// (or maybe //host///), but no path -+ // part after the host -+ log.warningf("%s: incomplete UNC path: no path after host(%s)", -+ __FUNCTION__,utf8string.c_str()); -+ return 0; -+ } -+ -+ if (num_slashes > 1) -+ { -+ // Another busted case //host//blah or -+ // //host///blah, etc. -+ log.warningf("%s: invalid UNC path: too many slashes after host(%s)", -+ __FUNCTION__,utf8string.c_str()); -+ return 0; -+ } -+ -+ // If we're here it means num_slashes is exactly 1 -+ // so we've got //host/something so we're calling -+ // that a UNC path. -+ return 1; -+} -+ -+/** -+ * Accessor for whether the UTF-16 encoded string is valid -+ * -+ * @retval false the UTF-16 encoded string is not valid -+ * @retval true the UTF-16 encoded string is valid -+ */ -+bool -+Utf8ToFilename::IsUTF16Valid( ) const -+{ -+ return (_wideCharString ? true : false); -+} -+ -+/** -+ * Decode one UTF-8 encoded character into a UTF-16 -+ * character. The trouble here is that UTF-16 is really a -+ * variable length encoding to handle surrogate pairs -+ * (0xD800 --> 0xDFFF). This way UTF-16 can handle more -+ * than 2^16 characters. So we need to be careful. UCS-2 -+ * is a fixed width (16-bit) encoding that we could use, but -+ * then we can only handle 2^16 characters (the BMP). To -+ * handle all 2^21 characters, we need UTF-16. -+ * -+ * What does Windows really use? UTF-16. See -+ * http://unicode.org/iuc/iuc17/b2/slides.ppt for a -+ * discussion. -+ * http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&ixPost=168543 -+ * also has some info. -+ * -+ * @param utf8_char the UTF-8 character to decode, possibly -+ * occupying multiple bytes, not necessarily NUL terminated -+ * -+ * @param num_bytes the number of bytes that @p utf8_char -+ * points to (must be > 0) -+ * -+ * @param utf16 populated with the UTF-16 equivalent of @p -+ * utf8_char. Note that this must point to at least 2 -+ * wchar_t's of memory so there's room to hold a surrogate -+ * pair. -+ * -+ * @param invalid populated with 1 if @p utf8_char doesn't -+ * point to a valid UTF-8 encoded character, 0 if @p -+ * utf8_char is valid. -+ * -+ * @return the next byte to examine for subsequent decoding -+ * (some number of bytes after @p utf8_char). This may not -+ * be valid to dereference depending on the value of @p -+ * num_bytes. -+ */ -+const UINT8 * -+Utf8ToFilename::Utf8DecodeChar ( const UINT8 *utf8_char, -+ size_t num_bytes, -+ wchar_t *utf16, -+ int *invalid ) -+ -+{ -+ wchar_t high_half; -+ int i; -+ UINT8 len; -+ wchar_t low_half; -+ UINT8 mask; -+ const UINT8 *p; -+ UINT32 ucs4; -+ int valid_len; -+ -+ ASSERT(utf8_char); -+ ASSERT(num_bytes > 0); -+ ASSERT(utf16); -+ -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: decoding UTF-8 string at address 0x%p", -+ __FUNCTION__,utf8_char)); -+ -+ /* -+ ** Assume utf8_char is invalid until we learn otherwise -+ */ -+ if (invalid) -+ { -+ *invalid = 1; -+ } -+ -+ /* -+ ** Traverse the UTF-8 encoding and figure out what we've -+ ** got. -+ */ -+ p = (const UINT8 *)(utf8_char); -+ -+ /* -+ ** This is the number of bytes we expect based on the -+ ** first octet. If subsequent bytes are NUL or invalid, -+ ** then it may not the same as the actual len. -+ */ -+ len = Utf8NumOctets(*p); -+ if (len == 0) -+ { -+ log.errorf("%s: 0x%02X is not a valid first byte of a UTF-8 encoded character",__FUNCTION__,*p); -+ -+ /* -+ ** Use the replacement character and advance past -+ ** the invalid byte -+ */ -+ *utf16 = REPLACEMENT_CHAR; -+ return p + 1; -+ } -+ -+ /* -+ ** Handle one byte encodings in a special case. See -+ ** below for an explanation of how we mask successive -+ ** bytes of an encoding to see why. We're depending on -+ ** the validation in Utf8NumOctets here to make this OK. -+ */ -+ if (len == 1) -+ { -+ /* -+ ** There's no intermediate UCS-4 step here. We go -+ ** straight to UTF-16 since they're the same. -+ */ -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: one byte UTF-16 encoding: 0x%02X", -+ __FUNCTION__,*p)); -+ *utf16 = *p; -+ if (invalid) -+ { -+ *invalid = 0; -+ } -+ return p + 1; -+ } -+ -+ /* -+ ** Make sure we've got enough bytes in our input string -+ ** to form a valid UTF-8 character -+ */ -+ if (len > num_bytes) -+ { -+ log.errorf("%s: first byte 0x%02X indicates a %d byte " -+ "UTF-8 character, but we only have %u valid byte(s)", -+ __FUNCTION__,*p,len,num_bytes); -+ *utf16 = REPLACEMENT_CHAR; -+ return p + 1; -+ } -+ -+ /* -+ ** Traverse the bytes that should be part of this UTF-8 -+ ** encoded character and make sure we don't have an -+ ** overlength encoding, and make sure that each -+ ** character is valid. -+ */ -+ -+ /* -+ ** As we traverse each character, we mask off the -+ ** appropriate number of bits and include them in the -+ ** overall result. -+ ** -+ ** 1 byte encoding [U+00000000,U+0000007F]: 7 bits (7 bits total) (handled above) -+ ** 2 byte encoding [U+00000080,U+000007FF]: 5 bits, 6 bits (11 bits total) -+ ** 3 byte encoding [U+00000800,U+0000FFFF]: 4 bits, 6 bits, 6 bits (16 bits total) -+ ** 4 byte encoding [U+00010000,U+001FFFFF]: 3 bits, 6 bits, 6 bits, 6 bits (21 bits total) -+ ** 5 byte encoding [U+00200000,U+03FFFFFF]: 2 bits, 6 bits, 6 bits, 6 bits, 6 bits (26 bits total) -+ ** 6 byte encoding [U+04000000,U+7FFFFFFF]: 1 bit, 6 bits, 6 bits, 6 bits, 6 bits, 6 bits (31 bits total) -+ ** -+ ** So, mask the initial byte appropriately, then take -+ ** the bottom 6 bits from the remaining bytes. To be -+ ** brutally explicit, the first byte mask is: -+ ** -+ ** 1 byte encoding: 0x7F (or 0x80 - 1) (or (1 << 7) - 1) -+ ** 2 byte encoding: 0x1F (or 0x20 - 1) (or (1 << 5) - 1) -+ ** 3 byte encoding: 0x0F (or 0x10 - 1) (or (1 << 4) - 1) -+ ** 4 byte encoding: 0x07 (or 0x08 - 1) (or (1 << 3) - 1) -+ ** 5 byte encoding: 0x03 (or 0x04 - 1) (or (1 << 2) - 1) -+ ** 6 byte encoding: 0x01 (or 0x02 - 1) (or (1 << 1) - 1) -+ ** -+ ** So, the one byte encoding is a special case (again, -+ ** handled above), but for the other lengths, the mask -+ ** is (1 << (7 - len)) - 1. -+ */ -+ -+ /* -+ ** Handle the first byte of multi-byte encodings since -+ ** it's special -+ */ -+ ASSERT(len > 1); -+ ASSERT(len <= 6); -+ mask = (1 << (7 - len)) - 1; -+ ucs4 = *p & mask; -+ p++; -+ -+ /* -+ ** Now handle the remaining bytes -+ */ -+ for (i = 1;(i < len);i++) -+ { -+ if ((*p < 0x80) || (*p > 0xBF)) -+ { -+ log.errorf("%s: 0x%02X is not a valid continuation character in a UTF-8 encoding", -+ __FUNCTION__,*p); -+ -+ /* -+ ** Use the replacement character and return the -+ ** next byte after the invalid sequence as the -+ ** place for subsequent decoding operations. In -+ ** this case the invalid continuation character -+ ** could be the beginning of the next valid -+ ** sequence, so return that. -+ */ -+ *utf16 = REPLACEMENT_CHAR; -+ return p; -+ } -+ -+ /* -+ ** For the remainder of the bytes, shift over what -+ ** we've already got by 6 bits, and then OR in the -+ ** bottom 6 bits of the current byte. -+ */ -+ ucs4 = (ucs4 << 6) | (*p & 0x3F); -+ p++; -+ } -+ -+ /* -+ ** p is now pointing to the beginning of the next UTF-8 -+ ** sequence to decode... -+ */ -+ -+ /* -+ ** Finally, detect overlong encodings. For example, a -+ ** line feed (U+000A) should be encoded as 0x0A -+ ** (0b00001010) but could in theory be encoded in UTF-8 -+ ** as 0xC0 0x8A (0b10001010). -+ ** -+ ** Another example is the forward slash (/) (U+002F). -+ ** It should be encoded as 0x2F, but could in theory be -+ ** encoded in UTF-8 as 0xC0 0xAF (which we'll catch -+ ** because 0xC0 is an invalid first byte of a UTF-8 -+ ** encoding), but could also be 0xE0 0x80 0xAF. -+ ** -+ ** I can't see any reasonable way to do this other than -+ ** to check the decoded character against its expected -+ ** length -+ */ -+ valid_len = Utf8LenFromUcs4(ucs4); -+ if (valid_len == 0) -+ { -+ /* -+ ** This should never happen -+ */ -+ log.errorf("%s: decoded a character that we can't encode again (0x%08X)",__FUNCTION__,ucs4); -+ ASSERT(0); -+ -+ /* -+ ** If it does, use the replacement character -+ */ -+ *utf16 = REPLACEMENT_CHAR; -+ return p; -+ } -+ -+ if (len != valid_len) -+ { -+ ASSERT(len > valid_len); -+ log.errorf("%s: overlong encoding(%s)...should be %d byte(s), not %d",__FUNCTION__, -+ utf8_char,valid_len,len); -+ *utf16 = REPLACEMENT_CHAR; -+ return p; -+ } -+ -+ /* -+ ** UTF-16 can only hold 21 bits. As of now (21-dec-10), -+ ** there's no Unicode code point bigger than 2^21. To -+ ** be safe, check... -+ */ -+ if (ucs4 > 0x0010FFFF) -+ { -+ log.errorf("%s: code point 0x%08X is too big",__FUNCTION__,ucs4); -+ *utf16 = REPLACEMENT_CHAR; -+ return p; -+ } -+ -+ /* -+ ** Check to make sure we're not working with a "code -+ ** point" that is in the range used to indicate -+ ** surrogate pairs. -+ */ -+ if ((ucs4 >= 0x0000D800) && (ucs4 <= 0x0000DFFF)) -+ { -+ log.errorf("%s: code point 0x%08X is in the range used to indicate surrogate pairs", -+ __FUNCTION__,ucs4); -+ *utf16 = REPLACEMENT_CHAR; -+ return p; -+ } -+ -+ /* -+ ** To (try to) be complete, check for a couple more -+ ** invalid code points -+ */ -+ if ((ucs4 == 0x0000FFFF) || (ucs4 == 0x0000FFFE)) -+ { -+ log.errorf("%s: invalid code point (0x%08X)",__FUNCTION__,ucs4); -+ *utf16 = REPLACEMENT_CHAR; -+ return p; -+ } -+ -+ /* -+ ** Finally, convert from UCS-4 to UTF-16. This may be a -+ ** straightforward assignment, but we have to deal with -+ ** surrogate pairs -+ */ -+ if (ucs4 <= 0x0000FFFF) -+ { -+ *utf16 = ucs4 & 0xFFFF; -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: UTF-16 encoding of 0x%08X is 0x%04X", -+ __FUNCTION__,ucs4,*utf16)); -+ if (invalid) -+ { -+ *invalid = 0; -+ } -+ return p; -+ } -+ -+ /* -+ ** Transform UCS-4 into a UTF-16 surrogate pair -+ */ -+ -+ /* -+ ** Grab bits [10,20] (where bit 0 is the LSB) and shift -+ ** them down -+ */ -+ high_half = 0xD800 + ((ucs4 - 0x00010000) >> 10); -+ -+ /* -+ ** And the bottom 10 bits [0,9] -+ */ -+ low_half = 0xDC00 + (ucs4 & 0x03FF); -+ -+ utf16[0] = high_half; -+ utf16[1] = low_half; -+ -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: UTF-16 encoding of 0x%08X is 0x%04X:0x%04X", -+ __FUNCTION__,ucs4,utf16[0],utf16[1])); -+ -+ if (invalid) -+ { -+ *invalid = 0; -+ } -+ -+ return p; -+} -+ -+/** -+ * Determine the number of bytes required to hold the UTF-8 -+ * encoding of a UCS-4 code point -+ * -+ * @param ucs4 the code point -+ * -+ * @param use_syslog 1 to use syslog, 0 otherwise -+ * -+ * @retval 0 @p ucs4 is not a valid code point -+ * -+ * @retval [1,6] the number of bytes required to hold the -+ * UTF-8 encoding of @p ucs4 -+ */ -+size_t -+Utf8ToFilename::Utf8LenFromUcs4 ( UINT32 ucs4 ) -+{ -+ size_t table_idx; -+ -+ LOG_PRINTF((MP4_LOG_VERBOSE4,"%s: processing UCS-4 code point 0x%08X", -+ __FUNCTION__,ucs4)); -+ -+ for (table_idx = 0;(table_idx < (sizeof(s_len_info) / -+ sizeof(struct utf8_len_info))); -+ table_idx++) -+ { -+ if ((s_len_info[table_idx].range_min <= ucs4) && -+ (ucs4 <= s_len_info[table_idx].range_max)) -+ { -+ return s_len_info[table_idx].num_chars; -+ } -+ } -+ -+ log.errorf("%s: 0x%08X is an invalid code point",__FUNCTION__,ucs4); -+ -+ return 0; -+} -+ -+/** -+ * Determine the number of octets that a UTF-8 encoded -+ * character should occupy based on its first byte -+ * -+ * @param utf8_first_byte the byte to examine -+ * -+ * @retval 0 @p utf8_first_byte is not a valid first byte of -+ * a UTF-8 encoded character -+ * -+ * @retval [1,6] the number of octets that @p -+ * utf8_first_byte should occupy -+ */ -+UINT8 -+Utf8ToFilename::Utf8NumOctets ( UINT8 utf8_first_byte ) -+{ -+ /** -+ * Here's a mapping from the first byte of a UTF-8 -+ * character to the number of bytes it should contain -+ * based on information from -+ * http://www.unicode.org/versions/corrigendum1.html as -+ * well as -+ * http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt -+ * -+ * [0x00,0x7F]: 1 (0-127) (128 possible values) -+ * [0x80,0xBF]: invalid (128-191) (64 possible values) -+ * [0xC0,0xDF]: 2 (192-223) (32 possible values) (see below) -+ * [0xE0,0xEF]: 3 (224-239) (16 possible values) -+ * [0xF0,0xF7]: 4 (240 - 247) (8 possible values) -+ * [0xF8,0xFB]: 5 (248 - 251) (4 possible values) -+ * [0xFC,0xFD]: 6 (252 - 253) (2 possible values) -+ * [0xFE,0xFF]: invalid (254 - 255) (2 possible values) -+ * -+ * There's some gray area about 0xC0 and 0xC1. It's -+ * clear they are invalid first bytes but the question -+ * is how to handle it. If I reject them here, they'll -+ * get replaced with the REPLACEMENT character. But, if -+ * I allow them here, it's likely that both this byte -+ * and the subsequent one will get replaced with only -+ * one replacement character. This is what -+ * http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt -+ * assumes in sections 4.1.1, 4.2.1 and 4.3.1. -+ */ -+ if (utf8_first_byte <= 0x7F) -+ { -+ return 1; -+ } -+ -+ if ((utf8_first_byte >= 0x80) && (utf8_first_byte <= 0xBF)) -+ { -+ return 0; -+ } -+ -+ if ((utf8_first_byte >= 0xC0) && (utf8_first_byte <= 0xDF)) -+ { -+ return 2; -+ } -+ -+ if ((utf8_first_byte >= 0xE0) && (utf8_first_byte <= 0xEF)) -+ { -+ return 3; -+ } -+ -+ if ((utf8_first_byte >= 0xF0) && (utf8_first_byte <= 0xF7)) -+ { -+ return 4; -+ } -+ -+ if ((utf8_first_byte >= 0xF8) && (utf8_first_byte <= 0xFB)) -+ { -+ return 5; -+ } -+ -+ if ((utf8_first_byte >= 0xFC) && (utf8_first_byte <= 0xFD)) -+ { -+ return 6; -+ } -+ -+ ASSERT((utf8_first_byte == 0xFE) || (utf8_first_byte == 0xFF)); -+ return 0; -+} -+ -+/////////////////////////////////////////////////////////////////////////////// -+ -+}}} // namespace mp4v2::platform::win32 -diff -ruN mp4v2-2.0.0.orig/libplatform/platform_win32.h mp4v2-2.0.0/libplatform/platform_win32.h ---- mp4v2-2.0.0.orig/libplatform/platform_win32.h 2012-05-21 00:11:55.000000000 +0200 -+++ mp4v2-2.0.0/libplatform/platform_win32.h 2014-04-14 07:53:02.677010281 +0200 -@@ -7,6 +7,8 @@ - #ifdef __MINGW32__ - # undef __MSVCRT_VERSION__ - # define __MSVCRT_VERSION__ 0x800 -+// JAN: see http://code.google.com/p/mp4v2/issues/detail?id=132 -+# define _USE_32BIT_TIME_T - #endif - - // set minimum win32 API requirement to Windows 2000 or higher -diff -ruN mp4v2-2.0.0.orig/libplatform/platform_win32_impl.h mp4v2-2.0.0/libplatform/platform_win32_impl.h ---- mp4v2-2.0.0.orig/libplatform/platform_win32_impl.h 1970-01-01 01:00:00.000000000 +0100 -+++ mp4v2-2.0.0/libplatform/platform_win32_impl.h 2014-04-14 07:54:09.737011998 +0200 -@@ -0,0 +1,70 @@ -+// Note that we have a separate platform_win32_impl.h to deal with the fact that windows.h defines a macro -+// called FindAtom, which mp4v2 also defines. In older versions of visual studio, this actually causes -+// some pretty seriously issues with naming collisions and the defined macros (think infamous min/max macro -+// of windows.h vs stdc++'s min/max template functions) -+#include <windows.h> -+ -+typedef unsigned char UINT8; -+ -+/////////////////////////////////////////////////////////////////////////////// -+ -+namespace mp4v2 { namespace platform { namespace win32 { -+ -+class Utf8ToFilename -+{ -+ public: -+ Utf8ToFilename( const string &utf8string ); -+ ~Utf8ToFilename( ); -+ -+ bool IsUTF16Valid( ) const; -+ -+ operator LPCWSTR( ) const { return _wideCharString; } -+ operator LPWSTR( ) const { return _wideCharString; } -+ -+ private: -+ Utf8ToFilename ( const Utf8ToFilename &src ); -+ Utf8ToFilename &operator= ( const Utf8ToFilename &src ); -+ -+ wchar_t *ConvertToUTF16 ( const string &utf8 ); -+ -+ static int ConvertToUTF16Buf ( const char *utf8, -+ wchar_t *utf16_buf, -+ size_t num_bytes ); -+ static int GetPrefixLen ( const string &utf8string ); -+ -+ static int IsAbsolute ( const string &utf8string ); -+ -+ static int IsPathSeparator ( char c ); -+ -+ static int IsUncPath ( const string &utf8string ); -+ -+ static const UINT8 *Utf8DecodeChar ( -+ const UINT8 *utf8_char, -+ size_t num_bytes, -+ wchar_t *utf16, -+ int *invalid -+ ); -+ -+ static size_t Utf8LenFromUcs4 ( UINT32 ucs4 ); -+ -+ static UINT8 Utf8NumOctets ( UINT8 utf8_first_byte ); -+ -+ /** -+ * The UTF-8 encoding of the filename actually used -+ */ -+ string _utf8; -+ -+ /** -+ * The UTF-16 encoding of the filename actually used -+ */ -+ wchar_t* _wideCharString; -+ -+ public: -+ -+ /** -+ * Accessor for @p _utf8 -+ */ -+ const string& utf8; -+}; -+ -+}}} // namespace mp4v2::platform::win32