1 /*****************************************************************************
2 * dxva.c: DXVA 2 video decoder
3 *****************************************************************************
4 * Copyright (C) 2009 Geoffroy Couprie
7 * Authors: Geoffroy Couprie <geal@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_plugin.h>
33 #include <vlc_codec.h>
44 DEFINE_GUID(DXVA2_ModeMPEG2_MoComp, 0xe6a9f44b, 0x61b0, 0x4563,0x9e,0xa4,0x63,0xd2,0xa3,0xc6,0xfe,0x66);
45 DEFINE_GUID(DXVA2_ModeMPEG2_IDCT, 0xbf22ad00, 0x03ea, 0x4690,0x80,0x77,0x47,0x33,0x46,0x20,0x9b,0x7e);
46 DEFINE_GUID(DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28, 0x4e65,0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9);
47 DEFINE_GUID(DXVA2_ModeH264_A, 0x1b81be64, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
48 DEFINE_GUID(DXVA2_ModeH264_B, 0x1b81be65, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
49 DEFINE_GUID(DXVA2_ModeH264_C, 0x1b81be66, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
50 DEFINE_GUID(DXVA2_ModeH264_D, 0x1b81be67, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
51 DEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
52 DEFINE_GUID(DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
53 DEFINE_GUID(DXVA2_ModeWMV8_A, 0x1b81be80, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
54 DEFINE_GUID(DXVA2_ModeWMV8_B, 0x1b81be81, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
55 DEFINE_GUID(DXVA2_ModeWMV9_A, 0x1b81be90, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
56 DEFINE_GUID(DXVA2_ModeWMV9_B, 0x1b81be91, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
57 DEFINE_GUID(DXVA2_ModeWMV9_C, 0x1b81be94, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
58 DEFINE_GUID(DXVA2_ModeVC1_A, 0x1b81beA0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
59 DEFINE_GUID(DXVA2_ModeVC1_B, 0x1b81beA1, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
60 DEFINE_GUID(DXVA2_ModeVC1_C, 0x1b81beA2, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
61 DEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
63 const GUID IID_IDirectXVideoDecoderService = {0xfc51a551,0xd5e7,0x11d9, {0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02}};
64 const GUID IID_IDirectXVideoAccelerationService = {0xfc51a550,0xd5e7,0x11d9,{0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02}};
66 const D3DFORMAT VIDEO_RENDER_TARGET_FORMAT = D3DFMT_X8R8G8B8;
70 #define print_error(a) format_error(p_dec, __FILE__, __FUNCTION__, __LINE__,a)
72 static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block );
73 LPDIRECTXVIDEODECODER pvid_dec;
74 LPDIRECT3DSURFACE9 psurfaces = NULL;
75 /*****************************************************************************
76 * decoder_sys_t : dxva decoder descriptor
77 *****************************************************************************/
80 HINSTANCE g_hinst; /* This application's HINSTANCE */
82 HWND g_hwndChild; /* Optional child window */
84 D3DPRESENT_PARAMETERS d3dpp;
85 LPDIRECT3DDEVICE9 g_pd3dDevice;
86 IDirect3DSurface9* g_pD3DRT;
89 /*****************************************************************************
91 *****************************************************************************/
92 static int OpenDecoder( vlc_object_t * );
93 static void CloseDecoder( vlc_object_t * );
95 /*****************************************************************************
97 *****************************************************************************/
99 set_description( N_("DXVA 2 video decoder") )
100 set_capability( "decoder", 150 )
101 set_category( CAT_INPUT )
102 set_subcategory( SUBCAT_INPUT_VCODEC )
103 set_callbacks( OpenDecoder, CloseDecoder )
104 add_shortcut( "dxva" )
107 /*****************************************************************************
108 * OpenDecoder: probe the decoder and return score
109 *****************************************************************************/
110 static int OpenDecoder( vlc_object_t *p_this )
112 decoder_t *p_dec = (decoder_t*)p_this;
113 decoder_sys_t *p_sys;
115 switch( p_dec->fmt_in.i_codec )
117 case VLC_FOURCC('h','2','6','4'):
118 //case VLC_FOURCC('m','p','g','2'):
119 //case VLC_FOURCC('m','p','g','v'):
120 //case VLC_CODEC_WMVA:
121 //case VLC_CODEC_VC1:
124 //if( p_dec->fmt_in.i_original_fourcc )
129 /* Allocate the memory needed to store the decoder's structure */
130 p_sys = malloc(sizeof(decoder_sys_t));
134 /************** VLC codec stuff **********************/
136 char original_fourcc[5];
138 original_fourcc[5] = 0;
139 vlc_fourcc_to_char(p_dec->fmt_in.i_codec, fourcc);
140 vlc_fourcc_to_char(p_dec->fmt_in.i_original_fourcc, original_fourcc);
141 msg_Dbg(p_dec, "Input format:\n\tcategory:%u\n\tcodec:%s\n\toriginal fourcc:%s\n\tbitrate:%u",
142 p_dec->fmt_in.i_cat,fourcc,original_fourcc, p_dec->fmt_in.i_bitrate);
143 msg_Dbg(p_dec, "Input format:\n\twidth:%u\n\theight:%u\n\tratio:%d",
144 p_dec->fmt_in.video.i_width,p_dec->fmt_in.video.i_height,p_dec->fmt_in.video.i_aspect);
145 /************** D3D stuff **********************/
147 ZeroMemory( &p_sys->d3dpp, sizeof(D3DPRESENT_PARAMETERS) );
149 p_sys->d3dpp.Windowed = TRUE;
150 p_sys->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
151 p_sys->d3dpp.BackBufferFormat = VIDEO_RENDER_TARGET_FORMAT;
152 p_sys->d3dpp.BackBufferWidth = p_dec->fmt_in.video.i_width;
153 p_sys->d3dpp.BackBufferHeight = p_dec->fmt_in.video.i_height;
154 p_sys->d3dpp.BackBufferCount = 2;
155 p_sys->d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
157 LPDIRECT3D9 (WINAPI *OurDirect3DCreate9)(UINT SDKVersion);
159 msg_Dbg( p_dec, "loading d3d dll" );
160 p_sys->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL"));
161 if( NULL == p_sys->hd3d9_dll )
163 msg_Warn( p_dec, "cannot load d3d9.dll, aborting" );
167 msg_Dbg( p_dec, "loading d3d function" );
169 (void *)GetProcAddress( p_sys->hd3d9_dll,
170 TEXT("Direct3DCreate9") );
171 if( OurDirect3DCreate9 == NULL )
173 msg_Err( p_dec, "Cannot locate reference to Direct3DCreate9 ABI in DLL" );
177 msg_Dbg( p_dec, "creating d3d" );
178 if( NULL == ( p_sys->g_pD3D = OurDirect3DCreate9( D3D_SDK_VERSION ) ) )
180 msg_Err( p_dec, "Direct3DCreate9 failed" );
184 msg_Dbg( p_dec, "creating d3d device" );
186 /* Direct3D needs a HWND to create a device, even without using ::Present
187 this HWND is used to alert Direct3D when there's a change of focus window.
188 For now, use GetShellWindow, as it looks harmless */
189 if( FAILED( IDirect3D9_CreateDevice( p_sys->g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetShellWindow(),
190 D3DCREATE_SOFTWARE_VERTEXPROCESSING,
191 &p_sys->d3dpp, &p_sys->g_pd3dDevice ) ) )
193 print_error("IDirect3D9_CreateDevice failed");
196 /*****************END OF D3D****************************/
198 /*****************DXVA STUFF****************************/
201 HINSTANCE hdxva2_dll;
203 HRESULT (WINAPI *MyDXVA2CreateVideoService)
205 IDirect3DDevice9 *pDD,
209 HRESULT (WINAPI *MyDXVA2CreateDirect3DDeviceManager9)
212 IDirect3DDeviceManager9 **ppDXVAManager
216 hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL"));
217 if( NULL == hdxva2_dll )
219 msg_Err( p_dec, "cannot load DXVA2\n");
223 MyDXVA2CreateVideoService =
224 (void *)GetProcAddress(hdxva2_dll,
225 TEXT("DXVA2CreateVideoService") );
227 if( MyDXVA2CreateVideoService == NULL )
229 msg_Err( p_dec, "cannot load function\n");
233 msg_Info( p_dec, "DXVA2CreateVideoService Success!");
235 MyDXVA2CreateDirect3DDeviceManager9 =
236 (void *)GetProcAddress(hdxva2_dll,
237 TEXT("DXVA2CreateDirect3DDeviceManager9") );
239 if( MyDXVA2CreateDirect3DDeviceManager9 == NULL )
241 msg_Err( p_dec, "cannot load function\n");
245 msg_Info( p_dec, "DXVA2CreateDirect3DDeviceManager9 Success!");
248 LPDIRECT3DDEVICEMANAGER9 p_devman;
249 if( FAILED( MyDXVA2CreateDirect3DDeviceManager9 ( &reset_token,&p_devman ) ) )
251 msg_Err( p_dec, " MyDXVA2CreateDirect3DDeviceManager9 failed");
255 msg_Info( p_dec, "obtained IDirect3DDeviceManager9");
257 HRESULT bb = IDirect3DDeviceManager9_ResetDevice( p_devman, p_sys->g_pd3dDevice, reset_token);
258 msg_Err( p_dec, "IDirect3DDeviceManager9_ResetDevice result: %08x", bb);
260 LPDIRECTXVIDEODECODERSERVICE g_pdxva_vs;
263 HRESULT hret1 = IDirect3DDeviceManager9_OpenDeviceHandle( p_devman, &hDevice);
265 HRESULT hret2 = IDirect3DDeviceManager9_GetVideoService( p_devman, hDevice, &IID_IDirectXVideoDecoderService,
266 (void **) &g_pdxva_vs );
268 /*****************configuration dxva****************************/
271 GUID* pdecoderguids = NULL;
273 if( FAILED( IDirectXVideoDecoderService_GetDecoderDeviceGuids ( g_pdxva_vs, &nbguid, &pdecoderguids ) ) )
275 msg_Err( p_dec, "IDirectXVideoDecoderService_GetDecoderDeviceGuids failed");
280 // Look for the decoder GUIDs we want.
281 for (iGuid = 0; iGuid < nbguid; iGuid++)
283 //liste des GUID à afficher plus tard en Dbg (pour savoir ce qu'on peut décoder)
284 msg_Dbg( p_dec, "GUID = %08X-%04x-%04x-XXXX\n", pdecoderguids[iGuid].Data1,pdecoderguids[iGuid].Data2,pdecoderguids[iGuid].Data3);
288 /* on prend pour les tests pdecoderguids[6] = DXVA2_ModeH264_E => H.264 VLD, no FGT.
289 On cherche parmi les GUID qu'on a récupérés celui qui correspond au codec de la vidéo
290 cf http://msdn.microsoft.com/en-us/library/ms697067%28VS.85%29.aspx pour une correspondance entre les GUID et les codecs
291 if( p_dec->fmt_in.i_original_fourcc == VLC_FOURCC('h','2','6','4'))
293 for (iGuid = 0; iGuid < nbguid; iGuid++)
299 // FAILS probably because of the unusual d3d device
301 D3DFORMAT *prender_targets = NULL;
303 if( FAILED( IDirectXVideoDecoderService_GetDecoderRenderTargets ( g_pdxva_vs,
304 &pdecoderguids[6], &nb_render, &prender_targets) ) )
306 msg_Err( p_dec, "IDirectXVideoDecoderService_GetDecoderRenderTargets failed");
311 vlc_fourcc_to_char(prender_targets[0], fourcc);
312 msg_Info( p_dec, "we got %d decoder formats, choosing d3dformat n° %d test desc:%s",
313 nb_render,prender_targets[0],fourcc);
315 /* Only one decoder format, for now */
316 /* Ici, il faut faire la même chose que les decoder GUIDs: on regarde les différents formats, et on en choisit un qui correspond*/
317 D3DFORMAT fmt = prender_targets[0];
318 DXVA2_VideoDesc vid_desc;
319 DXVA2_ExtendedFormat ext_fmt;
321 vid_desc.SampleWidth = p_dec->fmt_in.video.i_width;//???
322 vid_desc.SampleHeight = p_dec->fmt_in.video.i_height;//???
324 vid_desc.Format = prender_targets[0];
325 vid_desc.InputSampleFreq.Numerator = 60;
326 vid_desc.InputSampleFreq.Denominator = 1;
327 vid_desc.OutputFrameFreq.Numerator = 60;
328 vid_desc.OutputFrameFreq.Denominator = 1;
329 vid_desc.OutputFrameFreq = vid_desc.InputSampleFreq;
330 vid_desc.UABProtectionLevel = false;
331 vid_desc.Reserved = 0;
334 DXVA2_ConfigPictureDecode* pdec_conf = NULL;
335 if( FAILED( IDirectXVideoDecoderService_GetDecoderConfigurations ( g_pdxva_vs,
336 &pdecoderguids[0], &vid_desc, NULL, &nb_dec_conf, &pdec_conf )))
338 msg_Err( p_dec, "IDirectXVideoDecoderService_GetDecoderConfigurations failed\n");
342 msg_Info( p_dec, "we got %d decoder configurations", nb_dec_conf);
344 /* Création de la surface de rendering*/
345 if( FAILED( IDirectXVideoDecoderService_CreateSurface ( g_pdxva_vs, p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height,
346 1, prender_targets[0], D3DPOOL_DEFAULT, 0, 0/*DXVA2_VideoDecoderRenderTarget*/, &psurfaces, NULL )))
348 msg_Err( p_dec, "IDirectXVideoAccelerationService_CreateSurface failed\n");
352 msg_Info( p_dec, "we got d3d surfaces\n");
356 aa = IDirectXVideoDecoderService_CreateVideoDecoder ( g_pdxva_vs,
357 &pdecoderguids[6], &vid_desc, &pdec_conf[1], &psurfaces, 2,
359 // msg_Err( p_dec,"IDirectXVideoDecoderService_CreateVideoDecoder1: %08x\n", aa);
361 HRESULT cc = IDirect3DDeviceManager9_ResetDevice( p_devman, p_sys->g_pd3dDevice, reset_token);
362 //msg_Err( p_dec, "IDirect3DDeviceManager9_ResetDevice result: %08x\n", cc);
364 aa = IDirectXVideoDecoderService_CreateVideoDecoder ( g_pdxva_vs,
365 &pdecoderguids[6], &vid_desc, &pdec_conf[1], &psurfaces, 2,
367 //msg_Err( p_dec, "IDirectXVideoDecoderService_CreateVideoDecoder2: %08x\n", aa);
369 /*if( FAILED( IDirectXVideoDecoderService_CreateVideoDecoder ( g_pdxva_vs,
370 &pdecoderguids[6], &vid_desc, &pdec_conf[0], &psurfaces, 6,
373 print_error("IDirectXVideoDecoderService_CreateVideoDecoder failed");
378 p_dec->pf_decode_video = DecodeBlock;
379 p_dec->fmt_out.i_cat = VIDEO_ES;
380 p_dec->fmt_out.i_codec = VLC_CODEC_I420; //???
381 p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width;//pas sur
382 p_dec->fmt_out.video.i_height = p_dec->fmt_in.video.i_height;//???
383 p_dec->fmt_out.video.i_visible_width = p_dec->fmt_in.video.i_width;//???
384 p_dec->fmt_out.video.i_visible_height = p_dec->fmt_in.video.i_height;//???
385 p_dec->fmt_out.video.i_aspect = 1;//p_dec->fmt_in.video.i_aspect;//?????
386 p_dec->fmt_out.video.i_sar_num = 1;
387 p_dec->fmt_out.video.i_sar_den = 1;
392 /**************END OF DXVA******************************/
394 //CoTaskMemFree(pdecoderguids);
401 /*****************************************************************************
402 * DecodeBlock: dxva decoder
403 *****************************************************************************/
404 static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
406 decoder_sys_t *p_sys = p_dec->p_sys;
412 if( !pp_block || !*pp_block ) return NULL;
415 uint8_t * buf = p_block->p_buffer;
417 /*****************************************************************************/
418 /* Etapes du décodage: http://msdn.microsoft.com/en-us/library/aa965245%28VS.85%29.aspx#Decoding */
420 if( 0 != IDirectXVideoDecoder_BeginFrame(pvid_dec,psurfaces,NULL ) )
422 print_error("IDirectXVideoDecoder_BeginFrame failed");
425 UINT BufferType = DXVA2_PictureParametersBufferType;
428 if( 0 != IDirectXVideoDecoder_GetBuffer(pvid_dec, BufferType, &pBuffer, &BufferSize))
430 print_error("IDirectXVideoDecoder_GetBuffer failed");
434 // msg_Dbg( p_dec, "IDirectXVideoDecoder_GetBuffer -> buffer size=%u\n", BufferSize);
436 /*************** FILLING THE BUFFER *****************************/
437 /*here fill pbuffer with video*/
438 memcpy( pBuffer, p_block->p_buffer, BufferSize );
440 /*************** BUFFER FILLED ***********************************/
441 if( 0 != IDirectXVideoDecoder_ReleaseBuffer(pvid_dec, BufferType) )
443 print_error("IDirectXVideoDecoder_ReleaseBuffer failed");
445 /*************** DECODE VIDEO ***********************/
447 DXVA2_DecodeExecuteParams params;
448 params.NumCompBuffers = 1;
450 DXVA2_DecodeBufferDesc bufferdesc[2];
451 bufferdesc[0].CompressedBufferType = BufferType;
452 bufferdesc[0].BufferIndex = 0; // Reserved
453 bufferdesc[0].DataOffset = 0;
454 bufferdesc[0].DataSize = BufferSize;
455 bufferdesc[0].FirstMBaddress = 0; //??????
456 bufferdesc[0].NumMBsInBuffer = 1; //??????
457 bufferdesc[0].Width = 0; // Reserved
458 bufferdesc[0].Height = 0; // Reserved
459 bufferdesc[0].Stride = 0; // Reserved
460 bufferdesc[0].ReservedBits = 0; // Reserved
461 bufferdesc[0].pvPVPState = NULL; // No encrypted data
463 params.pCompressedBuffers = bufferdesc;
464 params.pExtensionData = NULL; // no private data to send to the driver
465 HRESULT hr2 = IDirectXVideoDecoder_Execute(pvid_dec, ¶ms);
466 if(hr2 != (HRESULT)0x00000000L)
469 // msg_Err( p_dec, "IDirectXVideoDecoder_Execute failed with error %08x\n", hr2);
473 // msg_Err( p_dec, "\n\nIDirectXVideoDecoder_Execute SUCCESS\n\n");
476 bufferdesc[1].CompressedBufferType = DXVA2_BitStreamDateBufferType;
477 bufferdesc[1].BufferIndex = 0; // Reserved
478 bufferdesc[1].DataOffset = 0;
479 bufferdesc[1].DataSize = BufferSize;
480 bufferdesc[1].FirstMBaddress = 0; //??????
481 bufferdesc[1].NumMBsInBuffer = 1; //??????
482 bufferdesc[1].Width = 0; // Reserved
483 bufferdesc[1].Height = 0; // Reserved
484 bufferdesc[1].Stride = 0; // Reserved
485 bufferdesc[1].ReservedBits = 0; // Reserved
486 bufferdesc[1].pvPVPState = NULL; // No encrypted data
488 DXVA2_DecodeExecuteParams params2;
489 params2.NumCompBuffers = 1;
490 params2.pCompressedBuffers = bufferdesc + 1;
491 params2.pExtensionData = NULL; // no private data to send to the driver
495 if( 0 != IDirectXVideoDecoder_GetBuffer(pvid_dec, DXVA2_BitStreamDateBufferType, &pBuffer2, &BufferSize2))
497 // print_error("IDirectXVideoDecoder_GetBuffer failed");
501 // msg_Dbg( p_dec, "IDirectXVideoDecoder_GetBuffer bitstream -> buffer size=%u\n", BufferSize2);
502 hr2 = IDirectXVideoDecoder_Execute(pvid_dec, ¶ms2);
503 if(hr2 != (HRESULT)0x00000000L)
506 // msg_Err( p_dec, "IDirectXVideoDecoder_Execute bitstream failed with error %08x\n", hr2);
510 // msg_Err( p_dec, "\n\nIDirectXVideoDecoder_Execute bitstream SUCCESS\n\n");
513 /*************** END OF DECODING ***********************/
518 if( 0 != IDirectXVideoDecoder_EndFrame(pvid_dec,&endframeout) )
520 print_error("IDirectXVideoDecoder_EndFrame");
524 //msg_Dbg( p_dec, "New picture");
525 /* Get a new picture */
526 p_pic = decoder_NewPicture( p_dec );
527 if( !p_pic ) return NULL;
528 //msg_Dbg( p_dec, "Got a new picture");
530 /*access the surface's memory*/
531 D3DLOCKED_RECT d3dlock;
532 if( FAILED( IDirect3DSurface9_LockRect( psurfaces, &d3dlock, NULL, 0/*??*/)) )
536 //Copy in picture_t, not block
537 //memcpy( p_block->p_buffer, d3dlock.pBits, BufferSize );
538 if( FAILED(IDirect3DSurface9_UnlockRect( psurfaces )))
543 /* Error handling, dates des samples, bloc_Release? */
544 block_Release( p_block );
548 /*****************************************************************************
549 * CloseDecoder: dxva decoder destruction
550 *****************************************************************************/
551 static void CloseDecoder( vlc_object_t *p_this )
553 decoder_t *p_dec = (decoder_t *)p_this;
554 decoder_sys_t *p_sys = p_dec->p_sys;
556 if( p_sys->g_pd3dDevice != NULL)
557 IDirect3DDevice9_Release( p_sys->g_pd3dDevice );
558 if( p_sys->g_pD3D != NULL)
559 IDirect3D9_Release( p_sys->g_pD3D );
564 void format_error(decoder_t *p_dec, char * file, char * function, int line, char * msg)
567 DWORD err = GetLastError();
568 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
570 err, /*dwMessageId */
571 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* dwLanguageId */
574 msg_Err( p_dec, "Error in %s:%d - %s : %08x-%s | %s", file, line, function, err, lpMsgBuf, msg);