12 0xfc51a551, 0xd5e7, 0x11d9, {0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02}
16 static inline QString
toString(
const GUID& guid)
18 return QString(
"%1-%2-%3-%4%5-%6%7%8%9%10%11")
19 .arg(guid.Data1, 8, 16, QLatin1Char(
'0'))
20 .arg(guid.Data2, 4, 16, QLatin1Char(
'0'))
21 .arg(guid.Data3, 4, 16, QLatin1Char(
'0'))
22 .arg(guid.Data4[0], 2, 16, QLatin1Char(
'0'))
23 .arg(guid.Data4[1], 2, 16, QLatin1Char(
'0'))
24 .arg(guid.Data4[2], 2, 16, QLatin1Char(
'0'))
25 .arg(guid.Data4[3], 2, 16, QLatin1Char(
'0'))
26 .arg(guid.Data4[4], 2, 16, QLatin1Char(
'0'))
27 .arg(guid.Data4[5], 2, 16, QLatin1Char(
'0'))
28 .arg(guid.Data4[6], 2, 16, QLatin1Char(
'0'))
29 .arg(guid.Data4[7], 2, 16, QLatin1Char(
'0')).toUpper();
32 #define LOC QString("DXVA2: ")
33 #define ERR QString("DXVA2 Error: ")
36 DEFINE_GUID(DXVA2_ModeH264_A, 0x1b81be64, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
37 DEFINE_GUID(DXVA2_ModeH264_B, 0x1b81be65, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
38 DEFINE_GUID(DXVA2_ModeH264_C, 0x1b81be66, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
39 DEFINE_GUID(DXVA2_ModeH264_D, 0x1b81be67, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
40 DEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
41 DEFINE_GUID(DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
43 DEFINE_GUID(DXVA2_ModeWMV8_A, 0x1b81be80, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
44 DEFINE_GUID(DXVA2_ModeWMV8_B, 0x1b81be81, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
46 DEFINE_GUID(DXVA2_ModeWMV9_A, 0x1b81be90, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
47 DEFINE_GUID(DXVA2_ModeWMV9_B, 0x1b81be91, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
48 DEFINE_GUID(DXVA2_ModeWMV9_C, 0x1b81be94, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
50 DEFINE_GUID(DXVA2_ModeVC1_A, 0x1b81beA0, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
51 DEFINE_GUID(DXVA2_ModeVC1_B, 0x1b81beA1, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
52 DEFINE_GUID(DXVA2_ModeVC1_C, 0x1b81beA2, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
53 DEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7, 0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
55 DEFINE_GUID(DXVA2_ModeMPEG2_MoComp, 0xe6a9f44b, 0x61b0, 0x4563, 0x9e,0xa4,0x63,0xd2,0xa3,0xc6,0xfe,0x66);
56 DEFINE_GUID(DXVA2_ModeMPEG2_IDCT, 0xbf22ad00, 0x03ea, 0x4690, 0x80,0x77,0x47,0x33,0x46,0x20,0x9b,0x7e);
57 DEFINE_GUID(DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28, 0x4e65, 0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9);
60 #define DXVA2_ModeWMV8_PostProc DXVA2_ModeWMV8_A
61 #define DXVA2_ModeWMV8_MoComp DXVA2_ModeWMV8_B
63 #define DXVA2_ModeWMV9_PostProc DXVA2_ModeWMV9_A
64 #define DXVA2_ModeWMV9_MoComp DXVA2_ModeWMV9_B
65 #define DXVA2_ModeWMV9_IDCT DXVA2_ModeWMV9_C
67 #define DXVA2_ModeVC1_PostProc DXVA2_ModeVC1_A
68 #define DXVA2_ModeVC1_MoComp DXVA2_ModeVC1_B
69 #define DXVA2_ModeVC1_IDCT DXVA2_ModeVC1_C
70 #define DXVA2_ModeVC1_VLD DXVA2_ModeVC1_D
72 #define DXVA2_ModeH264_MoComp_NoFGT DXVA2_ModeH264_A
73 #define DXVA2_ModeH264_MoComp_FGT DXVA2_ModeH264_B
74 #define DXVA2_ModeH264_IDCT_NoFGT DXVA2_ModeH264_C
75 #define DXVA2_ModeH264_IDCT_FGT DXVA2_ModeH264_D
76 #define DXVA2_ModeH264_VLD_NoFGT DXVA2_ModeH264_E
77 #define DXVA2_ModeH264_VLD_FGT DXVA2_ModeH264_F
79 DEFINE_GUID(DXVA2_Intel_ModeH264_A, 0x604F8E64, 0x4951, 0x4c54, 0x88,0xFE,0xAB,0xD2,0x5C,0x15,0xB3,0xD6);
80 DEFINE_GUID(DXVA2_Intel_ModeH264_C, 0x604F8E66, 0x4951, 0x4c54, 0x88,0xFE,0xAB,0xD2,0x5C,0x15,0xB3,0xD6);
81 DEFINE_GUID(DXVA2_Intel_ModeH264_E, 0x604F8E68, 0x4951, 0x4c54, 0x88,0xFE,0xAB,0xD2,0x5C,0x15,0xB3,0xD6);
82 DEFINE_GUID(DXVA2_Intel_ModeVC1_E , 0xBCC5DB6D, 0xA2B6, 0x4AF0, 0xAC,0xE4,0xAD,0xB1,0xF7,0x87,0xBC,0x89);
93 {
"MPEG2 MoComp", &DXVA2_ModeMPEG2_MoComp,
kCodec_NONE},
98 {
"H.264 IDCT, FGT", &DXVA2_ModeH264_D,
kCodec_NONE},
99 {
"H.264 IDCT, no FGT", &DXVA2_ModeH264_C,
kCodec_NONE},
100 {
"H.264 MoComp, FGT", &DXVA2_ModeH264_B,
kCodec_NONE},
101 {
"H.264 MoComp, no FGT", &DXVA2_ModeH264_A,
kCodec_NONE},
104 {
"WMV8 post processing", &DXVA2_ModeWMV8_A,
kCodec_NONE},
108 {
"WMV9 post processing", &DXVA2_ModeWMV9_A,
kCodec_NONE},
114 {
"VC-1 post processing", &DXVA2_ModeVC1_A,
kCodec_NONE},
117 {
"Intel H.264 IDCT, no FGT", &DXVA2_Intel_ModeH264_C,
kCodec_NONE},
118 {
"Intel H.264 MoComp, no FGT", &DXVA2_Intel_ModeH264_A,
kCodec_NONE},
124 #define CREATE_CHECK(arg1, arg2) \
129 LOG(VB_GENERAL, LOG_ERR, LOC + (arg2)); \
134 : m_codec_id(codec_id), m_width(width), m_height(height)
136 memset(&
m_format, 0,
sizeof(DXVA2_VideoDesc));
137 memset(&
m_context, 0,
sizeof(dxva_context));
138 memset(&
m_config, 0,
sizeof(DXVA2_ConfigPictureDecode));
141 m_context.surface =
new IDirect3DSurface9*[num_bufs];
142 for (
uint i = 0; i < num_bufs; i++)
176 if (!create_video_service)
182 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to get device manager.");
189 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to get device handle.");
199 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to get video service.");
203 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Created DXVA2 video service.");
212 IDirectXVideoDecoderService_Release(
m_service);
222 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Looking for support for %1")
227 IDirectXVideoDecoderService_GetDecoderDeviceGuids(
231 !mode->
name.isEmpty() &&
m_format.Format == D3DFMT_UNKNOWN;
236 for (
uint j = 0; j < input_count; j++)
238 if (IsEqualGUID(input_list[j], *mode->guid))
240 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Testing %1")
248 return m_format.Format != D3DFMT_UNKNOWN;
255 uint output_count = 0;
256 D3DFORMAT *output_list =
nullptr;
257 IDirectXVideoDecoderService_GetDecoderRenderTargets(
258 m_service, guid, &output_count, &output_list);
259 for(
uint i = 0; i < output_count; i++)
261 if(output_list[i] == MAKEFOURCC(
'Y',
'V',
'1',
'2') ||
262 output_list[i] == MAKEFOURCC(
'N',
'V',
'1',
'2'))
276 m_format.InputSampleFreq.Numerator = 0;
277 m_format.InputSampleFreq.Denominator = 0;
279 m_format.UABProtectionLevel =
false;
289 DXVA2_ConfigPictureDecode *cfg_list =
nullptr;
290 IDirectXVideoDecoderService_GetDecoderConfigurations(
293 DXVA2_ConfigPictureDecode config = {};
295 for (
uint i = 0; i < cfg_count; i++)
298 if (config.ConfigBitstreamRaw == 0 &&
299 cfg_list[i].ConfigBitstreamRaw != 0)
301 config = cfg_list[i];
304 if (config.ConfigBitstreamRaw != bitstream &&
305 cfg_list[i].ConfigBitstreamRaw == bitstream)
307 config = cfg_list[i];
311 if(!config.ConfigBitstreamRaw)
315 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Found bitstream type %1")
316 .arg(
m_context.cfg->ConfigBitstreamRaw));
325 HRESULT hr = IDirectXVideoDecoderService_CreateSurface(
328 D3DPOOL_DEFAULT, 0, DXVA2_VideoDecoderRenderTarget,
334 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Created %1 decoder surfaces.")
359 HRESULT hr = IDirectXVideoDecoderService_CreateVideoDecoder(
361 const_cast<DXVA2_ConfigPictureDecode*
>(
m_context.cfg),
367 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
368 QString(
"Created decoder: %1->%2x%3 (%4 surfaces)")
377 IDirectXVideoDecoder_Release(
m_context.decoder);