diff --git a/src/global.cpp b/src/global.cpp index 3091ee6..8aebb58 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -1448,23 +1448,30 @@ bool x264_suspendProcess(const QProcess *proc, const bool suspend) /* * Convert path to short/ANSI path */ -QString x264_path2ansi(const QString &longPath) +QString x264_path2ansi(const QString &longPath, bool makeLowercase) { QString shortPath = longPath; - DWORD buffSize = GetShortPathNameW(reinterpret_cast(longPath.utf16()), NULL, NULL); + const QString longPathNative = QDir::toNativeSeparators(longPath); + DWORD buffSize = GetShortPathNameW(QWCHAR(longPathNative), NULL, NULL); if(buffSize > 0) { - wchar_t *buffer = new wchar_t[buffSize]; - DWORD result = GetShortPathNameW(reinterpret_cast(longPath.utf16()), buffer, buffSize); + wchar_t *buffer = (wchar_t*) _malloca(sizeof(wchar_t) * buffSize); + DWORD result = GetShortPathNameW(QWCHAR(longPathNative), buffer, buffSize); if((result > 0) && (result < buffSize)) { - shortPath = QString::fromUtf16(reinterpret_cast(buffer), result); + shortPath = QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast(buffer), result)); + + if(makeLowercase) + { + QFileInfo info(shortPath); + shortPath = QString("%1/%2").arg(info.absolutePath(), info.fileName().toLower()); + } } - delete[] buffer; + _freea(buffer); buffer = NULL; } diff --git a/src/global.h b/src/global.h index f0786f0..6c477e8 100644 --- a/src/global.h +++ b/src/global.h @@ -116,7 +116,7 @@ bool x264_init_qt(int argc, char* argv[]); bool x264_is_executable(const QString &path); bool x264_is_prerelease(void); void x264_message_handler(QtMsgType type, const char *msg); -QString x264_path2ansi(const QString &longPath); +QString x264_path2ansi(const QString &longPath, bool makeLowercase = false); bool x264_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias = NULL); bool x264_portable(void); unsigned int x264_process_id(void); diff --git a/src/thread_encode.cpp b/src/thread_encode.cpp index 0c6ba4e..6b967ef 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -364,7 +364,7 @@ bool EncodeThread::runEncodingPass(bool x264_x64, bool x264_10bit, bool avs2yuv_ { cmdLine_Input.append(splitParams(m_options->customAvs2YUV())); } - cmdLine_Input << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)); + cmdLine_Input << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true)); cmdLine_Input << "-"; log("Creating Avisynth process:"); if(!startProcess(processInput, AVS2_BINARY(m_binDir, avs2yuv_x64), cmdLine_Input, false)) @@ -373,7 +373,7 @@ bool EncodeThread::runEncodingPass(bool x264_x64, bool x264_10bit, bool avs2yuv_ } break; case INPUT_VAPOUR: - cmdLine_Input << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)); + cmdLine_Input << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true)); cmdLine_Input << "-" << "-y4m"; log("Creating Vapoursynth process:"); if(!startProcess(processInput, VPSP_BINARY(m_vpsDir), cmdLine_Input, false)) @@ -990,7 +990,7 @@ bool EncodeThread::checkPropertiesAvisynth(bool x64, unsigned int &frames) } cmdLine << "-frames" << "1"; - cmdLine << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)) << "NUL"; + cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true)) << "NUL"; log("Creating process:"); if(!startProcess(process, AVS2_BINARY(m_binDir, x64), cmdLine)) @@ -1150,7 +1150,7 @@ bool EncodeThread::checkPropertiesVapoursynth(/*const QString &vspipePath,*/ uns QProcess process; QStringList cmdLine; - cmdLine << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)); + cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true)); cmdLine << "-" << "-info"; log("Creating process:"); diff --git a/src/version.h b/src/version.h index 28afd21..62bd77c 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 2 #define VER_X264_PATCH 5 -#define VER_X264_BUILD 610 +#define VER_X264_BUILD 612 #define VER_X264_MINIMUM_REV 2363 #define VER_X264_CURRENT_API 140