2009-07-02, 03:41
is the conversion to directX completed yet? I'm in need of a DX surface to copy to
#include "VideoSource.h"
#include "FrameQueue.h"
#include "VideoParser.h"
#include <assert.h>
VideoSource::VideoSource(const std::string sFileName, FrameQueue * pFrameQueue): hVideoSource_(0)
{
// fill in SourceData struct as much as we can
// right now. Client must specify parser at a later point
// to avoid crashes (see setParser() method).
assert(0 != pFrameQueue);
oSourceData_.hVideoParser = 0;
oSourceData_.pFrameQueue = pFrameQueue;
CUVIDSOURCEPARAMS oVideoSourceParameters;
// Fill parameter struct
memset(&oVideoSourceParameters, 0, sizeof(CUVIDSOURCEPARAMS));
oVideoSourceParameters.pUserData = &oSourceData_; // will be passed to data handlers
oVideoSourceParameters.pfnVideoDataHandler = HandleVideoData; // our local video-handler callback
oVideoSourceParameters.pfnAudioDataHandler = 0;
// now create the actual source
CUresult oResult = cuvidCreateVideoSource(&hVideoSource_, sFileName.c_str(), &oVideoSourceParameters);
assert(CUDA_SUCCESS == oResult);
}
VideoSource::~VideoSource()
{
cuvidDestroyVideoSource(hVideoSource_);
}
void
VideoSource::ReloadVideo(const std::string sFileName, FrameQueue * pFrameQueue, VideoParser *pVideoParser)
{
// fill in SourceData struct as much as we can right now. Client must specify parser at a later point
assert(0 != pFrameQueue);
oSourceData_.hVideoParser = pVideoParser->hParser_;
oSourceData_.pFrameQueue = pFrameQueue;
cuvidDestroyVideoSource(hVideoSource_);
CUVIDSOURCEPARAMS oVideoSourceParameters;
// Fill parameter struct
memset(&oVideoSourceParameters, 0, sizeof(CUVIDSOURCEPARAMS));
oVideoSourceParameters.pUserData = &oSourceData_; // will be passed to data handlers
oVideoSourceParameters.pfnVideoDataHandler = HandleVideoData; // our local video-handler callback
oVideoSourceParameters.pfnAudioDataHandler = 0;
// now create the actual source
CUresult oResult = cuvidCreateVideoSource(&hVideoSource_, sFileName.c_str(), &oVideoSourceParameters);
assert(CUDA_SUCCESS == oResult);
}
CUVIDEOFORMAT
VideoSource::format()
const
{
CUVIDEOFORMAT oFormat;
CUresult oResult = cuvidGetSourceVideoFormat(hVideoSource_, &oFormat, 0);
assert(CUDA_SUCCESS == oResult);
return oFormat;
}
void
VideoSource::getDimensions(unsigned int &width, unsigned int &height)
{
CUVIDEOFORMAT rCudaVideoFormat= format();
width = rCudaVideoFormat.coded_width;
height = rCudaVideoFormat.coded_height;
}
void
VideoSource::setParser(VideoParser & rVideoParser)
{
oSourceData_.hVideoParser = rVideoParser.hParser_;
}
void
VideoSource::start()
{
CUresult oResult = cuvidSetVideoSourceState(hVideoSource_, cudaVideoState_Started);
assert(CUDA_SUCCESS == oResult);
}
void
VideoSource::stop()
{
CUresult oResult = cuvidSetVideoSourceState(hVideoSource_, cudaVideoState_Stopped);
assert(CUDA_SUCCESS == oResult);
}
bool
VideoSource::isStarted()
{
return (cuvidGetVideoSourceState(hVideoSource_) == cudaVideoState_Started);
}
int
VideoSource::HandleVideoData(void * pUserData, CUVIDSOURCEDATAPACKET * pPacket)
{
VideoSourceData * pVideoSourceData = (VideoSourceData *)pUserData;
// Parser calls back for decode & display within cuvidParseVideoData
CUresult oResult = cuvidParseVideoData(pVideoSourceData->hVideoParser, pPacket);
if ((pPacket->flags & CUVID_PKT_ENDOFSTREAM) || (oResult != CUDA_SUCCESS))
pVideoSourceData->pFrameQueue->endDecode();
return !pVideoSourceData->pFrameQueue->isEndOfDecode();
}
std::ostream &
operator << (std::ostream & rOutputStream, const CUVIDEOFORMAT & rCudaVideoFormat)
{
rOutputStream << "VideoCodec: ";
switch (rCudaVideoFormat.codec)
{
case cudaVideoCodec_MPEG1:
rOutputStream << "MPEG 1\n";
break;
case cudaVideoCodec_MPEG2:
rOutputStream << "MPEG 2\n";
break;
case cudaVideoCodec_MPEG4:
rOutputStream << "MPEG 4\n";
break;
case cudaVideoCodec_VC1:
rOutputStream << "VC 1\n";
break;
case cudaVideoCodec_H264:
rOutputStream << "H.264\n";
break;
default:
rOutputStream << "unknown\n";
}
rOutputStream << "Frame rate: " << rCudaVideoFormat.frame_rate.numerator << "/" << rCudaVideoFormat.frame_rate.denominator;
rOutputStream << "fps ~ " << rCudaVideoFormat.frame_rate.numerator/static_cast<float>(rCudaVideoFormat.frame_rate.denominator) << "fps\n";
rOutputStream << "Sequence format: ";
if (rCudaVideoFormat.progressive_sequence)
rOutputStream << "Progressive\n";
else
rOutputStream << "Interlaced\n";
rOutputStream << "Coded frame size: [" << rCudaVideoFormat.coded_width << ", " << rCudaVideoFormat.coded_height << "]\n";
rOutputStream << "Display area: [" << rCudaVideoFormat.display_area.left << ", " << rCudaVideoFormat.display_area.top;
rOutputStream << ", " << rCudaVideoFormat.display_area.right << ", " << rCudaVideoFormat.display_area.bottom << "]\n";
rOutputStream << "Chroma format: ";
switch (rCudaVideoFormat.chroma_format)
{
case cudaVideoChromaFormat_Monochrome:
rOutputStream << "Monochrome\n";
break;
case cudaVideoChromaFormat_420:
rOutputStream << "4:2:0\n";
break;
case cudaVideoChromaFormat_422:
rOutputStream << "4:2:2\n";
break;
case cudaVideoChromaFormat_444:
rOutputStream << "4:4:4\n";
break;
default:
rOutputStream << "unknown\n";
}
rOutputStream << "Bitrate: ";
if (rCudaVideoFormat.bitrate == 0)
rOutputStream << "unknown\n";
else
rOutputStream << rCudaVideoFormat.bitrate/1024 << "kBit/s\n";
rOutputStream << "Aspect ratio: " << rCudaVideoFormat.display_aspect_ratio.x << ":" << rCudaVideoFormat.display_aspect_ratio.y << "\n";
return rOutputStream;
}
Quote:Revision: 21540
http://xbmc.svn.sourceforge.net/xbmc/?re...0&view=rev
Author: jmarshallnz
Date: 2009-07-10 02:39:06 +0000 (Fri, 10 Jul 2009)
Log Message:
-----------
added: Projects for building a DirectX 9 version of XBMC, and an (extremely) basic window init routine.
Modified Paths:
--------------
branches/linuxport/XBMC/project/VS2008Express/UnrarXLib.vcproj
branches/linuxport/XBMC/project/VS2008Express/XBMC for Windows.sln
branches/linuxport/XBMC/project/VS2008Express/XBMC.vcproj
branches/linuxport/XBMC/project/VS2008Express/guilib.vcproj
branches/linuxport/XBMC/xbmc/win32/XBMC_PC.cpp
Quote: Revision: 21536
http://xbmc.svn.sourceforge.net/xbmc/?re...6&view=rev
Author: jmarshallnz
Date: 2009-07-10 00:52:04 +0000 (Fri, 10 Jul 2009)
Log Message:
-----------
changed: Moved DirectX code to DirectX 9.
Modified Paths:
--------------
branches/linuxport/XBMC/guilib/DirectXGraphics.cpp
branches/linuxport/XBMC/guilib/DirectXGraphics.h
branches/linuxport/XBMC/guilib/GUIFontTTF.cpp
branches/linuxport/XBMC/guilib/GUIFontTTF.h
branches/linuxport/XBMC/guilib/GUITextureD3D.cpp
branches/linuxport/XBMC/guilib/GraphicContext.cpp
branches/linuxport/XBMC/guilib/GraphicContext.h
branches/linuxport/XBMC/guilib/TextureManager.cpp
branches/linuxport/XBMC/guilib/gui3d.h
branches/linuxport/XBMC/xbmc/Application.cpp
branches/linuxport/XBMC/xbmc/ApplicationRenderer.cpp
branches/linuxport/XBMC/xbmc/ApplicationRenderer.h
branches/linuxport/XBMC/xbmc/GUIDialogVideoBookmarks.cpp
branches/linuxport/XBMC/xbmc/Picture.cpp
branches/linuxport/XBMC/xbmc/SlideShowPicture.cpp
branches/linuxport/XBMC/xbmc/Util.cpp
branches/linuxport/XBMC/xbmc/XBApplicationEx.cpp
branches/linuxport/XBMC/xbmc/XBApplicationEx.h
branches/linuxport/XBMC/xbmc/XBVideoConfig.cpp
branches/linuxport/XBMC/xbmc/XBVideoConfig.h
branches/linuxport/XBMC/xbmc/cores/DummyVideoPlayer.cpp
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/RenderManager.cpp
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/WinRenderManager.cpp
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/WinRenderer.cpp
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/WinRenderer.h
branches/linuxport/XBMC/xbmc/karaoke/karaokelyricscdg.cpp
branches/linuxport/XBMC/xbmc/karaoke/karaokelyricscdg.h
branches/linuxport/XBMC/xbmc/screensavers/DllScreenSaver.h
branches/linuxport/XBMC/xbmc/utils/Splash.cpp
Quote:Revision: 21531
http://xbmc.svn.sourceforge.net/xbmc/?re...1&view=rev
Author: jmarshallnz
Date: 2009-07-09 22:31:57 +0000 (Thu, 09 Jul 2009)
Log Message:
-----------
added: Add back the directx code for camera positioning.
changed: Guard access to m_screenSurface in a couple of spots.
Modified Paths:
--------------
branches/linuxport/XBMC/guilib/GraphicContext.cpp
Quote:Revision: 21525
http://xbmc.svn.sourceforge.net/xbmc/?re...5&view=rev
Author: jmarshallnz
Date: 2009-07-09 20:02:43 +0000 (Thu, 09 Jul 2009)
Log Message:
-----------
cleanup: Renderers were missing a few ifdef's.
changed: Bring the WinRenderer back in to the win32 build - not built under SDL/OpenGL.
Modified Paths:
--------------
branches/linuxport/XBMC/project/VS2008Express/XBMC.vcproj
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/RenderManager.cpp
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/RenderManager.h
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/WinRenderer.cpp
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/WinRenderer.h
branches/linuxport/XBMC/xbmc/cores/VideoRenderers/XBoxRenderer.h