Convert the filename part of "short" paths to lower case, so the Avs2YUV file extension check won't fail.

This commit is contained in:
LoRd_MuldeR 2013-11-08 14:15:40 +01:00
parent 50eec4814f
commit b1ff469728
4 changed files with 19 additions and 12 deletions

View File

@ -1448,23 +1448,30 @@ bool x264_suspendProcess(const QProcess *proc, const bool suspend)
/* /*
* Convert path to short/ANSI path * Convert path to short/ANSI path
*/ */
QString x264_path2ansi(const QString &longPath) QString x264_path2ansi(const QString &longPath, bool makeLowercase)
{ {
QString shortPath = longPath; QString shortPath = longPath;
DWORD buffSize = GetShortPathNameW(reinterpret_cast<const wchar_t*>(longPath.utf16()), NULL, NULL); const QString longPathNative = QDir::toNativeSeparators(longPath);
DWORD buffSize = GetShortPathNameW(QWCHAR(longPathNative), NULL, NULL);
if(buffSize > 0) if(buffSize > 0)
{ {
wchar_t *buffer = new wchar_t[buffSize]; wchar_t *buffer = (wchar_t*) _malloca(sizeof(wchar_t) * buffSize);
DWORD result = GetShortPathNameW(reinterpret_cast<const wchar_t*>(longPath.utf16()), buffer, buffSize); DWORD result = GetShortPathNameW(QWCHAR(longPathNative), buffer, buffSize);
if((result > 0) && (result < buffSize)) if((result > 0) && (result < buffSize))
{ {
shortPath = QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer), result); shortPath = QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer), result));
if(makeLowercase)
{
QFileInfo info(shortPath);
shortPath = QString("%1/%2").arg(info.absolutePath(), info.fileName().toLower());
}
} }
delete[] buffer; _freea(buffer);
buffer = NULL; buffer = NULL;
} }

View File

@ -116,7 +116,7 @@ bool x264_init_qt(int argc, char* argv[]);
bool x264_is_executable(const QString &path); bool x264_is_executable(const QString &path);
bool x264_is_prerelease(void); bool x264_is_prerelease(void);
void x264_message_handler(QtMsgType type, const char *msg); 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_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias = NULL);
bool x264_portable(void); bool x264_portable(void);
unsigned int x264_process_id(void); unsigned int x264_process_id(void);

View File

@ -364,7 +364,7 @@ bool EncodeThread::runEncodingPass(bool x264_x64, bool x264_10bit, bool avs2yuv_
{ {
cmdLine_Input.append(splitParams(m_options->customAvs2YUV())); 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 << "-"; cmdLine_Input << "-";
log("Creating Avisynth process:"); log("Creating Avisynth process:");
if(!startProcess(processInput, AVS2_BINARY(m_binDir, avs2yuv_x64), cmdLine_Input, false)) 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; break;
case INPUT_VAPOUR: case INPUT_VAPOUR:
cmdLine_Input << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)); cmdLine_Input << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true));
cmdLine_Input << "-" << "-y4m"; cmdLine_Input << "-" << "-y4m";
log("Creating Vapoursynth process:"); log("Creating Vapoursynth process:");
if(!startProcess(processInput, VPSP_BINARY(m_vpsDir), cmdLine_Input, false)) 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 << "-frames" << "1";
cmdLine << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)) << "NUL"; cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true)) << "NUL";
log("Creating process:"); log("Creating process:");
if(!startProcess(process, AVS2_BINARY(m_binDir, x64), cmdLine)) if(!startProcess(process, AVS2_BINARY(m_binDir, x64), cmdLine))
@ -1150,7 +1150,7 @@ bool EncodeThread::checkPropertiesVapoursynth(/*const QString &vspipePath,*/ uns
QProcess process; QProcess process;
QStringList cmdLine; QStringList cmdLine;
cmdLine << x264_path2ansi(QDir::toNativeSeparators(m_sourceFileName)); cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFileName, true));
cmdLine << "-" << "-info"; cmdLine << "-" << "-info";
log("Creating process:"); log("Creating process:");

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 2 #define VER_X264_MINOR 2
#define VER_X264_PATCH 5 #define VER_X264_PATCH 5
#define VER_X264_BUILD 610 #define VER_X264_BUILD 612
#define VER_X264_MINIMUM_REV 2363 #define VER_X264_MINIMUM_REV 2363
#define VER_X264_CURRENT_API 140 #define VER_X264_CURRENT_API 140