Kellaw

Anyone know of a C++ coding which can tell you if your machine can support DXVA(DirectX Video Acceleration) like a Query
Thanks. Planning to make a simple video player which supports DXVA in Visual C++. Would help if the second problem could be solved too. Stuck here. Thanks in advance.


Re: Media Foundation Development VISUAL C++ on DXVA

Mustafa Husain - MSFT

For DXVA2 - the DXVA capabilities can be explored as follows.

// For decoding caps
hr = DXVA2CreateVideoService(pD3DDevice, IID_IDirectXVideoDecoderService, (void**)&pVDS);

// http://msdn2.microsoft.com/en-us/library/ms704721.aspx

if (FAILED(hr) || (NULL == pVDS))
{
ErrorCodeFromHResult(hr, szErrMsg);
printf("\n\tFailed to create video decoder service (%s).", szErrMsg);
break;
}

// explore guids
printf("\n");
printf("\n\t\bEnumerating video decoding modes..");
hr = pVDS->GetDecoderDeviceGuids(&uGuids, &rgGuids); (http://msdn2.microsoft.com/en-us/library/ms697067.aspx)
if (FAILED(hr))
{
ErrorCodeFromHResult(hr, szErrMsg);
printf("FAILED (%s).", szErrMsg);
break;
}

// For VPS caps
hr = DXVA2CreateVideoService(pD3DDevice, IID_IDirectXVideoProcessorService, (void**)&pVPS);
if (FAILED(hr) || (NULL == pVPS))
{
ErrorCodeFromHResult(hr, szErrMsg);
printf("\n\tFailed to create video processor service (%s).", szErrMsg);
goto end

}

// initialize VD ---- Setting some video defaults
VD.SampleWidth = g_dwWidth;
VD.SampleHeight = g_dwHeight;
VD.Format = (D3DFORMAT)g_d3dFormat;
VD.SampleFormat.SampleFormat = g_SampleFormat;
VD.InputSampleFreq.Numerator = g_dwInFreqNum;
VD.InputSampleFreq.Denominator = g_dwInFreqDen;
VD.OutputFrameFreq.Numerator = g_dwOutFreqNum;
VD.OutputFrameFreq.Denominator = g_dwOutFreqDen;

// explore guids
printf("\n\t\bEnumerating video processor modes..");
hr = pVPS->GetVideoProcessorDeviceGuids(&VD, &uGuids, &rgGuids); (http://msdn2.microsoft.com/en-us/library/ms695370.aspx)
if (FAILED(hr))
{
ErrorCodeFromHResult(hr, szErrMsg);
printf("FAILED (%s).", szErrMsg);

goto end

}

--------------------

For DXVA1 -

code found below i.e. IsDXVApresent()

Thanks

-MH






Re: Media Foundation Development VISUAL C++ on DXVA

Kellaw

I still can't run it. You sure it works mus

By the way a friend gave me one way:-

Download DCT

Then go to C:\DCT_II\Common\DXVA

and run DXVADisplayTest.exe

I need the code for that exe

Got any contacts which I may get that

Thanks

--------EDIT--------

found out more info about the .exe file

version is the 6..... thing and aaroned I think is the author

6.4.4094.0 (aaroned.030828-1057)





Re: Media Foundation Development VISUAL C++ on DXVA

Mustafa Husain - MSFT

The above "For DXVA 1" copy pasted is indeed the code used in DXVAdisplaytest.exe to detect HW acceleration supported by the driver.

Can you be more specific what doesnt work for you using the above code

Thanks,

MH






Re: Media Foundation Development VISUAL C++ on DXVA

Kellaw

I copied and paste that DXVA 1 code into a new project in visual C++ like what i used to do for programming work but it doesn't work when i compile. BTW i am new at windows programming. Below is the error message i got

Code Snippet

1>------ Build started: Project: DXVANew, Configuration: Debug Win32 ------

1>Compiling...

1>Main.cpp

1>c:\documents and settings\wlaw2\my documents\visual studio 2005\projects\dxvanew\dxvanew\main.cpp(17) : error C2039: 'CoCreateInstance' : is not a member of 'CComPtr<IAMDirectSound>'

1> with

1> [

1> IAMDirectSound=IGraphBuilder

1> ]

1>c:\documents and settings\wlaw2\my documents\visual studio 2005\projects\dxvanew\dxvanew\main.cpp(21) : error C2065: 'cout' : undeclared identifier

1>c:\documents and settings\wlaw2\my documents\visual studio 2005\projects\dxvanew\dxvanew\main.cpp(26) : error C2039: 'CoCreateInstance' : is not a member of 'CComPtr<IAMDirectSound>'

1> with

1> [

1> IAMDirectSound=IBaseFilter

1> ]

1>c:\documents and settings\wlaw2\my documents\visual studio 2005\projects\dxvanew\dxvanew\main.cpp(66) : error C2039: 'QueryInterface' : is not a member of 'CComPtr<IAMDirectSound>'

1> with

1> [

1> IAMDirectSound=IPin

1> ]

1>Build log was saved at "file://c:\Documents and Settings\wlaw2\My Documents\Visual Studio 2005\Projects\DXVANew\DXVANew\Debug\BuildLog.htm"

1>DXVANew - 4 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========





Re: Media Foundation Development VISUAL C++ on DXVA

Kellaw

Does the DXVADisplaytest.exe includes a encoder and decoder

I need the full codes for it if possible. Thanks





Re: Media Foundation Development VISUAL C++ on DXVA

Mustafa Husain - MSFT

Make sure you have the windows SDK installed on your machine and integrated with your VS.

1)Create a VCproj with this file -

//------------------------------------------------------------------------------

// File: DXVADetect.cpp

//

// Desc: This program detects the presence of Video Accleration GUIDs which

// indicate the present of acceleration.

//

// Copyright (c) 1999-2001, Microsoft Corporation. All rights reserved.

//------------------------------------------------------------------------------

#include <atlbase.h>

#include <iostream>

#include <streams.h> //*Additional include

#include <videoacc.h>

#include <initguid.h>

#include <dxva.h>

using namespace std;

bool IsDXVAPresent(void);

int main(int argc, char* argv[]) //

{

cout << "DXVADetect 1.0\n----------\n";

cout << "This program detects support for DirectX Video Acceleration\n"

"and other hardware video accelerators.\n----------\n\n";

CoInitialize(NULL);

bool bDXVA= IsDXVAPresent();

CoUninitialize();

return (bDXVA) 1 : 0;

}

//------------------------------------------------------------------------------

// Name: IsDXVAPresent()

// Desc: This function tests whether the video driver supports DirectX Video

// acceleration (DXVA).

//------------------------------------------------------------------------------

bool IsDXVAPresent(void)

{

HRESULT hr;

CComPtr<IGraphBuilder> pGraph;

hr = pGraph.CoCreateInstance(CLSID_FilterGraph);

if (FAILED(hr))

{

cout << "Could not determine if DXVA is supported - Assuming that it is.\n";

return true;

}

CComPtr<IBaseFilter> pMixer;

hr = pMixer.CoCreateInstance(CLSID_OverlayMixer);

if (FAILED(hr))

{

cout << "Could not determine if DXVA is supported - Assuming that it is.\n";

return true;

}

hr = pGraph->AddFilter(pMixer, L"Mixer");

if (FAILED(hr))

{

cout << "Could not determine if DXVA is supported - Assuming that it is.\n";

return true;

}

CComPtr<IEnumPins> pEnum;

hr = pMixer->EnumPins(&pEnum);

if (FAILED(hr))

{

cout << "Could not determine if DXVA is supported - Assuming that it is.\n";

return true;

}

CComPtr<IPin> pPin;

ULONG ulFetched;

hr = pEnum->Next(1, &pPin, &ulFetched);

if (FAILED(hr) || 0 == ulFetched)

{

cout << "Could not determine if DXVA is supported - Assuming that it is.\n";

return true;

}

CComPtr<IAMVideoAccelerator> pAccel;

hr = pPin.QueryInterface(&pAccel);

if (FAILED(hr))

{

cout << "Could not determine if DXVA is supported - Assuming that it is.\n";

return true;

}

DWORD dwGuids = 0;

hr = pAccel->GetVideoAcceleratorGUIDs(&dwGuids, NULL);

if (SUCCEEDED(hr) && 0 < dwGuids) // we found some acceleration

{

cout << "DXVA or other form of hardware video acceleration is present.\n";

cout << "\nSupported Modes:\n";

GUID * pGuids = new GUID[dwGuids];

GUID * pCurGuid = pGuids;

if (NULL == pGuids)

{

cout << "Could not determine.\n";

return true;

}

hr = pAccel->GetVideoAcceleratorGUIDs(&dwGuids, pGuids);

if (FAILED(hr))

{

delete[] pGuids;

cout << "Could not determine.\n";

return true;

}

for (DWORD i = 0; i < dwGuids; i++, pCurGuid++)

{

//Log the GUIDs here

OLECHAR wsz[40];char szStr[100];

StringFromGUID2(*pCurGuid, wsz, sizeof(wsz)/sizeof(OLECHAR));

WideCharToMultiByte(CP_ACP, 0, wsz, -1, szStr, 100, NULL, NULL) ;

cout << szStr << "\n";

}

delete[] pGuids;

return true;

}

else

{

cout << "No form of hardware video acceleration is present.\n";

return false;

}

}

3) Additional Includes and Lib path:

X:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\Multimedia\DirectShow\BaseClasses

X:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\Multimedia\DirectShow\BaseClasses\Debug\strmbasd.lib

4) Build and Run via command line .(Should enumerate the GUIDs if any HW accl present.)

Thanks

-MH