home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / system / memory.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  3.5 KB  |  85 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    System library component
  3. //    Copyright (C) 1998-2004 Avery Lee, All Rights Reserved.
  4. //
  5. //    Beginning with 1.6.0, the VirtualDub system library is licensed
  6. //    differently than the remainder of VirtualDub.  This particular file is
  7. //    thus licensed as follows (the "zlib" license):
  8. //
  9. //    This software is provided 'as-is', without any express or implied
  10. //    warranty.  In no event will the authors be held liable for any
  11. //    damages arising from the use of this software.
  12. //
  13. //    Permission is granted to anyone to use this software for any purpose,
  14. //    including commercial applications, and to alter it and redistribute it
  15. //    freely, subject to the following restrictions:
  16. //
  17. //    1.    The origin of this software must not be misrepresented; you must
  18. //        not claim that you wrote the original software. If you use this
  19. //        software in a product, an acknowledgment in the product
  20. //        documentation would be appreciated but is not required.
  21. //    2.    Altered source versions must be plainly marked as such, and must
  22. //        not be misrepresented as being the original software.
  23. //    3.    This notice may not be removed or altered from any source
  24. //        distribution.
  25.  
  26. #ifndef f_VD2_SYSTEM_MEMORY_H
  27. #define f_VD2_SYSTEM_MEMORY_H
  28.  
  29. #include <vd2/system/vdtypes.h>
  30.  
  31. void *VDAlignedMalloc(size_t n, unsigned alignment);
  32. void VDAlignedFree(void *p);
  33.  
  34. template<unsigned alignment>
  35. struct VDAlignedObject {
  36.     inline void *operator new(size_t n) { return VDAlignedMalloc(n, alignment); }
  37.     inline void operator delete(void *p) { VDAlignedFree(p); }
  38. };
  39.  
  40. void *VDAlignedVirtualAlloc(size_t n);
  41. void VDAlignedVirtualFree(void *p);
  42.  
  43. extern void (__cdecl *VDSwapMemory)(void *p0, void *p1, size_t bytes);
  44.  
  45. void VDInvertMemory(void *p, unsigned bytes);
  46.  
  47. bool VDIsValidReadRegion(const void *p, size_t bytes);
  48. bool VDIsValidWriteRegion(void *p, size_t bytes);
  49.  
  50. bool VDCompareRect(void *dst, ptrdiff_t dstpitch, const void *src, ptrdiff_t srcpitch, size_t w, size_t h);
  51.  
  52. const void *VDMemCheck8(const void *src, uint8 value, size_t count);
  53.  
  54. void VDMemset8(void *dst, uint8 value, size_t count);
  55. void VDMemset16(void *dst, uint16 value, size_t count);
  56. void VDMemset24(void *dst, uint32 value, size_t count);
  57. void VDMemset32(void *dst, uint32 value, size_t count);
  58. void VDMemset64(void *dst, uint64 value, size_t count);
  59. void VDMemset128(void *dst, const void *value, size_t count);
  60. void VDMemsetPointer(void *dst, const void *value, size_t count);
  61.  
  62. void VDMemset8Rect(void *dst, ptrdiff_t pitch, uint8 value, size_t w, size_t h);
  63. void VDMemset16Rect(void *dst, ptrdiff_t pitch, uint16 value, size_t w, size_t h);
  64. void VDMemset24Rect(void *dst, ptrdiff_t pitch, uint32 value, size_t w, size_t h);
  65. void VDMemset32Rect(void *dst, ptrdiff_t pitch, uint32 value, size_t w, size_t h);
  66.  
  67. #if defined(_WIN32) && defined(_M_IX86)
  68.     extern void (__cdecl *VDFastMemcpyPartial)(void *dst, const void *src, size_t bytes);
  69.     extern void (__cdecl *VDFastMemcpyFinish)();
  70.     void VDFastMemcpyAutodetect();
  71. #else
  72.     void VDFastMemcpyPartial(void *dst, const void *src, size_t bytes);
  73.     void VDFastMemcpyFinish();
  74.     void VDFastMemcpyAutodetect();
  75. #endif
  76.  
  77.  
  78. void VDMemcpyRect(void *dst, ptrdiff_t dststride, const void *src, ptrdiff_t srcstride, size_t w, size_t h);
  79.  
  80. /// Copy a region of memory with an access violation guard; used in cases where a sporadic
  81. /// AV is unavoidable (dynamic Direct3D VB under XP). The regions must not overlap.
  82. bool VDMemcpyGuarded(void *dst, const void *src, size_t bytes);
  83.  
  84. #endif
  85.