This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

View File

@@ -0,0 +1,28 @@
// ----------------------------------------- //
// File generated by VPC //
// ----------------------------------------- //
Source file: F:\csgo_64\cstrike15_src\avi\avi.cpp
Debug output file: F:\csgo_64\cstrike15_src\avi\avi.cpp
Release output file: F:\csgo_64\cstrike15_src\avi\avi.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\avi\bink.cpp
Debug output file: F:\csgo_64\cstrike15_src\avi\bink.cpp
Release output file: F:\csgo_64\cstrike15_src\avi\bink.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
Debug output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
Release output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
Debug output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
Release output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
Containing unity file:
PCH file:

1184
avi/avi.cpp Normal file

File diff suppressed because it is too large Load Diff

30
avi/avi.h Normal file
View File

@@ -0,0 +1,30 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef AVI_H
#define AVI_H
#ifdef _WIN32
#pragma once
#endif
#include "tier2/tier2.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IFileSystem;
class IMaterialSystem;
//-----------------------------------------------------------------------------
// Global interfaces
//-----------------------------------------------------------------------------
extern IFileSystem *g_pFileSystem;
#endif // AVI_H

662
avi/avi_osx.cpp Normal file
View File

@@ -0,0 +1,662 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#include "avi/iavi.h"
#include "avi.h"
#include "filesystem.h"
#include "tier1/strtools.h"
#include "tier1/utllinkedlist.h"
#include "tier1/keyvalues.h"
#include "materialsystem/imaterial.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/materialsystemutil.h"
#include "materialsystem/itexture.h"
#include "vtf/vtf.h"
#include "pixelwriter.h"
#include "tier3/tier3.h"
//-----------------------------------------------------------------------------
//
// Class used to write out AVI files
//
//-----------------------------------------------------------------------------
class CAviFile
{
public:
CAviFile();
void Init( const AVIParams_t& params, void *hWnd );
void Shutdown();
void AppendMovieSound( short *buf, size_t bufsize );
void AppendMovieFrame( const BGR888_t *pRGBData );
private:
void Reset();
void CreateVideoStreams( const AVIParams_t& params, void *hWnd );
void CreateAudioStream();
bool m_bValid;
int m_nWidth;
int m_nHeight;
int m_nFrameRate;
int m_nFrameScale;
int m_nFrame;
int m_nSample;
};
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CAviFile::CAviFile()
{
Reset();
}
//-----------------------------------------------------------------------------
// Reset the avi file
//-----------------------------------------------------------------------------
void CAviFile::Reset()
{
m_bValid = false;
m_nWidth = 0;
m_nHeight = 0;
m_nFrameRate = 0;
m_nFrameScale = 1;
m_nFrame = 0;
m_nSample = 0;
}
//-----------------------------------------------------------------------------
// Start recording an AVI
//-----------------------------------------------------------------------------
void CAviFile::Init( const AVIParams_t& params, void *hWnd )
{
Reset();
char avifilename[ 512 ];
char fullavifilename[ 512 ];
Q_snprintf( avifilename, sizeof( avifilename ), "%s", params.m_pFileName );
Q_SetExtension( avifilename, ".avi", sizeof( avifilename ) );
g_pFullFileSystem->RelativePathToFullPath( avifilename, params.m_pPathID, fullavifilename, sizeof( fullavifilename ) );
if ( g_pFullFileSystem->FileExists( fullavifilename, params.m_pPathID ) )
{
g_pFullFileSystem->RemoveFile( fullavifilename, params.m_pPathID );
}
m_nFrameRate = params.m_nFrameRate;
m_nFrameScale = params.m_nFrameScale;
m_bValid = true;
m_nHeight = params.m_nHeight;
m_nWidth = params.m_nWidth;
CreateVideoStreams( params, hWnd );
CreateAudioStream();
}
void CAviFile::Shutdown()
{
Reset();
}
void CAviFile::CreateVideoStreams( const AVIParams_t& params, void *hWnd )
{
}
void CAviFile::CreateAudioStream()
{
}
void CAviFile::AppendMovieSound( short *buf, size_t bufsize )
{
if ( !m_bValid )
return;
unsigned long numsamps = bufsize / sizeof( short ); // numbytes*8 / au->wfx.wBitsPerSample;
m_nSample += numsamps;
}
//-----------------------------------------------------------------------------
// Adds a frame of the movie to the AVI
//-----------------------------------------------------------------------------
void CAviFile::AppendMovieFrame( const BGR888_t *pRGBData )
{
if ( !m_bValid )
return;
++m_nFrame;
}
//-----------------------------------------------------------------------------
//
// Class used to associated AVI files with IMaterials
//
//-----------------------------------------------------------------------------
class CAVIMaterial : public ITextureRegenerator
{
public:
CAVIMaterial();
// Initializes, shuts down the material
bool Init( const char *pMaterialName, const char *pFileName, const char *pPathID );
void Shutdown();
// Inherited from ITextureRegenerator
virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pRect );
virtual void Release();
// Returns the material
IMaterial *GetMaterial();
// Returns the texcoord range
void GetTexCoordRange( float *pMaxU, float *pMaxV );
// Returns the frame size of the AVI (stored in a subrect of the material itself)
void GetFrameSize( int *pWidth, int *pHeight );
// Sets the current time
void SetTime( float flTime );
// Returns the frame rate/count of the AVI
int GetFrameRate( );
int GetFrameCount( );
// Sets the frame for an AVI material (use instead of SetTime)
void SetFrame( float flFrame );
private:
// Initializes, shuts down the procedural texture
void CreateProceduralTexture( const char *pTextureName );
void DestroyProceduralTexture();
// Initializes, shuts down the procedural material
void CreateProceduralMaterial( const char *pMaterialName );
void DestroyProceduralMaterial();
// Initializes, shuts down the video stream
void CreateVideoStream( );
void DestroyVideoStream( );
CMaterialReference m_Material;
CTextureReference m_Texture;
int m_nAVIWidth;
int m_nAVIHeight;
int m_nFrameRate;
int m_nFrameCount;
int m_nCurrentSample;
};
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CAVIMaterial::CAVIMaterial()
{
}
//-----------------------------------------------------------------------------
// Initializes the material
//-----------------------------------------------------------------------------
bool CAVIMaterial::Init( const char *pMaterialName, const char *pFileName, const char *pPathID )
{
// Determine the full path name of the AVI
char pAVIFileName[ 512 ];
char pFullAVIFileName[ 512 ];
Q_snprintf( pAVIFileName, sizeof( pAVIFileName ), "%s", pFileName );
Q_DefaultExtension( pAVIFileName, ".avi", sizeof( pAVIFileName ) );
g_pFullFileSystem->RelativePathToFullPath( pAVIFileName, pPathID, pFullAVIFileName, sizeof( pFullAVIFileName ) );
CreateProceduralTexture( pMaterialName );
CreateProceduralMaterial( pMaterialName );
CreateVideoStream();
m_Texture->Download();
return true;
}
void CAVIMaterial::Shutdown()
{
DestroyVideoStream();
DestroyProceduralMaterial( );
DestroyProceduralTexture( );
}
//-----------------------------------------------------------------------------
// Returns the material
//-----------------------------------------------------------------------------
IMaterial *CAVIMaterial::GetMaterial()
{
return m_Material;
}
//-----------------------------------------------------------------------------
// Returns the texcoord range
//-----------------------------------------------------------------------------
void CAVIMaterial::GetTexCoordRange( float *pMaxU, float *pMaxV )
{
if ( !m_Texture )
{
*pMaxU = *pMaxV = 1.0f;
return;
}
int nTextureWidth = m_Texture->GetActualWidth();
int nTextureHeight = m_Texture->GetActualHeight();
*pMaxU = (float)m_nAVIWidth / (float)nTextureWidth;
*pMaxV = (float)m_nAVIHeight / (float)nTextureHeight;
}
//-----------------------------------------------------------------------------
// Returns the frame size of the AVI (stored in a subrect of the material itself)
//-----------------------------------------------------------------------------
void CAVIMaterial::GetFrameSize( int *pWidth, int *pHeight )
{
*pWidth = m_nAVIWidth;
*pHeight = m_nAVIHeight;
}
//-----------------------------------------------------------------------------
// Computes a power of two at least as big as the passed-in number
//-----------------------------------------------------------------------------
static inline int ComputeGreaterPowerOfTwo( int n )
{
int i = 1;
while ( i < n )
{
i <<= 1;
}
return i;
}
//-----------------------------------------------------------------------------
// Initializes, shuts down the procedural texture
//-----------------------------------------------------------------------------
void CAVIMaterial::CreateProceduralTexture( const char *pTextureName )
{
// Choose power-of-two textures which are at least as big as the AVI
int nWidth = ComputeGreaterPowerOfTwo( m_nAVIWidth );
int nHeight = ComputeGreaterPowerOfTwo( m_nAVIHeight );
m_Texture.InitProceduralTexture( pTextureName, "avi", nWidth, nHeight,
IMAGE_FORMAT_RGBA8888, TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT | TEXTUREFLAGS_NOMIP |
TEXTUREFLAGS_PROCEDURAL | TEXTUREFLAGS_SINGLECOPY );
m_Texture->SetTextureRegenerator( this );
}
void CAVIMaterial::DestroyProceduralTexture()
{
if (m_Texture)
{
m_Texture->SetTextureRegenerator( NULL );
m_Texture.Shutdown();
}
}
//-----------------------------------------------------------------------------
// Initializes, shuts down the procedural material
//-----------------------------------------------------------------------------
void CAVIMaterial::CreateProceduralMaterial( const char *pMaterialName )
{
// FIXME: gak, this is backwards. Why doesn't the material just see that it has a funky basetexture?
char vmtfilename[ 512 ];
Q_strcpy( vmtfilename, pMaterialName );
Q_SetExtension( vmtfilename, ".vmt", sizeof( vmtfilename ) );
KeyValues *pVMTKeyValues = new KeyValues( "UnlitGeneric" );
if (!pVMTKeyValues->LoadFromFile( g_pFullFileSystem , vmtfilename, "GAME" ))
{
pVMTKeyValues->SetString( "$basetexture", m_Texture->GetName() );
pVMTKeyValues->SetInt( "$nofog", 1 );
pVMTKeyValues->SetInt( "$spriteorientation", 3 );
pVMTKeyValues->SetInt( "$translucent", 1 );
}
m_Material.Init( pMaterialName, pVMTKeyValues );
m_Material->Refresh();
}
void CAVIMaterial::DestroyProceduralMaterial()
{
m_Material.Shutdown();
}
//-----------------------------------------------------------------------------
// Sets the current time
//-----------------------------------------------------------------------------
void CAVIMaterial::SetTime( float flTime )
{
}
//-----------------------------------------------------------------------------
// Returns the frame rate of the AVI
//-----------------------------------------------------------------------------
int CAVIMaterial::GetFrameRate( )
{
return m_nFrameRate;
}
int CAVIMaterial::GetFrameCount( )
{
return m_nFrameCount;
}
//-----------------------------------------------------------------------------
// Sets the frame for an AVI material (use instead of SetTime)
//-----------------------------------------------------------------------------
void CAVIMaterial::SetFrame( float flFrame )
{
}
//-----------------------------------------------------------------------------
// Initializes, shuts down the video stream
//-----------------------------------------------------------------------------
void CAVIMaterial::CreateVideoStream( )
{
}
void CAVIMaterial::DestroyVideoStream( )
{
}
//-----------------------------------------------------------------------------
// Inherited from ITextureRegenerator
//-----------------------------------------------------------------------------
void CAVIMaterial::RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pRect )
{
}
void CAVIMaterial::Release()
{
}
//-----------------------------------------------------------------------------
//
// Implementation of IAvi
//
//-----------------------------------------------------------------------------
class CAvi : public CTier3AppSystem< IAvi >
{
typedef CTier3AppSystem< IAvi > BaseClass;
public:
CAvi();
// Inherited from IAppSystem
virtual bool Connect( CreateInterfaceFn factory );
virtual void *QueryInterface( const char *pInterfaceName );
virtual InitReturnVal_t Init();
virtual void Shutdown();
// Inherited from IAvi
virtual void SetMainWindow( void* hWnd );
virtual AVIHandle_t StartAVI( const AVIParams_t& params );
virtual void FinishAVI( AVIHandle_t h );
virtual void AppendMovieSound( AVIHandle_t h, short *buf, size_t bufsize );
virtual void AppendMovieFrame( AVIHandle_t h, const BGR888_t *pRGBData );
virtual AVIMaterial_t CreateAVIMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID );
virtual void DestroyAVIMaterial( AVIMaterial_t hMaterial );
virtual void SetTime( AVIMaterial_t hMaterial, float flTime );
virtual IMaterial* GetMaterial( AVIMaterial_t hMaterial );
virtual void GetTexCoordRange( AVIMaterial_t hMaterial, float *pMaxU, float *pMaxV );
virtual void GetFrameSize( AVIMaterial_t hMaterial, int *pWidth, int *pHeight );
virtual int GetFrameRate( AVIMaterial_t hMaterial );
virtual void SetFrame( AVIMaterial_t hMaterial, float flFrame );
virtual int GetFrameCount( AVIMaterial_t hMaterial );
private:
CUtlLinkedList< CAviFile, AVIHandle_t > m_AVIFiles;
// NOTE: Have to use pointers here since AVIMaterials inherit from ITextureRegenerator
// The realloc screws up the pointers held to ITextureRegenerators in the material system.
CUtlLinkedList< CAVIMaterial*, AVIMaterial_t > m_AVIMaterials;
};
//-----------------------------------------------------------------------------
// Singleton
//-----------------------------------------------------------------------------
static CAvi g_AVI;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CAvi, IAvi, AVI_INTERFACE_VERSION, g_AVI );
//-----------------------------------------------------------------------------
// Constructor/destructor
//-----------------------------------------------------------------------------
CAvi::CAvi()
{
}
//-----------------------------------------------------------------------------
// Connect/disconnect
//-----------------------------------------------------------------------------
bool CAvi::Connect( CreateInterfaceFn factory )
{
if ( !BaseClass::Connect( factory ) )
return false;
if ( !( g_pFullFileSystem && materials ) )
{
Msg( "Avi failed to connect to a required system\n" );
}
return ( g_pFullFileSystem && materials );
}
//-----------------------------------------------------------------------------
// Query Interface
//-----------------------------------------------------------------------------
void *CAvi::QueryInterface( const char *pInterfaceName )
{
if (!Q_strncmp( pInterfaceName, AVI_INTERFACE_VERSION, Q_strlen(AVI_INTERFACE_VERSION) + 1))
return (IAvi*)this;
return NULL;
}
//-----------------------------------------------------------------------------
// Init/shutdown
//-----------------------------------------------------------------------------
InitReturnVal_t CAvi::Init()
{
InitReturnVal_t nRetVal = BaseClass::Init();
if ( nRetVal != INIT_OK )
return nRetVal;
return INIT_OK;
}
void CAvi::Shutdown()
{
BaseClass::Shutdown();
}
//-----------------------------------------------------------------------------
// Sets the main window
//-----------------------------------------------------------------------------
void CAvi::SetMainWindow( void* hWnd )
{
Assert( false );
}
//-----------------------------------------------------------------------------
// Start, finish recording an AVI
//-----------------------------------------------------------------------------
AVIHandle_t CAvi::StartAVI( const AVIParams_t& params )
{
AVIHandle_t h = m_AVIFiles.AddToTail();
m_AVIFiles[h].Init( params, NULL /*hwnd*/ );
return h;
}
void CAvi::FinishAVI( AVIHandle_t h )
{
if ( h != AVIHANDLE_INVALID )
{
m_AVIFiles[h].Shutdown();
m_AVIFiles.Remove( h );
}
}
//-----------------------------------------------------------------------------
// Add sound buffer
//-----------------------------------------------------------------------------
void CAvi::AppendMovieSound( AVIHandle_t h, short *buf, size_t bufsize )
{
if ( h != AVIHANDLE_INVALID )
{
m_AVIFiles[h].AppendMovieSound( buf, bufsize );
}
}
//-----------------------------------------------------------------------------
// Add movie frame
//-----------------------------------------------------------------------------
void CAvi::AppendMovieFrame( AVIHandle_t h, const BGR888_t *pRGBData )
{
if ( h != AVIHANDLE_INVALID )
{
m_AVIFiles[h].AppendMovieFrame( pRGBData );
}
}
//-----------------------------------------------------------------------------
// Create/destroy an AVI material
//-----------------------------------------------------------------------------
AVIMaterial_t CAvi::CreateAVIMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID )
{
AVIMaterial_t h = m_AVIMaterials.AddToTail();
m_AVIMaterials[h] = new CAVIMaterial;
m_AVIMaterials[h]->Init( pMaterialName, pFileName, pPathID );
return h;
}
void CAvi::DestroyAVIMaterial( AVIMaterial_t h )
{
if ( h != AVIMATERIAL_INVALID )
{
m_AVIMaterials[h]->Shutdown();
delete m_AVIMaterials[h];
m_AVIMaterials.Remove( h );
}
}
//-----------------------------------------------------------------------------
// Sets the time for an AVI material
//-----------------------------------------------------------------------------
void CAvi::SetTime( AVIMaterial_t h, float flTime )
{
if ( h != AVIMATERIAL_INVALID )
{
m_AVIMaterials[h]->SetTime( flTime );
}
}
//-----------------------------------------------------------------------------
// Gets the IMaterial associated with an AVI material
//-----------------------------------------------------------------------------
IMaterial* CAvi::GetMaterial( AVIMaterial_t h )
{
if ( h != AVIMATERIAL_INVALID )
return m_AVIMaterials[h]->GetMaterial();
return NULL;
}
//-----------------------------------------------------------------------------
// Returns the max texture coordinate of the AVI
//-----------------------------------------------------------------------------
void CAvi::GetTexCoordRange( AVIMaterial_t h, float *pMaxU, float *pMaxV )
{
if ( h != AVIMATERIAL_INVALID )
{
m_AVIMaterials[h]->GetTexCoordRange( pMaxU, pMaxV );
}
else
{
*pMaxU = *pMaxV = 1.0f;
}
}
//-----------------------------------------------------------------------------
// Returns the frame size of the AVI (is a subrect of the material itself)
//-----------------------------------------------------------------------------
void CAvi::GetFrameSize( AVIMaterial_t h, int *pWidth, int *pHeight )
{
if ( h != AVIMATERIAL_INVALID )
{
m_AVIMaterials[h]->GetFrameSize( pWidth, pHeight );
}
else
{
*pWidth = *pHeight = 1;
}
}
//-----------------------------------------------------------------------------
// Returns the frame rate of the AVI
//-----------------------------------------------------------------------------
int CAvi::GetFrameRate( AVIMaterial_t h )
{
if ( h != AVIMATERIAL_INVALID )
return m_AVIMaterials[h]->GetFrameRate();
return 1;
}
int CAvi::GetFrameCount( AVIMaterial_t h )
{
if ( h != AVIMATERIAL_INVALID )
return m_AVIMaterials[h]->GetFrameCount();
return 1;
}
//-----------------------------------------------------------------------------
// Sets the frame for an AVI material (use instead of SetTime)
//-----------------------------------------------------------------------------
void CAvi::SetFrame( AVIMaterial_t h, float flFrame )
{
if ( h != AVIMATERIAL_INVALID )
{
m_AVIMaterials[h]->SetFrame( flFrame );
}
}

1938
avi/bink.cpp Normal file

File diff suppressed because it is too large Load Diff

1133
avi/quicktime.cpp Normal file

File diff suppressed because it is too large Load Diff

274
avi/quicktime.h Normal file
View File

@@ -0,0 +1,274 @@
//===== Copyright (c) 2010, Valve Corporation, All rights reserved. ===========
//
// Purpose:
//
//=============================================================================
#ifndef QUICKTIME_H
#define QUICKTIME_H
#ifdef _WIN32
#pragma once
#endif
#include <avi/iquicktime.h>
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IFileSystem;
class IMaterialSystem;
class CQuickTimeMaterial;
//-----------------------------------------------------------------------------
// Global interfaces - you already did the needed includes, right?
//-----------------------------------------------------------------------------
extern IFileSystem *g_pFileSystem;
extern IMaterialSystem *materials;
//-----------------------------------------------------------------------------
// Quicktime includes - conditional compilation on #define QUICKTIME in VPC
// The intent is to have a default functionality fallback if not defined
// which provides a dynamically generated texture (moving line on background)
//-----------------------------------------------------------------------------
#if defined( QUICKTIME_VIDEO )
#if defined ( OSX )
#include <quicktime/QTML.h>
#include <quicktime/Movies.h>
#elif defined ( WIN32 )
#include <QTML.h>
#include <Movies.h>
#include <windows.h>
#endif
#else
typedef TimeValue long;
#endif
// -----------------------------------------------------------------------
// eVideoFrameFormat_t - bitformat for quicktime video frames
// -----------------------------------------------------------------------
enum eVideoFrameFormat_t
{
cVFF_Undefined = 0,
cVFF_R8G8B8A8_32Bit,
cVFF_R8G8B8_24Bit,
cVFF_Count, // Auto list counter
cVFF_ForceInt32 = 0x7FFFFFFF // Make sure eNum is (at least) an int32
};
//-----------------------------------------------------------------------------
// texture regenerator - callback to get new movie pixels into the texture
//-----------------------------------------------------------------------------
class CQuicktimeMaterialRGBTextureRegenerator : public ITextureRegenerator
{
public:
CQuicktimeMaterialRGBTextureRegenerator() :
m_pQTMaterial( NULL ),
m_nSourceWidth( 0 ),
m_nSourceHeight( 0 )
{
}
void SetParentMaterial( CQuickTimeMaterial *pQTMaterial, int nWidth, int nHeight )
{
m_pQTMaterial = pQTMaterial;
m_nSourceWidth = nWidth;
m_nSourceHeight = nHeight;
}
// Inherited from ITextureRegenerator
virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pRect );
virtual void Release();
private:
CQuickTimeMaterial *m_pQTMaterial;
int m_nSourceWidth;
int m_nSourceHeight;
};
//-----------------------------------------------------------------------------
//
// Class used to associated QuickTime video files with IMaterials
//
//-----------------------------------------------------------------------------
class CQuickTimeMaterial
{
public:
CQuickTimeMaterial();
~CQuickTimeMaterial();
// Initializes, shuts down the material
bool Init( const char *pMaterialName, const char *pFileName, const char *pPathID );
void Shutdown();
// Keeps the frames updated
bool Update( void );
// Check if a new frame is available
bool ReadyForSwap( void );
// Returns the material
IMaterial *GetMaterial();
// Returns the texcoord range
void GetTexCoordRange( float *pMaxU, float *pMaxV );
// Returns the frame size of the QuickTime Video (stored in a subrect of the material itself)
void GetFrameSize( int *pWidth, int *pHeight );
// Sets the current time
void SetTime( float flTime );
// Returns the frame rate/count of the QuickTime Material
int GetFrameRate( );
int GetFrameCount( );
// Sets the frame for an QuickTime material (use instead of SetTime) ??
void SetFrame( float flFrame );
void SetLooping( bool loop );
private:
friend class CQuicktimeMaterialRGBTextureRegenerator;
void Reset();
void OpenQTMovie( const char* theQTMovieFileName );
void SetQTFileName( const char *theQTMovieFileName );
void GetErrorFrame();
void CloseQTFile();
// Initializes, shuts down the procedural texture
void CreateProceduralTexture( const char *pTextureName );
void DestroyProceduralTexture();
// Initializes, shuts down the procedural material
void CreateProceduralMaterial( const char *pMaterialName );
void DestroyProceduralMaterial();
// Initializes, shuts down the video stream
CQuicktimeMaterialRGBTextureRegenerator m_TextureRegen;
CMaterialReference m_Material; // Ref to Material used for rendering the video frame
CTextureReference m_Texture; // Ref to the renderable texture which contains the most recent video frame (in a sub-rect)
float m_TexCordU; // Max U texture coordinate of the texture sub-rect which holds the video frame
float m_TexCordV; // Max V texture coordinate of the texture sub-rect which holds the video frame
int m_VideoFrameWidth;
int m_VideoFrameHeight;
char *m_pFileName;
char m_TextureName[128];
char m_MaterialName[128];
bool m_bActive;
bool m_bLoopMovie;
bool m_bMoviePlaying;
double m_MovieBeganPlayingTime;
double m_MovieCurrentTime;
#if defined( QUICKTIME_VIDEO )
// QuickTime Stuff
Movie m_QTMovie;
TimeValue m_QTMovieTimeScale; // Units per second
TimeValue m_QTMovieDuration; // movie duration is UPS
float m_QTMovieDurationinSec; // movie duration in seconds
long m_QTMoveFrameRate;
Rect m_QTMovieRect;
GWorldPtr m_MovieGWorld;
QTAudioContextRef m_AudioContext;
TimeValue m_LastInterestingTimePlayed;
TimeValue m_NextInterestingTimeToPlay;
// our Frame buffer stuff
#if defined ( WIN32 )
BITMAPINFO m_BitmapInfo;
#endif
#endif
void *m_BitMapData;
int m_BitMapDataSize;
bool m_bIsErrorFrame;
float m_nLastFrameTime;
static const int cMaxQTFileNameLen = 255;
static const int cMinVideoFrameWidth = 16;
static const int cMinVideoFrameHeight = 16;
static const int cMaxVideoFrameWidth = 2048;
static const int cMaxVideoFrameHeight = 2048;
};
//-----------------------------------------------------------------------------
//
// Implementation of IQuickTime
//
//-----------------------------------------------------------------------------
class CQuickTime : public CBaseAppSystem<IQuickTime>
{
public:
CQuickTime();
~CQuickTime();
// Inherited from IAppSystem
virtual bool Connect( CreateInterfaceFn factory );
virtual void Disconnect();
virtual void *QueryInterface( const char *pInterfaceName );
virtual InitReturnVal_t Init();
virtual void Shutdown();
// Inherited from IQuickTime
virtual QUICKTIMEMaterial_t CreateMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID, int flags = 0 );
virtual void DestroyMaterial( QUICKTIMEMaterial_t hMaterial );
virtual bool Update( QUICKTIMEMaterial_t hMaterial );
virtual bool ReadyForSwap( QUICKTIMEMaterial_t hMaterial );
virtual IMaterial *GetMaterial( QUICKTIMEMaterial_t hMaterial );
virtual void GetTexCoordRange( QUICKTIMEMaterial_t hMaterial, float *pMaxU, float *pMaxV );
virtual void GetFrameSize( QUICKTIMEMaterial_t hMaterial, int *pWidth, int *pHeight );
virtual int GetFrameRate( QUICKTIMEMaterial_t hMaterial );
virtual void SetFrame( QUICKTIMEMaterial_t hMaterial, float flFrame );
virtual int GetFrameCount( QUICKTIMEMaterial_t hMaterial );
virtual bool SetSoundDevice( void *pDevice );
private:
bool SetupQuicktime();
void ShutdownQuicktime();
// NOTE: Have to use pointers here since QuickTimeKMaterials inherit from ITextureRegenerator
// The realloc screws up the pointers held to ITextureRegenerators in the material system.
CUtlLinkedList< CQuickTimeMaterial*, QUICKTIMEMaterial_t > m_QTMaterials;
bool m_bQTInitialized;
};
#endif // QUICKTIME_H

74
avi/valve_avi.vpc Normal file
View File

@@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// VALVE_AVI.VPC
//
// Project Script
//
// MGP 4/010 Updated to support Quicktime on OSX. Win32 builds can optionally
// be enabled for cross platform work if quickTime is installed on the Win32
// PC.
//-----------------------------------------------------------------------------
$Macro SRCDIR ".."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$include "$SRCDIR\vpc_scripts\source_video_base.vpc"
$Configuration
{
$Compiler
{
// Win32 - need to point to Quicktime 7 for Win SDK directory so that dependant includes will work
$AdditionalIncludeDirectories "$BASE,..\common\quicktime_win32\" [$QUICKTIME_WINDOWS]
$AdditionalIncludeDirectories "$BASE;$SRCDIR\dx9sdk\include" [$WINDOWS]
$AdditionalIncludeDirectories "$BASE;$SRCDIR\thirdparty\sdl\include;$SRCDIR\thirdparty\sdl_mixer" [$LINUXALL]
}
$Linker
{
$IgnoreImportLibrary "Yes" [$WINDOWS]
$AdditionalDependencies "$BASE vfw32.lib" [$WINDOWS]
$SystemLibraries "iconv" [$OSXALL]
$SystemFrameworks "Quicktime;Carbon"
$AdditionalLibraryDirectories "$BASE;$SRCDIR\dx9sdk\lib" [$WINDOWS]
$GCC_ExtraLinkerFlags "-z muldefs -L$SRCDIR/thirdparty/sdl/build/.libs" [$LINUXALL]
$SystemLibraries "SDL2" [$LINUXALL]
}
}
$Project "valve_avi"
{
$Folder "Source Files"
{
$File "avi.cpp" [$WINDOWS]
$File "avi_osx.cpp" [$OSXALL]
$File "bink.cpp" [!$OSXALL]
$file "quicktime.cpp" [$QUICKTIME_VIDEO||$QUICKTIME_WINDOWS]
}
$Folder "Header Files"
{
$File "avi.h"
$file "quicktime.h"
// $File "$SRCDIR\BinkSDK\bink.h"
$File "$SRCDIR\public\pixelwriter.h"
}
$Folder "Interface"
{
$File "$SRCDIR\public\avi\iavi.h"
$File "$SRCDIR\public\avi\ibik.h"
$File "$SRCDIR\public\avi\iquicktime.h"
}
$Folder "Link Libraries" [$WINDOWS||$X360||$POSIX]
{
$Lib tier2
$lib tier3
$File "$SRCDIR\lib\common\quicktime\QTMLClient.lib" [$QUICKTIME_WINDOWS]
$File "$SRCDIR\DX9SDK\lib\dsound.lib" [$QUICKTIME_WINDOWS]
$File "$SRCDIR\DX9SDK\lib\dxguid.lib" [$QUICKTIME_WINDOWS]
$File "$SRCDIR\lib\common\libSDL2_mixer.a" [$LINUXALL]
}
}

View File

@@ -0,0 +1,13 @@
"vpc_cache"
{
"CacheVersion" "1"
"win32"
{
"CRCFile" "valve_avi.vcxproj.vpc_crc"
"OutputFiles"
{
"0" "valve_avi.vcxproj"
"1" "valve_avi.vcxproj.filters"
}
}
}