static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt, const es_format_t *fmt, picture_sys_t *p_sys) { int err = VLC_EGENERIC; directx_sys_t *dx_sys; if (pix_fmt != AV_PIX_FMT_D3D11VA_VLD) return VLC_EGENERIC; vlc_va_sys_t *sys = calloc(1, sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H) sys->dxgidebug_dll = LoadLibrary(TEXT("DXGIDEBUG.DLL")); #endif dx_sys = &sys->dx_sys; dx_sys->pf_check_device = CheckDevice; dx_sys->pf_create_device = D3dCreateDevice; dx_sys->pf_destroy_device = D3dDestroyDevice; dx_sys->pf_create_device_manager = D3dCreateDeviceManager; dx_sys->pf_destroy_device_manager = D3dDestroyDeviceManager; dx_sys->pf_create_video_service = DxCreateVideoService; dx_sys->pf_destroy_video_service = DxDestroyVideoService; dx_sys->pf_create_decoder_surfaces = DxCreateDecoderSurfaces; dx_sys->pf_destroy_surfaces = DxDestroySurfaces; dx_sys->pf_setup_avcodec_ctx = SetupAVCodecContext; dx_sys->pf_get_input_list = DxGetInputList; dx_sys->pf_setup_output = DxSetupOutput; dx_sys->pf_alloc_surface_pic = DxAllocPicture; dx_sys->psz_decoder_dll = TEXT("D3D11.DLL"); va->sys = sys; dx_sys->d3ddev = NULL; va->sys->render = DXGI_FORMAT_UNKNOWN; if ( p_sys != NULL && p_sys->context != NULL ) { ID3D11VideoContext *d3dvidctx = NULL; HRESULT hr = ID3D11DeviceContext_QueryInterface(p_sys->context, &IID_ID3D11VideoContext, (void **)&d3dvidctx); if (FAILED(hr)) { msg_Err(va, "Could not Query ID3D11VideoDevice Interface from the picture. (hr=0x%lX)", hr); } else { ID3D11DeviceContext_GetDevice( p_sys->context, (ID3D11Device**) &dx_sys->d3ddev ); sys->d3dctx = p_sys->context; sys->d3dvidctx = d3dvidctx; assert(p_sys->texture != NULL); D3D11_TEXTURE2D_DESC dstDesc; ID3D11Texture2D_GetDesc( (ID3D11Texture2D*) p_sys->texture, &dstDesc); sys->render = dstDesc.Format; } } err = directx_va_Open(va, &sys->dx_sys, ctx, fmt, dx_sys->d3ddev==NULL || va->sys->d3dctx==NULL); if (err!=VLC_SUCCESS) goto error; if (p_sys == NULL) { sys->filter = CreateFilter( VLC_OBJECT(va), fmt, VLC_CODEC_YV12); if (sys->filter == NULL) goto error; } err = directx_va_Setup(va, &sys->dx_sys, ctx); if (err != VLC_SUCCESS) goto error; ctx->hwaccel_context = &sys->hw; /* TODO print the hardware name/vendor for debugging purposes */ va->description = DxDescribe(dx_sys); va->setup = Setup; va->get = Get; va->release = directx_va_Release; va->extract = Extract; return VLC_SUCCESS; error: Close(va, ctx); return err; }
static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt, const es_format_t *fmt, picture_sys_t *p_sys) { int err = VLC_EGENERIC; directx_sys_t *dx_sys; if (pix_fmt != AV_PIX_FMT_DXVA2_VLD) return VLC_EGENERIC; vlc_va_sys_t *sys = calloc(1, sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; /* Load dll*/ sys->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL")); if (!sys->hd3d9_dll) { msg_Warn(va, "cannot load d3d9.dll"); goto error; } dx_sys = &sys->dx_sys; dx_sys->pf_check_device = CheckDevice; dx_sys->pf_create_device = D3dCreateDevice; dx_sys->pf_destroy_device = D3dDestroyDevice; dx_sys->pf_create_device_manager = D3dCreateDeviceManager; dx_sys->pf_destroy_device_manager = D3dDestroyDeviceManager; dx_sys->pf_create_video_service = DxCreateVideoService; dx_sys->pf_destroy_video_service = DxDestroyVideoService; dx_sys->pf_create_decoder_surfaces = DxCreateVideoDecoder; dx_sys->pf_destroy_surfaces = DxDestroyVideoDecoder; dx_sys->pf_setup_avcodec_ctx = SetupAVCodecContext; dx_sys->pf_get_input_list = DxGetInputList; dx_sys->pf_setup_output = DxSetupOutput; dx_sys->pf_alloc_surface_pic = DxAllocPicture; dx_sys->psz_decoder_dll = TEXT("DXVA2.DLL"); va->sys = sys; dx_sys->d3ddev = NULL; if (p_sys!=NULL) IDirect3DSurface9_GetDevice(p_sys->surface, (IDirect3DDevice9**) &dx_sys->d3ddev ); err = directx_va_Open(va, &sys->dx_sys, ctx, fmt, true); if (err!=VLC_SUCCESS) goto error; if (p_sys == NULL) { sys->filter = CreateFilter( VLC_OBJECT(va), fmt, VLC_CODEC_YV12); if (sys->filter == NULL) goto error; } err = directx_va_Setup(va, &sys->dx_sys, ctx); if (err != VLC_SUCCESS) goto error; ctx->hwaccel_context = &sys->hw; /* TODO print the hardware name/vendor for debugging purposes */ va->description = DxDescribe(sys); va->setup = Setup; va->get = Get; va->release = directx_va_Release; va->extract = Extract; return VLC_SUCCESS; error: Close(va, ctx); return VLC_EGENERIC; }
static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt, const es_format_t *fmt, picture_sys_t *p_sys) { int err = VLC_EGENERIC; directx_sys_t *dx_sys; if (pix_fmt != AV_PIX_FMT_DXVA2_VLD) return VLC_EGENERIC; ctx->hwaccel_context = NULL; vlc_va_sys_t *sys = calloc(1, sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; /* Load dll*/ sys->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL")); if (!sys->hd3d9_dll) { msg_Warn(va, "cannot load d3d9.dll"); goto error; } dx_sys = &sys->dx_sys; dx_sys->va_pool.pf_create_device = D3dCreateDevice; dx_sys->va_pool.pf_destroy_device = D3dDestroyDevice; dx_sys->va_pool.pf_create_device_manager = D3dCreateDeviceManager; dx_sys->va_pool.pf_destroy_device_manager = D3dDestroyDeviceManager; dx_sys->va_pool.pf_create_video_service = DxCreateVideoService; dx_sys->va_pool.pf_destroy_video_service = DxDestroyVideoService; dx_sys->va_pool.pf_create_decoder_surfaces = DxCreateVideoDecoder; dx_sys->va_pool.pf_destroy_surfaces = DxDestroyVideoDecoder; dx_sys->va_pool.pf_setup_avcodec_ctx = SetupAVCodecContext; dx_sys->va_pool.pf_new_surface_context = NewSurfacePicContext; dx_sys->pf_get_input_list = DxGetInputList; dx_sys->pf_setup_output = DxSetupOutput; dx_sys->psz_decoder_dll = TEXT("DXVA2.DLL"); va->sys = sys; dx_sys->d3ddev = NULL; if (p_sys!=NULL) { D3DSURFACE_DESC src; if (SUCCEEDED(IDirect3DSurface9_GetDesc(p_sys->surface, &src))) sys->render = src.Format; IDirect3DSurface9_GetDevice(p_sys->surface, &dx_sys->d3ddev ); } err = directx_va_Open(va, &sys->dx_sys, true); if (err!=VLC_SUCCESS) goto error; err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt); if (err != VLC_SUCCESS) goto error; ctx->hwaccel_context = &sys->hw; /* TODO print the hardware name/vendor for debugging purposes */ va->description = DxDescribe(sys); va->get = Get; return VLC_SUCCESS; error: Close(va, NULL); return VLC_EGENERIC; }