Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // File: quicktime_common.h
  4. //
  5. // QuickTime limits and constants shared among all QuickTime functions
  6. //
  7. //=============================================================================
  8. #ifndef QUICKTIME_COMMON_H
  9. #define QUICKTIME_COMMON_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #ifdef OSX
  14. // The OSX 10.7 SDK dropped support for the functions below, so we manually pull them in
  15. #include <dlfcn.h>
  16. typedef PixMapHandle
  17. (*PFNGetGWorldPixMap)(GWorldPtr offscreenGWorld);
  18. typedef Ptr
  19. (*PFNGetPixBaseAddr)(PixMapHandle pm);
  20. typedef Boolean
  21. (*PFNLockPixels)(PixMapHandle pm);
  22. typedef void
  23. (*PFNUnlockPixels)(PixMapHandle pm);
  24. typedef void
  25. (*PFNDisposeGWorld)(GWorldPtr offscreenGWorld);
  26. typedef void
  27. (*PFNSetGWorld)(CGrafPtr port,GDHandle gdh);
  28. typedef SInt32
  29. (*PFNGetPixRowBytes)(PixMapHandle pm);
  30. extern PFNGetGWorldPixMap GetGWorldPixMap;
  31. extern PFNGetPixBaseAddr GetPixBaseAddr;
  32. extern PFNLockPixels LockPixels;
  33. extern PFNUnlockPixels UnlockPixels;
  34. extern PFNDisposeGWorld DisposeGWorld;
  35. extern PFNSetGWorld SetGWorld;
  36. extern PFNGetPixRowBytes GetPixRowBytes;
  37. #endif
  38. // constant that define the bounds of various inputs
  39. static const int cMinVideoFrameWidth = 16;
  40. static const int cMinVideoFrameHeight = 16;
  41. static const int cMaxVideoFrameWidth = 2 * 2048;
  42. static const int cMaxVideoFrameHeight = 2 * 2048;
  43. static const int cMinFPS = 1;
  44. static const int cMaxFPS = 600;
  45. static const float cMinDuration = 0.016666666f; // 1/60th second
  46. static const float cMaxDuration = 3600.0f; // 1 Hour
  47. static const int cMinSampleRate = 11025; // 1/4 CD sample rate
  48. static const int cMaxSampleRate = 88200; // 2x CD rate
  49. #define NO_MORE_INTERESTING_TIMES -2
  50. #define END_OF_QUICKTIME_MOVIE -1
  51. // ===========================================================================
  52. // Macros & Utility functions
  53. // ===========================================================================
  54. #define SAFE_DISPOSE_HANDLE( _handle ) if ( _handle != nullptr ) { DisposeHandle( (Handle) _handle ); _handle = nullptr; }
  55. #define SAFE_DISPOSE_GWORLD( _gworld ) if ( _gworld != nullptr ) { DisposeGWorld( _gworld ); _gworld = nullptr; }
  56. #define SAFE_DISPOSE_MOVIE( _movie ) if ( _movie != nullptr ) { DisposeMovie( _movie ); ThreadSleep(10); Assert( GetMoviesError() == noErr ); _movie = nullptr; }
  57. #define SAFE_RELEASE_AUDIOCONTEXT( _cxt ) if ( _cxt != nullptr ) { QTAudioContextRelease( _cxt ); _cxt = nullptr; }
  58. #define SAFE_RELEASE_CFREF( _ref ) if ( _ref != nullptr ) { CFRelease( _ref ); _ref = nullptr; }
  59. // Utility functions
  60. extern char *COPY_STRING( const char *pString );
  61. bool MovieGetStaticFrameRate( Movie inMovie, VideoFrameRate_t &theFrameRate );
  62. bool SetGWorldDecodeGamma( CGrafPtr theGWorld, VideoPlaybackGamma_t gamma );
  63. bool CreateMovieAudioContext( bool enableAudio, Movie inMovie, QTAudioContextRef *pAudioConectext, bool setVolume = false, float *pCurrentVolume = nullptr );
  64. VideoPlaybackGamma_t GetSystemPlaybackGamma();
  65. //-----------------------------------------------------------------------------
  66. // Computes a power of two at least as big as the passed-in number
  67. //-----------------------------------------------------------------------------
  68. static inline int ComputeGreaterPowerOfTwo( int n )
  69. {
  70. int i = 1;
  71. while ( i < n )
  72. {
  73. i <<= 1;
  74. }
  75. return i;
  76. }
  77. #endif // QUICKTIME_COMMON_H