spacing
This commit is contained in:
@@ -178,7 +178,7 @@ MovieTexture_DShow::~MovieTexture_DShow()
|
||||
/* Shut down the graph. We can't call Stop() here, since that will
|
||||
* call SkipUpdates again, which will deadlock if we call it twice
|
||||
* in a row. */
|
||||
if( m_pGB )
|
||||
if( m_pGB )
|
||||
{
|
||||
LOG->Trace( "MovieTexture_DShow: shutdown" );
|
||||
LOG->Flush();
|
||||
@@ -264,7 +264,7 @@ void MovieTexture_DShow::Update(float fDeltaTime)
|
||||
if( m_bLoop )
|
||||
{
|
||||
// Check for completion events
|
||||
CComPtr<IMediaEvent> pME;
|
||||
CComPtr<IMediaEvent> pME;
|
||||
m_pGB.QueryInterface(&pME);
|
||||
|
||||
long lEventCode, lParam1, lParam2;
|
||||
@@ -325,49 +325,49 @@ RString MovieTexture_DShow::Create()
|
||||
{
|
||||
RageTextureID actualID = GetID();
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
actualID.iAlphaBits = 0;
|
||||
|
||||
if( FAILED( hr=CoInitialize(NULL) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not CoInitialize") );
|
||||
if( FAILED( hr=CoInitialize(NULL) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not CoInitialize") );
|
||||
|
||||
// Create the filter graph
|
||||
if( FAILED( hr=m_pGB.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not create CLSID_FilterGraph!") );
|
||||
|
||||
// Create the Texture Renderer object
|
||||
CTextureRenderer *pCTR = new CTextureRenderer;
|
||||
|
||||
/* Get a pointer to the IBaseFilter on the TextureRenderer, and add it to the
|
||||
// Create the filter graph
|
||||
if( FAILED( hr=m_pGB.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not create CLSID_FilterGraph!") );
|
||||
|
||||
// Create the Texture Renderer object
|
||||
CTextureRenderer *pCTR = new CTextureRenderer;
|
||||
|
||||
/* Get a pointer to the IBaseFilter on the TextureRenderer, and add it to the
|
||||
* graph. When m_pGB is released, it will free pFTR. */
|
||||
CComPtr<IBaseFilter> pFTR = pCTR;
|
||||
if( FAILED( hr = m_pGB->AddFilter(pFTR, L"TEXTURERENDERER" ) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not add renderer filter to graph!") );
|
||||
CComPtr<IBaseFilter> pFTR = pCTR;
|
||||
if( FAILED( hr = m_pGB->AddFilter(pFTR, L"TEXTURERENDERER" ) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not add renderer filter to graph!") );
|
||||
|
||||
// Add the source filter
|
||||
CComPtr<IBaseFilter> pFSrc; // Source Filter
|
||||
wstring wFileName = RStringToWstring(actualID.filename);
|
||||
// Add the source filter
|
||||
CComPtr<IBaseFilter> pFSrc; // Source Filter
|
||||
wstring wFileName = RStringToWstring(actualID.filename);
|
||||
|
||||
// if this fails, it's probably because the user doesn't have DivX installed
|
||||
/* No, it also happens if the movie can't be opened for some reason; for example,
|
||||
* if another program has it open and locked. Missing codecs probably won't
|
||||
* show up until Connect(). */
|
||||
if( FAILED( hr = m_pGB->AddSourceFilter( wFileName.c_str(), wFileName.c_str(), &pFSrc ) ) )
|
||||
if( FAILED( hr = m_pGB->AddSourceFilter( wFileName.c_str(), wFileName.c_str(), &pFSrc ) ) )
|
||||
return PrintCodecError( hr, "Could not create source filter to graph!" );
|
||||
|
||||
// Find the source's output and the renderer's input
|
||||
CComPtr<IPin> pFTRPinIn; // Texture Renderer Input Pin
|
||||
if( FAILED( hr = pFTR->FindPin( L"In", &pFTRPinIn ) ) )
|
||||
return hr_ssprintf(hr, "Could not find input pin" );
|
||||
|
||||
CComPtr<IPin> pFSrcPinOut; // Source Filter Output Pin
|
||||
if( FAILED( hr = pFSrc->FindPin( L"Output", &pFSrcPinOut ) ) )
|
||||
return hr_ssprintf( hr, "Could not find output pin" );
|
||||
// Find the source's output and the renderer's input
|
||||
CComPtr<IPin> pFTRPinIn; // Texture Renderer Input Pin
|
||||
if( FAILED( hr = pFTR->FindPin( L"In", &pFTRPinIn ) ) )
|
||||
return hr_ssprintf(hr, "Could not find input pin" );
|
||||
|
||||
// Connect these two filters
|
||||
if( FAILED( hr = m_pGB->Connect( pFSrcPinOut, pFTRPinIn ) ) )
|
||||
return PrintCodecError( hr, "Could not connect pins" );
|
||||
CComPtr<IPin> pFSrcPinOut; // Source Filter Output Pin
|
||||
if( FAILED( hr = pFSrc->FindPin( L"Output", &pFSrcPinOut ) ) )
|
||||
return hr_ssprintf( hr, "Could not find output pin" );
|
||||
|
||||
// Connect these two filters
|
||||
if( FAILED( hr = m_pGB->Connect( pFSrcPinOut, pFTRPinIn ) ) )
|
||||
return PrintCodecError( hr, "Could not connect pins" );
|
||||
|
||||
LOG->Trace( "Filters: %s", GetActiveFilterList().c_str() );
|
||||
|
||||
@@ -377,7 +377,7 @@ RString MovieTexture_DShow::Create()
|
||||
/* Cap the max texture size to the hardware max. */
|
||||
actualID.iMaxSize = min( actualID.iMaxSize, DISPLAY->GetMaxTextureSize() );
|
||||
|
||||
// The graph is built, now get the set the output video width and height.
|
||||
// The graph is built, now get the set the output video width and height.
|
||||
// The source and image width will always be the same since we can't scale the video
|
||||
m_iSourceWidth = pCTR->GetVidWidth();
|
||||
m_iSourceHeight = pCTR->GetVidHeight();
|
||||
@@ -406,7 +406,7 @@ RString MovieTexture_DShow::Create()
|
||||
CHECKPOINT;
|
||||
|
||||
// Start the graph running
|
||||
Play();
|
||||
Play();
|
||||
|
||||
return RString();
|
||||
}
|
||||
@@ -479,12 +479,12 @@ void MovieTexture_DShow::Play()
|
||||
|
||||
LOG->Trace("MovieTexture_DShow::Play()");
|
||||
CComPtr<IMediaControl> pMC;
|
||||
m_pGB.QueryInterface(&pMC);
|
||||
m_pGB.QueryInterface(&pMC);
|
||||
|
||||
// Start the graph running;
|
||||
// Start the graph running;
|
||||
HRESULT hr;
|
||||
if( FAILED(hr = pMC->Run()) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not run the DirectShow graph.") );
|
||||
if( FAILED(hr = pMC->Run()) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not run the DirectShow graph.") );
|
||||
|
||||
m_bPlaying = true;
|
||||
|
||||
@@ -496,12 +496,12 @@ void MovieTexture_DShow::Pause()
|
||||
SkipUpdates();
|
||||
|
||||
CComPtr<IMediaControl> pMC;
|
||||
m_pGB.QueryInterface(&pMC);
|
||||
m_pGB.QueryInterface(&pMC);
|
||||
|
||||
HRESULT hr;
|
||||
/* Use Pause(), so we'll get a still frame in CTextureRenderer::OnReceiveFirstSample. */
|
||||
if( FAILED(hr = pMC->Pause()) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not pause the DirectShow graph.") );
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not pause the DirectShow graph.") );
|
||||
|
||||
StopSkippingUpdates();
|
||||
}
|
||||
@@ -512,8 +512,8 @@ void MovieTexture_DShow::SetPosition( float fSeconds )
|
||||
SkipUpdates();
|
||||
|
||||
CComPtr<IMediaPosition> pMP;
|
||||
m_pGB.QueryInterface(&pMP);
|
||||
pMP->put_CurrentPosition(0);
|
||||
m_pGB.QueryInterface(&pMP);
|
||||
pMP->put_CurrentPosition(0);
|
||||
|
||||
StopSkippingUpdates();
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureR
|
||||
static HRESULT CBV_ret;
|
||||
CTextureRenderer::CTextureRenderer():
|
||||
CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer),
|
||||
NAME("Texture Renderer"), NULL, &CBV_ret),
|
||||
NAME("Texture Renderer"), NULL, &CBV_ret),
|
||||
m_OneFrameDecoded( "m_OneFrameDecoded", 0 )
|
||||
{
|
||||
if( FAILED(CBV_ret) )
|
||||
RageException::Throw( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") );
|
||||
if( FAILED(CBV_ret) )
|
||||
RageException::Throw( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") );
|
||||
|
||||
m_pTexture = NULL;
|
||||
}
|
||||
@@ -28,35 +28,35 @@ CTextureRenderer::~CTextureRenderer()
|
||||
|
||||
HRESULT CTextureRenderer::CheckMediaType(const CMediaType *pmt)
|
||||
{
|
||||
VIDEOINFO *pvi;
|
||||
|
||||
// Reject the connection if this is not a video type
|
||||
if( *pmt->FormatType() != FORMAT_VideoInfo )
|
||||
return E_INVALIDARG;
|
||||
|
||||
VIDEOINFO *pvi;
|
||||
|
||||
// Reject the connection if this is not a video type
|
||||
if( *pmt->FormatType() != FORMAT_VideoInfo )
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* Force the graph to R8G8B8. DirectShow won't generate a FMT_RGB5 that OpenGL
|
||||
* can handle. It's faster to generate FMT8 and let OpenGL convert on the fly
|
||||
* than to generate FMT_RGB5 and convert it ourself. */
|
||||
pvi = (VIDEOINFO *)pmt->Format();
|
||||
if(IsEqualGUID( *pmt->Type(), MEDIATYPE_Video) &&
|
||||
IsEqualGUID( *pmt->Subtype(), MEDIASUBTYPE_RGB24))
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
pvi = (VIDEOINFO *)pmt->Format();
|
||||
if( IsEqualGUID( *pmt->Type(), MEDIATYPE_Video) &&
|
||||
IsEqualGUID( *pmt->Subtype(), MEDIASUBTYPE_RGB24) )
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
// SetMediaType: Graph connection has been made.
|
||||
HRESULT CTextureRenderer::SetMediaType(const CMediaType *pmt)
|
||||
{
|
||||
// Retrive the size of this media type
|
||||
VIDEOINFO *pviBmp; // Bitmap info header
|
||||
pviBmp = (VIDEOINFO *)pmt->Format();
|
||||
m_lVidWidth = pviBmp->bmiHeader.biWidth;
|
||||
m_lVidHeight = abs(pviBmp->bmiHeader.biHeight);
|
||||
m_lVidPitch = (m_lVidWidth * 3 + 3) + ~3; // We are forcing RGB24
|
||||
// Retrive the size of this media type
|
||||
VIDEOINFO *pviBmp; // Bitmap info header
|
||||
pviBmp = (VIDEOINFO *)pmt->Format();
|
||||
m_lVidWidth = pviBmp->bmiHeader.biWidth;
|
||||
m_lVidHeight = abs(pviBmp->bmiHeader.biHeight);
|
||||
m_lVidPitch = (m_lVidWidth * 3 + 3) + ~3; // We are forcing RGB24
|
||||
|
||||
return S_OK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,15 +74,15 @@ HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample )
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
BYTE *pBmpBuffer; // Bitmap buffer
|
||||
BYTE *pBmpBuffer; // Bitmap buffer
|
||||
|
||||
// Get the video bitmap buffer
|
||||
pSample->GetPointer( &pBmpBuffer );
|
||||
// Get the video bitmap buffer
|
||||
pSample->GetPointer( &pBmpBuffer );
|
||||
|
||||
// Copy the bits
|
||||
// Copy the bits
|
||||
m_pTexture->NewData((char *) pBmpBuffer);
|
||||
|
||||
return S_OK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CTextureRenderer::OnReceiveFirstSample( IMediaSample * pSample )
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
class CTextureRenderer : public CBaseVideoRenderer
|
||||
{
|
||||
public:
|
||||
CTextureRenderer();
|
||||
~CTextureRenderer();
|
||||
CTextureRenderer();
|
||||
~CTextureRenderer();
|
||||
|
||||
HRESULT CheckMediaType( const CMediaType *pmt ); // Format acceptable?
|
||||
HRESULT SetMediaType( const CMediaType *pmt ); // Video format notification
|
||||
|
||||
@@ -422,10 +422,10 @@ void MovieDecoder_FFMpeg::ConvertToSurface( RageSurface *pSurface ) const
|
||||
|
||||
static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx )
|
||||
{
|
||||
for( int stream = 0; stream < m_fctx->nb_streams; ++stream )
|
||||
for( int stream = 0; stream < m_fctx->nb_streams; ++stream )
|
||||
{
|
||||
avcodec::AVStream *enc = m_fctx->streams[stream];
|
||||
if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO )
|
||||
if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO )
|
||||
return enc;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -22,7 +22,7 @@ MovieTexture_Generic::MovieTexture_Generic( RageTextureID ID, MovieDecoder *pDec
|
||||
|
||||
m_uTexHandle = 0;
|
||||
m_bLoop = true;
|
||||
m_State = DECODER_QUIT; /* it's quit until we call StartThread */
|
||||
m_State = DECODER_QUIT; /* it's quit until we call StartThread */
|
||||
m_pSurface = NULL;
|
||||
m_ImageWaiting = FRAME_NONE;
|
||||
m_fRate = 1;
|
||||
@@ -93,8 +93,8 @@ void MovieTexture_Generic::DestroyTexture()
|
||||
|
||||
void MovieTexture_Generic::CreateTexture()
|
||||
{
|
||||
if( m_uTexHandle )
|
||||
return;
|
||||
if( m_uTexHandle )
|
||||
return;
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
@@ -155,7 +155,7 @@ void MovieTexture_Generic::CreateTexture()
|
||||
}
|
||||
}
|
||||
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, m_pSurface, false );
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, m_pSurface, false );
|
||||
}
|
||||
|
||||
|
||||
@@ -390,16 +390,16 @@ void MovieTexture_Generic::UpdateFrame()
|
||||
{
|
||||
ASSERT_M( m_ImageWaiting == FRAME_WAITING, ssprintf("%i", m_ImageWaiting) );
|
||||
|
||||
/* Just in case we were invalidated: */
|
||||
CreateTexture();
|
||||
/* Just in case we were invalidated: */
|
||||
CreateTexture();
|
||||
|
||||
CHECKPOINT;
|
||||
DISPLAY->UpdateTexture(
|
||||
m_uTexHandle,
|
||||
m_pSurface,
|
||||
0, 0,
|
||||
m_iImageWidth, m_iImageHeight );
|
||||
CHECKPOINT;
|
||||
m_uTexHandle,
|
||||
m_pSurface,
|
||||
0, 0,
|
||||
m_iImageWidth, m_iImageHeight );
|
||||
CHECKPOINT;
|
||||
|
||||
m_ImageWaiting = FRAME_NONE;
|
||||
}
|
||||
@@ -443,7 +443,7 @@ void MovieTexture_Generic::StopThread()
|
||||
|
||||
void MovieTexture_Generic::SetPosition( float fSeconds )
|
||||
{
|
||||
ASSERT( m_State != DECODER_QUIT );
|
||||
ASSERT( m_State != DECODER_QUIT );
|
||||
|
||||
/* We can reset to 0, but I don't think this API supports fast seeking
|
||||
* yet. I don't think we ever actually seek except to 0 right now,
|
||||
|
||||
@@ -9,42 +9,42 @@
|
||||
|
||||
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
|
||||
{
|
||||
LOG->Trace("MovieTexture_Null::MovieTexture_Null(ID)");
|
||||
texHandle = 0;
|
||||
LOG->Trace("MovieTexture_Null::MovieTexture_Null(ID)");
|
||||
texHandle = 0;
|
||||
|
||||
RageTextureID actualID = GetID();
|
||||
RageTextureID actualID = GetID();
|
||||
|
||||
actualID.iAlphaBits = 0;
|
||||
actualID.iAlphaBits = 0;
|
||||
int size = 64;
|
||||
m_iSourceWidth = size;
|
||||
m_iSourceHeight = size;
|
||||
m_iImageWidth = size;
|
||||
m_iImageHeight = size;
|
||||
m_iTextureWidth = power_of_two(size);
|
||||
m_iTextureHeight = m_iTextureWidth;
|
||||
m_iFramesWide = 1;
|
||||
m_iFramesHigh = 1;
|
||||
m_iSourceWidth = size;
|
||||
m_iSourceHeight = size;
|
||||
m_iImageWidth = size;
|
||||
m_iImageHeight = size;
|
||||
m_iTextureWidth = power_of_two(size);
|
||||
m_iTextureHeight = m_iTextureWidth;
|
||||
m_iFramesWide = 1;
|
||||
m_iFramesHigh = 1;
|
||||
|
||||
CreateFrameRects();
|
||||
CreateFrameRects();
|
||||
|
||||
PixelFormat pixfmt = PixelFormat_RGBA4;
|
||||
if( !DISPLAY->SupportsTextureFormat(pixfmt) )
|
||||
pixfmt = PixelFormat_RGBA8;
|
||||
ASSERT( DISPLAY->SupportsTextureFormat(pixfmt) );
|
||||
PixelFormat pixfmt = PixelFormat_RGBA4;
|
||||
if( !DISPLAY->SupportsTextureFormat(pixfmt) )
|
||||
pixfmt = PixelFormat_RGBA8;
|
||||
ASSERT( DISPLAY->SupportsTextureFormat(pixfmt) );
|
||||
|
||||
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc( pixfmt );
|
||||
RageSurface *img = CreateSurface( size, size, pfd->bpp,
|
||||
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc( pixfmt );
|
||||
RageSurface *img = CreateSurface( size, size, pfd->bpp,
|
||||
pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
||||
memset( img->pixels, 0, img->pitch*img->h );
|
||||
memset( img->pixels, 0, img->pitch*img->h );
|
||||
|
||||
texHandle = DISPLAY->CreateTexture( pixfmt, img, false );
|
||||
texHandle = DISPLAY->CreateTexture( pixfmt, img, false );
|
||||
|
||||
delete img;
|
||||
delete img;
|
||||
}
|
||||
|
||||
MovieTexture_Null::~MovieTexture_Null()
|
||||
{
|
||||
DISPLAY->DeleteTexture( texHandle );
|
||||
DISPLAY->DeleteTexture( texHandle );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -13,21 +13,21 @@
|
||||
#include "RageTexture.h"
|
||||
|
||||
class MovieTexture_Null : public RageMovieTexture {
|
||||
private:
|
||||
bool playing;
|
||||
bool loop;
|
||||
unsigned texHandle;
|
||||
|
||||
public:
|
||||
MovieTexture_Null(RageTextureID ID);
|
||||
virtual ~MovieTexture_Null();
|
||||
void Invalidate() { texHandle = 0; }
|
||||
unsigned GetTexHandle() const { return texHandle; }
|
||||
void Update(float delta) { }
|
||||
void Reload() { }
|
||||
void SetPosition(float seconds) { }
|
||||
void SetPlaybackRate(float rate) { }
|
||||
void SetLooping(bool looping=true) { loop = looping; }
|
||||
MovieTexture_Null(RageTextureID ID);
|
||||
virtual ~MovieTexture_Null();
|
||||
void Invalidate() { texHandle = 0; }
|
||||
unsigned GetTexHandle() const { return texHandle; }
|
||||
void Update(float delta) { }
|
||||
void Reload() { }
|
||||
void SetPosition(float seconds) { }
|
||||
void SetPlaybackRate(float rate) { }
|
||||
void SetLooping(bool looping=true) { loop = looping; }
|
||||
|
||||
private:
|
||||
bool playing;
|
||||
bool loop;
|
||||
unsigned texHandle;
|
||||
};
|
||||
#define USE_MOVIE_TEXTURE_NULL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user