diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2013-07-02 13:42:34 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2013-08-09 13:55:42 +0400 |
commit | 294a6c605fc2fbfff84d60f7661c07f55c8024bb (patch) | |
tree | cffbf60879c1926400df7015d02858e12a2dc069 /src/thirdparty/VirtualDub | |
parent | 1db9aa113605b92c5fa1d3c7b3546ae823ff7b02 (diff) |
Update VirtualDub to v1.10.4-test11.
Diffstat (limited to 'src/thirdparty/VirtualDub')
24 files changed, 461 insertions, 63 deletions
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/VDString.h b/src/thirdparty/VirtualDub/h/vd2/system/VDString.h index 09a222d2d..941ea08a9 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/VDString.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/VDString.h @@ -1250,5 +1250,7 @@ template<> VDStringW *vdmove_forward(VDStringW *src1, VDStringW *src2, VDStringW template<> VDStringA *vdmove_backward(VDStringA *src1, VDStringA *src2, VDStringA *dst);
template<> VDStringW *vdmove_backward(VDStringW *src1, VDStringW *src2, VDStringW *dst);
+VDMOVE_CAPABLE(VDStringA);
+VDMOVE_CAPABLE(VDStringW);
#endif
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/binary.h b/src/thirdparty/VirtualDub/h/vd2/system/binary.h index fe3a5afa8..8ab90be3e 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/binary.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/binary.h @@ -35,20 +35,17 @@ #define VDMAKEFOURCC(byte1, byte2, byte3, byte4) (((uint8)byte1) + (((uint8)byte2) << 8) + (((uint8)byte3) << 16) + (((uint8)byte4) << 24))
#ifdef _MSC_VER
- unsigned short _byteswap_ushort(unsigned short);
- unsigned long _byteswap_ulong(unsigned long);
- unsigned __int64 _byteswap_uint64(unsigned __int64);
-
- #pragma intrinsic(_byteswap_ushort)
- #pragma intrinsic(_byteswap_ulong)
- #pragma intrinsic(_byteswap_uint64)
+ #include <vd2/system/win32/intrin.h>
inline uint16 VDSwizzleU16(uint16 value) { return (uint16)_byteswap_ushort((unsigned short)value); }
inline sint16 VDSwizzleS16(sint16 value) { return (sint16)_byteswap_ushort((unsigned short)value); }
inline uint32 VDSwizzleU32(uint32 value) { return (uint32)_byteswap_ulong((unsigned long)value); }
inline sint32 VDSwizzleS32(sint32 value) { return (sint32)_byteswap_ulong((unsigned long)value); }
- inline uint64 VDSwizzleU64(uint64 value) { return (uint32)_byteswap_uint64((unsigned __int64)value); }
- inline sint64 VDSwizzleS64(sint64 value) { return (sint32)_byteswap_uint64((unsigned __int64)value); }
+ inline uint64 VDSwizzleU64(uint64 value) { return (uint64)_byteswap_uint64((unsigned __int64)value); }
+ inline sint64 VDSwizzleS64(sint64 value) { return (sint64)_byteswap_uint64((unsigned __int64)value); }
+
+ inline uint32 VDRotateLeftU32(uint32 value, int bits) { return (uint32)_rotl((unsigned int)value, bits); }
+ inline uint32 VDRotateRightU32(uint32 value, int bits) { return (uint32)_rotr((unsigned int)value, bits); }
#else
inline uint16 VDSwizzleU16(uint16 value) {
return (value >> 8) + (value << 8);
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/filesys.h b/src/thirdparty/VirtualDub/h/vd2/system/filesys.h index 10e529501..121a2dffe 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/filesys.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/filesys.h @@ -188,6 +188,8 @@ uint64 VDFileGetLastWriteTime(const wchar_t *path); VDStringW VDFileGetRootPath(const wchar_t *partialPath);
VDStringW VDGetFullPath(const wchar_t *partialPath);
+extern VDStringW (*VDGetLongPath)(const wchar_t *path);
+
VDStringW VDMakePath(const wchar_t *base, const wchar_t *file);
bool VDFileIsPathEqual(const wchar_t *path1, const wchar_t *path2);
void VDFileFixDirPath(VDStringW& path);
@@ -196,6 +198,9 @@ VDStringW VDGetProgramPath(); VDStringW VDGetProgramFilePath();
VDStringW VDGetSystemPath();
+void VDGetRootPaths(vdvector<VDStringW>& paths);
+VDStringW VDGetRootVolumeLabel(const wchar_t *rootPath);
+
/////////////////////////////////////////////////////////////////////////////
enum VDFileAttributes {
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/filewatcher.h b/src/thirdparty/VirtualDub/h/vd2/system/filewatcher.h index db1a02312..f38b4432d 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/filewatcher.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/filewatcher.h @@ -23,6 +23,7 @@ public: bool IsActive() const;
void Init(const wchar_t *file, IVDFileWatcherCallback *cb);
+ void InitDir(const wchar_t *path, bool subdirs, IVDFileWatcherCallback *cb);
void Shutdown();
bool Wait(uint32 delay = 0xFFFFFFFFU);
@@ -32,6 +33,7 @@ protected: void *mChangeHandle;
uint64 mLastWriteTime;
+ bool mbWatchDir;
VDStringW mPath;
IVDFileWatcherCallback *mpCB;
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/linearalloc.h b/src/thirdparty/VirtualDub/h/vd2/system/linearalloc.h index 4fd847152..08a35dc3a 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/linearalloc.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/linearalloc.h @@ -13,6 +13,8 @@ public: void *Allocate(size_t bytes) {
void *p = mpAllocPtr;
+ bytes = (bytes + sizeof(void *) - 1) & ((size_t)0 - (size_t)sizeof(void *));
+
if (mAllocLeft < bytes)
p = AllocateSlow(bytes);
else {
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/source/registrymemory.cpp b/src/thirdparty/VirtualDub/h/vd2/system/source/registrymemory.cpp index ba850ab17..020e7d668 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/source/registrymemory.cpp +++ b/src/thirdparty/VirtualDub/h/vd2/system/source/registrymemory.cpp @@ -239,6 +239,9 @@ void VDRegistryProviderMemory::Key::Remove(VDRegistryProviderMemory::Key *key) { }
bool VDRegistryProviderMemory::Key::RemoveKey(const char *name) {
+ if (!name)
+ name = "";
+
// look up the subkey
KeyMap::iterator it(mKeyMap.find_as(name));
@@ -268,6 +271,9 @@ bool VDRegistryProviderMemory::Key::RemoveKey(const char *name) { }
bool VDRegistryProviderMemory::Key::RemoveValue(const char *name) {
+ if (!name)
+ name = "";
+
ValueMap::iterator it(mValueMap.find_as(name));
if (it == mValueMap.end())
@@ -282,6 +288,9 @@ bool VDRegistryProviderMemory::Key::RemoveValue(const char *name) { }
VDRegistryProviderMemory::Value *VDRegistryProviderMemory::Key::OpenValue(const char *name, bool create) {
+ if (!name)
+ name = "";
+
ValueMap::iterator it(mValueMap.find_as(name));
if (it != mValueMap.end())
@@ -638,6 +647,9 @@ void *VDRegistryProviderMemory::EnumValuesBegin(void *key) { const char *VDRegistryProviderMemory::EnumValuesNext(void *enumerator) {
Enumerator *en = (Enumerator *)enumerator;
+ if (!en->mKey)
+ return NULL;
+
vdsynchronized(mMutex) {
const char *s = en->mKey->GetValueName(en->mIndex);
if (!s)
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/time.h b/src/thirdparty/VirtualDub/h/vd2/system/time.h index e2da3ce4a..ecf49651a 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/time.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/time.h @@ -105,12 +105,14 @@ public: ~VDLazyTimer();
void SetOneShot(IVDTimerCallback *pCB, uint32 delay);
+ void SetPeriodic(IVDTimerCallback *pCB, uint32 delay);
void Stop();
protected:
void StaticTimeCallback(VDZHWND hwnd, VDZUINT msg, VDZUINT_PTR id, VDZDWORD time);
uint32 mTimerId;
+ bool mbPeriodic;
VDFunctionThunk *mpThunk;
IVDTimerCallback *mpCB;
};
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/vdalloc.h b/src/thirdparty/VirtualDub/h/vd2/system/vdalloc.h index 96039754a..66a98ba1d 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/vdalloc.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/vdalloc.h @@ -134,6 +134,57 @@ public: T *release() { T *v = ptr; ptr = NULL; return v; }
};
+///////////////////////////////////////////////////////////////////////////
+
+struct vdsafedelete_t {};
+extern vdsafedelete_t vdsafedelete;
+
+template<class T>
+inline vdsafedelete_t& operator<<=(vdsafedelete_t& x, T *& p) {
+ if (p) {
+ delete p;
+ p = 0;
+ }
+
+ return x;
+}
+
+template<class T>
+inline vdsafedelete_t& operator,(vdsafedelete_t& x, T *& p) {
+ if (p) {
+ delete p
+ p = 0;
+ }
+
+ return x;
+}
+
+template<class T, size_t N>
+inline vdsafedelete_t& operator<<=(vdsafedelete_t& x, T *(&p)[N]) {
+ for(size_t i=0; i<N; ++i) {
+ if (p[i]) {
+ delete p[i];
+ p[i] = 0;
+ }
+ }
+
+ return x;
+}
+
+template<class T, size_t N>
+inline vdsafedelete_t& operator,(vdsafedelete_t& x, T *(&p)[N]) {
+ for(size_t i=0; i<N; ++i) {
+ if (p[i]) {
+ delete p[i];
+ p[i] = 0;
+ }
+ }
+
+ return x;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
#pragma warning(pop)
#endif
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/vdstl.h b/src/thirdparty/VirtualDub/h/vd2/system/vdstl.h index d0f70bc71..8084b60ee 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/vdstl.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/vdstl.h @@ -54,8 +54,17 @@ struct vdreverse_iterator { ///////////////////////////////////////////////////////////////////////////
+struct vdfalse_type { };
+struct vdtrue_type { };
+
+struct vdfalse_result { typedef vdfalse_type result; };
+struct vdtrue_result { typedef vdtrue_type result; };
+
+template<class T> void vdmove(T& dst, T& src);
+template<class T> struct vdmove_capable : public vdfalse_result {};
+
template<class T>
-T *vdmove_forward(T *src1, T *src2, T *dst) {
+T *vdmove_forward_impl(T *src1, T *src2, T *dst, vdfalse_type) {
T *p = src1;
while(p != src2) {
*dst = *p;
@@ -67,7 +76,7 @@ T *vdmove_forward(T *src1, T *src2, T *dst) { }
template<class T>
-T *vdmove_backward(T *src1, T *src2, T *dst) {
+T *vdmove_backward_impl(T *src1, T *src2, T *dst, vdfalse_type) {
T *p = src2;
while(p != src1) {
--dst;
@@ -78,7 +87,52 @@ T *vdmove_backward(T *src1, T *src2, T *dst) { return dst;
}
+template<class T>
+T *vdmove_forward_impl(T *src1, T *src2, T *dst, vdtrue_type) {
+ T *p = src1;
+ while(p != src2) {
+ vdmove(*dst, *p);
+ ++dst;
+ ++p;
+ }
+
+ return dst;
+}
+
+template<class T>
+T *vdmove_backward_impl(T *src1, T *src2, T *dst, vdtrue_type) {
+ T *p = src2;
+ while(p != src1) {
+ --dst;
+ --p;
+ vdmove(*dst, *p);
+ }
+
+ return dst;
+}
+
+template<class T>
+T *vdmove_forward(T *src1, T *src2, T *dst) {
+ return vdmove_forward_impl(src1, src2, dst, vdmove_capable<T>::result());
+}
+
+template<class T>
+T *vdmove_backward(T *src1, T *src2, T *dst) {
+ return vdmove_backward_impl(src1, src2, dst, vdmove_capable<T>::result());
+}
+
+#define VDMOVE_CAPABLE(type) \
+ template<> struct vdmove_capable<type> : public vdtrue_result {}; \
+ template<> void vdmove<type>(type& dst, type& src)
+
///////////////////////////////////////////////////////////////////////////
+
+template<class T, size_t N> char (&VDCountOfHelper(const T(&)[N]))[N];
+
+#define vdcountof(array) (sizeof(VDCountOfHelper(array)))
+
+///////////////////////////////////////////////////////////////////////////
+
class vdallocator_base {
protected:
void VDNORETURN throw_oom(size_t n, size_t elsize);
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/vdstl_hash.h b/src/thirdparty/VirtualDub/h/vd2/system/vdstl_hash.h index a7957e8c2..28f1f673e 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/vdstl_hash.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/vdstl_hash.h @@ -112,6 +112,13 @@ template<class T> struct vdhash<T *> { size_t operator()(T *val) const { return (size_t)val; }
};
+struct vdstringhashi {
+ size_t operator()(const VDStringA& s) const;
+ size_t operator()(const char *s) const;
+ size_t operator()(const VDStringW& s) const;
+ size_t operator()(const wchar_t *s) const;
+};
+
struct vdstringpred {
bool operator()(const VDStringA& s, const VDStringA& t) const;
bool operator()(const VDStringA& s, const VDStringSpanA& t) const;
@@ -121,4 +128,13 @@ struct vdstringpred { bool operator()(const VDStringW& s, const wchar_t *t) const;
};
+struct vdstringpredi {
+ bool operator()(const VDStringA& s, const VDStringA& t) const;
+ bool operator()(const VDStringA& s, const VDStringSpanA& t) const;
+ bool operator()(const VDStringA& s, const char *t) const;
+ bool operator()(const VDStringW& s, const VDStringW& t) const;
+ bool operator()(const VDStringW& s, const VDStringSpanW& t) const;
+ bool operator()(const VDStringW& s, const wchar_t *t) const;
+};
+
#endif // f_VD2_SYSTEM_VDSTL_HASH_H
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/vectors.h b/src/thirdparty/VirtualDub/h/vd2/system/vectors.h index 6b0f799f0..a7957a4d1 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/vectors.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/vectors.h @@ -458,6 +458,7 @@ public: void translate(T x, T y);
void scale(T x, T y);
void transform(T scaleX, T scaleY, T offsetX, T offsety);
+ void resize(T w, T h);
bool operator==(const VDRect& r) const;
bool operator!=(const VDRect& r) const;
@@ -566,6 +567,12 @@ void VDRect<T>::transform(T scaleX, T scaleY, T offsetX, T offsetY) { }
template<class T>
+void VDRect<T>::resize(T w, T h) {
+ right = left + w;
+ bottom = top + h;
+}
+
+template<class T>
bool VDRect<T>::operator==(const VDRect& r) const { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; }
template<class T>
diff --git a/src/thirdparty/VirtualDub/h/vd2/system/w32assist.h b/src/thirdparty/VirtualDub/h/vd2/system/w32assist.h index c231717f0..a92da8723 100644 --- a/src/thirdparty/VirtualDub/h/vd2/system/w32assist.h +++ b/src/thirdparty/VirtualDub/h/vd2/system/w32assist.h @@ -69,6 +69,7 @@ void VDSetWindowTextFW32(HWND hwnd, const wchar_t *format, ...); VDStringA VDGetWindowTextAW32(HWND hwnd);
VDStringW VDGetWindowTextW32(HWND hwnd);
void VDAppendMenuW32(HMENU hmenu, UINT flags, UINT id, const wchar_t *text);
+bool VDAppendPopupMenuW32(HMENU hmenu, UINT flags, HMENU hmenuPopup, const wchar_t *text);
void VDAppendMenuSeparatorW32(HMENU hmenu);
void VDCheckMenuItemByPositionW32(HMENU hmenu, uint32 pos, bool checked);
void VDCheckMenuItemByCommandW32(HMENU hmenu, UINT cmd, bool checked);
diff --git a/src/thirdparty/VirtualDub/system/h/stdafx.h b/src/thirdparty/VirtualDub/system/h/stdafx.h index 11f0391b5..950889964 100644 --- a/src/thirdparty/VirtualDub/system/h/stdafx.h +++ b/src/thirdparty/VirtualDub/system/h/stdafx.h @@ -1,3 +1,8 @@ +// Force C locale to avoid this warning:
+//
+// mmreg.h : warning C4819: The file contains a character that cannot be represented in the current code page (932). Save the file in Unicode format to prevent data loss
+#pragma setlocale("C")
+
/* MPC-HC comment out
// Detect the Windows SDK in use and select Windows 2000 baseline
// if the Vista SDK, else Windows 98 baseline.
diff --git a/src/thirdparty/VirtualDub/system/source/VDString.cpp b/src/thirdparty/VirtualDub/system/source/VDString.cpp index a14d29ade..dc9a614bc 100644 --- a/src/thirdparty/VirtualDub/system/source/VDString.cpp +++ b/src/thirdparty/VirtualDub/system/source/VDString.cpp @@ -223,7 +223,9 @@ VDStringW& VDStringW::append_vsprintf(const value_type *format, va_list val) { }
void VDStringW::move_from(VDStringW& src) {
- delete[] mpBegin;
+ if (mpBegin != sNull)
+ delete[] mpBegin;
+
mpBegin = src.mpBegin;
mpEnd = src.mpEnd;
mpEOS = src.mpEOS;
@@ -282,3 +284,13 @@ VDStringW *vdmove_backward(VDStringW *src1, VDStringW *src2, VDStringW *dst) { return dst;
}
+
+template<>
+void vdmove<VDStringA>(VDStringA& dst, VDStringA& src) {
+ dst.move_from(src);
+}
+
+template<>
+void vdmove<VDStringW>(VDStringW& dst, VDStringW& src) {
+ dst.move_from(src);
+}
diff --git a/src/thirdparty/VirtualDub/system/source/error_win32.cpp b/src/thirdparty/VirtualDub/system/source/error_win32.cpp index 36e8c02e5..72cee57de 100644 --- a/src/thirdparty/VirtualDub/system/source/error_win32.cpp +++ b/src/thirdparty/VirtualDub/system/source/error_win32.cpp @@ -74,31 +74,6 @@ MyICError::MyICError(uint32 icErr, const char *format, ...) { setf(tmpbuf, GetVCMErrorString(icErr)); } -MyMMIOError::MyMMIOError(const char *s, uint32 mmioerr) { - const char *err = "(Unknown)"; - - switch(mmioerr) { - case MMIOERR_FILENOTFOUND: err = "file not found"; break; - case MMIOERR_OUTOFMEMORY: err = "out of memory"; break; - case MMIOERR_CANNOTOPEN: err = "couldn't open"; break; - case MMIOERR_CANNOTCLOSE: err = "couldn't close"; break; - case MMIOERR_CANNOTREAD: err = "couldn't read"; break; - case MMIOERR_CANNOTWRITE: err = "couldn't write"; break; - case MMIOERR_CANNOTSEEK: err = "couldn't seek"; break; - case MMIOERR_CANNOTEXPAND: err = "couldn't expand"; break; - case MMIOERR_CHUNKNOTFOUND: err = "chunk not found"; break; - case MMIOERR_UNBUFFERED: err = "unbuffered"; break; - case MMIOERR_PATHNOTFOUND: err = "path not found"; break; - case MMIOERR_ACCESSDENIED: err = "access denied"; break; - case MMIOERR_SHARINGVIOLATION: err = "sharing violation"; break; - case MMIOERR_NETWORKERROR: err = "network error"; break; - case MMIOERR_TOOMANYOPENFILES: err = "too many open files"; break; - case MMIOERR_INVALIDFILE: err = "invalid file"; break; - } - - setf("%s error: %s (%ld)", s, err, mmioerr); -} - MyAVIError::MyAVIError(const char *s, uint32 avierr) { const char *err = "(Unknown)"; @@ -199,24 +174,3 @@ MyWin32Error::MyWin32Error(const char *format, uint32 err, ...) setf(szTemp, szError); } - -MyCrashError::MyCrashError(const char *format, uint32 dwExceptionCode) { - const char *s = "(Unknown Exception)"; - - switch(dwExceptionCode) { - case EXCEPTION_ACCESS_VIOLATION: - s = "Access Violation"; - break; - case EXCEPTION_PRIV_INSTRUCTION: - s = "Privileged Instruction"; - break; - case EXCEPTION_INT_DIVIDE_BY_ZERO: - s = "Integer Divide By Zero"; - break; - case EXCEPTION_BREAKPOINT: - s = "User Breakpoint"; - break; - } - - setf(format, s); -} diff --git a/src/thirdparty/VirtualDub/system/source/filesys.cpp b/src/thirdparty/VirtualDub/system/source/filesys.cpp index d64180e28..0c62d1d75 100644 --- a/src/thirdparty/VirtualDub/system/source/filesys.cpp +++ b/src/thirdparty/VirtualDub/system/source/filesys.cpp @@ -739,6 +739,67 @@ VDStringW VDGetFullPath(const wchar_t *partialPath) { }
}
+VDStringW VDGetLongPathA(const wchar_t *s) {
+ const VDStringA& pathA = VDTextWToA(s);
+ CHAR buf[MAX_PATH];
+
+ DWORD len = GetLongPathNameA(pathA.c_str(), buf, MAX_PATH);
+ VDStringW longPath;
+
+ if (!len)
+ longPath = s;
+ else if (len <= MAX_PATH)
+ longPath = VDTextAToW(buf);
+ else if (len > MAX_PATH) {
+ vdfastvector<CHAR> extbuf(len, 0);
+
+ DWORD len2 = GetLongPathNameA(pathA.c_str(), extbuf.data(), len);
+
+ if (len2 && len2 <= len)
+ longPath = VDTextAToW(extbuf.data());
+ else
+ longPath = s;
+ }
+
+ return longPath;
+}
+
+VDStringW VDGetLongPathW(const wchar_t *s) {
+ WCHAR buf[MAX_PATH];
+
+ DWORD len = GetLongPathNameW(s, buf, MAX_PATH);
+ VDStringW longPath;
+
+ if (!len)
+ longPath = s;
+ else if (len <= MAX_PATH)
+ longPath = buf;
+ else if (len > MAX_PATH) {
+ vdfastvector<WCHAR> extbuf(len, 0);
+
+ DWORD len2 = GetLongPathNameW(s, extbuf.data(), len);
+
+ if (len2 && len2 <= len)
+ longPath = extbuf.data();
+ else
+ longPath = s;
+ }
+
+ return longPath;
+}
+
+#if VD_CPU_X86
+ VDStringW VDGetLongPathAutodetect(const wchar_t *s) {
+ VDGetLongPath = VDIsWindowsNT() ? VDGetLongPathW : VDGetLongPathA;
+
+ return VDGetLongPath(s);
+ }
+
+ extern VDStringW (*VDGetLongPath)(const wchar_t *path) = VDGetLongPathAutodetect;
+#else
+ extern VDStringW (*VDGetLongPath)(const wchar_t *path) = VDGetLongPathW;
+#endif
+
VDStringW VDMakePath(const wchar_t *base, const wchar_t *file) {
if (!*base)
return VDStringW(file);
@@ -890,6 +951,86 @@ VDStringW VDGetSystemPath() { return VDGetSystemPath9x();
}
+void VDGetRootPaths(vdvector<VDStringW>& paths) {
+ union {
+ WCHAR w[512];
+ CHAR a[1024];
+ } buf;
+
+ if (VDIsWindowsNT()) {
+ vdfastvector<WCHAR> heapbufw;
+ WCHAR *pw = buf.w;
+ DWORD wlen = vdcountof(buf.w);
+
+ for(;;) {
+ *pw = 0;
+
+ DWORD r = GetLogicalDriveStringsW(wlen, pw);
+
+ if (!r)
+ return;
+
+ if (r <= wlen)
+ break;
+
+ heapbufw.resize(r);
+ wlen = r;
+ pw = heapbufw.data();
+ }
+
+ while(*pw) {
+ paths.push_back() = pw;
+ pw += wcslen(pw) + 1;
+ }
+ } else {
+ vdfastvector<CHAR> heapbufa;
+ CHAR *pa = buf.a;
+ DWORD alen = vdcountof(buf.a);
+
+ for(;;) {
+ *pa = 0;
+
+ DWORD r = GetLogicalDriveStringsA(alen, pa);
+
+ if (!r)
+ return;
+
+ if (r <= alen)
+ break;
+
+ heapbufa.resize(r);
+ alen = r;
+ pa = heapbufa.data();
+ }
+
+ while(*pa) {
+ paths.push_back() = VDTextAToW(pa);
+ pa += strlen(pa) + 1;
+ }
+ }
+}
+
+VDStringW VDGetRootVolumeLabel(const wchar_t *rootPath) {
+ union {
+ char a[MAX_PATH * 2];
+ wchar_t w[MAX_PATH];
+ } buf;
+
+ DWORD maxComponentLength;
+ DWORD fsFlags;
+ VDStringW name;
+
+ if (VDIsWindowsNT()) {
+ if (GetVolumeInformationW(rootPath, buf.w, vdcountof(buf.w), NULL, &maxComponentLength, &fsFlags, NULL, 0))
+ name = buf.w;
+ } else {
+ if (GetVolumeInformationA(VDTextWToA(rootPath).c_str(), buf.a, vdcountof(buf.a), NULL, &maxComponentLength, &fsFlags, NULL, 0))
+ name = VDTextAToW(buf.a);
+ }
+
+ return name;
+}
+
uint32 VDFileGetAttributesFromNativeW32(uint32 nativeAttrs) {
if (nativeAttrs == INVALID_FILE_ATTRIBUTES)
return kVDFileAttr_Invalid;
diff --git a/src/thirdparty/VirtualDub/system/source/filewatcher.cpp b/src/thirdparty/VirtualDub/system/source/filewatcher.cpp index 3d32150fd..f09c8dcf3 100644 --- a/src/thirdparty/VirtualDub/system/source/filewatcher.cpp +++ b/src/thirdparty/VirtualDub/system/source/filewatcher.cpp @@ -8,6 +8,7 @@ VDFileWatcher::VDFileWatcher()
: mChangeHandle(INVALID_HANDLE_VALUE)
, mLastWriteTime(0)
+ , mbWatchDir(false)
, mbRepeatRequested(false)
, mbThunksInited(false)
, mpThunk(NULL)
@@ -45,6 +46,43 @@ void VDFileWatcher::Init(const wchar_t *file, IVDFileWatcherCallback *callback) mLastWriteTime = VDFileGetLastWriteTime(mPath.c_str());
mpCB = callback;
mbRepeatRequested = false;
+ mbWatchDir = false;
+
+ if (callback) {
+ if (!mbThunksInited)
+ mbThunksInited = VDInitThunkAllocator();
+
+ if (mbThunksInited) {
+ mpThunk = VDCreateFunctionThunkFromMethod(this, &VDFileWatcher::StaticTimerCallback, true);
+
+ if (mpThunk) {
+ mTimerId = SetTimer(NULL, 0, 1000, (TIMERPROC)mpThunk);
+ }
+ }
+ }
+}
+
+void VDFileWatcher::InitDir(const wchar_t *path, bool subdirs, IVDFileWatcherCallback *callback) {
+ Shutdown();
+
+ const DWORD flags
+ = FILE_NOTIFY_CHANGE_SIZE
+ | FILE_NOTIFY_CHANGE_ATTRIBUTES
+ | FILE_NOTIFY_CHANGE_LAST_WRITE
+ | FILE_NOTIFY_CHANGE_FILE_NAME
+ | FILE_NOTIFY_CHANGE_CREATION;
+ if (VDIsWindowsNT())
+ mChangeHandle = FindFirstChangeNotificationW(path, subdirs, flags);
+ else
+ mChangeHandle = FindFirstChangeNotificationA(VDTextWToA(path).c_str(), subdirs, flags);
+
+ if (mChangeHandle == INVALID_HANDLE_VALUE)
+ throw MyError("Unable to monitor path: %ls", path);
+
+ mPath = path;
+ mpCB = callback;
+ mbRepeatRequested = false;
+ mbWatchDir = true;
if (callback) {
if (!mbThunksInited)
@@ -92,12 +130,14 @@ bool VDFileWatcher::Wait(uint32 delay) { FindNextChangeNotification(mChangeHandle);
- uint64 t = VDFileGetLastWriteTime(mPath.c_str());
+ if (!mbWatchDir) {
+ uint64 t = VDFileGetLastWriteTime(mPath.c_str());
- if (mLastWriteTime == t)
- return false;
+ if (mLastWriteTime == t)
+ return false;
- mLastWriteTime = t;
+ mLastWriteTime = t;
+ }
return true;
}
diff --git a/src/thirdparty/VirtualDub/system/source/linearalloc.cpp b/src/thirdparty/VirtualDub/system/source/linearalloc.cpp index 9758c11c6..e1b02c4f8 100644 --- a/src/thirdparty/VirtualDub/system/source/linearalloc.cpp +++ b/src/thirdparty/VirtualDub/system/source/linearalloc.cpp @@ -26,6 +26,8 @@ void VDLinearAllocator::Clear() { } mpBlocks = NULL; + mpAllocPtr = NULL; + mAllocLeft = 0; } void *VDLinearAllocator::AllocateSlow(size_t bytes) { diff --git a/src/thirdparty/VirtualDub/system/source/time.cpp b/src/thirdparty/VirtualDub/system/source/time.cpp index 14e2c892e..35e90bbc9 100644 --- a/src/thirdparty/VirtualDub/system/source/time.cpp +++ b/src/thirdparty/VirtualDub/system/source/time.cpp @@ -232,6 +232,7 @@ void VDCallbackTimer::ThreadRun() { VDLazyTimer::VDLazyTimer()
: mTimerId(0)
, mpCB(NULL)
+ , mbPeriodic(false)
{
if (!VDInitThunkAllocator())
throw MyError("Unable to initialize thunk allocator.");
@@ -253,6 +254,15 @@ VDLazyTimer::~VDLazyTimer() { void VDLazyTimer::SetOneShot(IVDTimerCallback *pCB, uint32 delay) {
Stop();
+ mbPeriodic = false;
+ mpCB = pCB;
+ mTimerId = SetTimer(NULL, 0, delay, (TIMERPROC)mpThunk);
+}
+
+void VDLazyTimer::SetPeriodic(IVDTimerCallback *pCB, uint32 delay) {
+ Stop();
+
+ mbPeriodic = true;
mpCB = pCB;
mTimerId = SetTimer(NULL, 0, delay, (TIMERPROC)mpThunk);
}
@@ -265,7 +275,8 @@ void VDLazyTimer::Stop() { }
void VDLazyTimer::StaticTimeCallback(VDZHWND hwnd, VDZUINT msg, VDZUINT_PTR id, VDZDWORD time) {
- Stop();
+ if (!mbPeriodic)
+ Stop();
if (mpCB)
mpCB->TimerCallback();
diff --git a/src/thirdparty/VirtualDub/system/source/vdalloc.cpp b/src/thirdparty/VirtualDub/system/source/vdalloc.cpp new file mode 100644 index 000000000..228437de9 --- /dev/null +++ b/src/thirdparty/VirtualDub/system/source/vdalloc.cpp @@ -0,0 +1,29 @@ +// VirtualDub - Video processing and capture application +// System library component +// Copyright (C) 1998-2012 Avery Lee, All Rights Reserved. +// +// Beginning with 1.6.0, the VirtualDub system library is licensed +// differently than the remainder of VirtualDub. This particular file is +// thus licensed as follows (the "zlib" license): +// +// 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 "stdafx.h" +#include <vd2/system/vdalloc.h> + +vdsafedelete_t vdsafedelete; diff --git a/src/thirdparty/VirtualDub/system/source/vdstl_hash.cpp b/src/thirdparty/VirtualDub/system/source/vdstl_hash.cpp index d68c6546f..8e842eada 100644 --- a/src/thirdparty/VirtualDub/system/source/vdstl_hash.cpp +++ b/src/thirdparty/VirtualDub/system/source/vdstl_hash.cpp @@ -44,6 +44,22 @@ size_t vdhash<VDStringW>::operator()(const wchar_t *s) const { return VDHashString32(s, wcslen(s));
}
+size_t vdstringhashi::operator()(const VDStringA& s) const {
+ return VDHashString32I(s.data(), s.length());
+}
+
+size_t vdstringhashi::operator()(const char *s) const {
+ return VDHashString32I(s);
+}
+
+size_t vdstringhashi::operator()(const VDStringW& s) const {
+ return VDHashString32I(s.data(), s.length());
+}
+
+size_t vdstringhashi::operator()(const wchar_t *s) const {
+ return VDHashString32I(s);
+}
+
bool vdstringpred::operator()(const VDStringA& s, const VDStringA& t) const {
return s == t;
}
@@ -67,3 +83,27 @@ bool vdstringpred::operator()(const VDStringW& s, const VDStringSpanW& t) const bool vdstringpred::operator()(const VDStringW& s, const wchar_t *t) const {
return s == t;
}
+
+bool vdstringpredi::operator()(const VDStringA& s, const VDStringA& t) const {
+ return s.comparei(t) == 0;
+}
+
+bool vdstringpredi::operator()(const VDStringA& s, const VDStringSpanA& t) const {
+ return s.comparei(t) == 0;
+}
+
+bool vdstringpredi::operator()(const VDStringA& s, const char *t) const {
+ return s.comparei(t) == 0;
+}
+
+bool vdstringpredi::operator()(const VDStringW& s, const VDStringW& t) const {
+ return s.comparei(t) == 0;
+}
+
+bool vdstringpredi::operator()(const VDStringW& s, const VDStringSpanW& t) const {
+ return s.comparei(t) == 0;
+}
+
+bool vdstringpredi::operator()(const VDStringW& s, const wchar_t *t) const {
+ return s.comparei(t) == 0;
+}
diff --git a/src/thirdparty/VirtualDub/system/source/w32assist.cpp b/src/thirdparty/VirtualDub/system/source/w32assist.cpp index 76b6e516f..311810dc5 100644 --- a/src/thirdparty/VirtualDub/system/source/w32assist.cpp +++ b/src/thirdparty/VirtualDub/system/source/w32assist.cpp @@ -176,6 +176,15 @@ void VDAppendMenuW32(HMENU hmenu, UINT flags, UINT id, const wchar_t *text){ }
}
+bool VDAppendPopupMenuW32(HMENU hmenu, UINT flags, HMENU hmenuPopup, const wchar_t *text){
+ flags |= MF_POPUP;
+
+ if (VDIsWindowsNT())
+ return 0 != AppendMenuW(hmenu, flags, (UINT_PTR)hmenuPopup, text);
+ else
+ return 0 != AppendMenuA(hmenu, flags, (UINT_PTR)hmenuPopup, VDTextWToA(text).c_str());
+}
+
void VDAppendMenuSeparatorW32(HMENU hmenu) {
int pos = GetMenuItemCount(hmenu);
if (pos < 0)
diff --git a/src/thirdparty/VirtualDub/system/system.vcxproj b/src/thirdparty/VirtualDub/system/system.vcxproj index 9105f3f35..978b73412 100644 --- a/src/thirdparty/VirtualDub/system/system.vcxproj +++ b/src/thirdparty/VirtualDub/system/system.vcxproj @@ -147,6 +147,7 @@ <ClCompile Include="source\thunk.cpp" />
<ClCompile Include="source\time.cpp" />
<ClCompile Include="source\tls.cpp" />
+ <ClCompile Include="source\vdalloc.cpp" />
<ClCompile Include="source\VDNamespace.cpp" />
<ClCompile Include="source\VDScheduler.cpp" />
<ClCompile Include="source\vdstl.cpp" />
diff --git a/src/thirdparty/VirtualDub/system/system.vcxproj.filters b/src/thirdparty/VirtualDub/system/system.vcxproj.filters index 636791437..b6839cba4 100644 --- a/src/thirdparty/VirtualDub/system/system.vcxproj.filters +++ b/src/thirdparty/VirtualDub/system/system.vcxproj.filters @@ -129,6 +129,9 @@ <ClCompile Include="source\tls.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="source\vdalloc.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="source\VDNamespace.cpp">
<Filter>Source Files</Filter>
</ClCompile>
|