bool VideoDecoderDXVAPrivate::open() { if (va_pixfmt != QTAV_PIX_FMT_C(NONE)) codec_ctx->pix_fmt = va_pixfmt; if (!D3dCreateDevice()) { qWarning("Failed to create Direct3D device"); goto error; } qDebug("D3dCreateDevice succeed"); if (!D3dCreateDeviceManager()) { qWarning("D3dCreateDeviceManager failed"); goto error; } if (!DxCreateVideoService()) { qWarning("DxCreateVideoService failed"); goto error; } if (!DxFindVideoServiceConversion(&input, &render)) { qWarning("DxFindVideoServiceConversion failed"); goto error; } /* TODO print the hardware name/vendor for debugging purposes */ return true; error: close(); return false; }
vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id) { vlc_va_dxva2_t *va = calloc(1, sizeof(*va)); if (!va) return NULL; /* */ va->log = log; va->codec_id = codec_id; /* Load dll*/ va->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL")); if (!va->hd3d9_dll) { msg_Warn(va->log, "cannot load d3d9.dll"); goto error; } va->hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL")); if (!va->hdxva2_dll) { msg_Warn(va->log, "cannot load dxva2.dll"); goto error; } msg_Dbg(va->log, "DLLs loaded"); /* */ if (D3dCreateDevice(va)) { msg_Err(va->log, "Failed to create Direct3D device"); goto error; } msg_Dbg(va->log, "D3dCreateDevice succeed"); if (D3dCreateDeviceManager(va)) { msg_Err(va->log, "D3dCreateDeviceManager failed"); goto error; } if (DxCreateVideoService(va)) { msg_Err(va->log, "DxCreateVideoService failed"); goto error; } /* */ if (DxFindVideoServiceConversion(va, &va->input, &va->render)) { msg_Err(va->log, "DxFindVideoServiceConversion failed"); goto error; } /* TODO print the hardware name/vendor for debugging purposes */ va->va.description = DxDescribe(va); va->va.setup = Setup; va->va.get = Get; va->va.release = Release; va->va.extract = Extract; va->va.close = Close; return &va->va; error: Close(&va->va); return NULL; }
bool VideoDecoderDXVAPrivate::open() { if (!prepare()) return false; if (codec_ctx->codec_id == QTAV_CODEC_ID(HEVC)) { // runtime hevc check if (isHEVCSupported()) { qWarning("HEVC DXVA2 is supported by current FFmpeg runtime."); } else { qWarning("HEVC DXVA2 is not supported by current FFmpeg runtime."); return false; } } if (!D3dCreateDevice()) { qWarning("Failed to create Direct3D device"); goto error; } qDebug("D3dCreateDevice succeed"); if (!D3dCreateDeviceManager()) { qWarning("D3dCreateDeviceManager failed"); goto error; } if (!DxCreateVideoService()) { qWarning("DxCreateVideoService failed"); goto error; } if (!DxFindVideoServiceConversion(&input, &render)) { qWarning("DxFindVideoServiceConversion failed"); goto error; } IDirect3DDevice9Ex *devEx; d3ddev->QueryInterface(IID_IDirect3DDevice9Ex, (void**)&devEx); qDebug("using D3D9Ex: %d", !!devEx); // runtime check gles for dynamic gl #if QTAV_HAVE(DXVA_EGL) if (OpenGLHelper::isOpenGLES()) { // d3d9ex is required to share d3d resource. It's available in vista and later. d3d9 can not CreateTexture with shared handle if (devEx) interop_res = dxva::InteropResourcePtr(new dxva::EGLInteropResource(d3ddev)); else qDebug("D3D9Ex is not available. Disable 0-copy."); } #endif SafeRelease(&devEx); #if QTAV_HAVE(DXVA_GL) if (!OpenGLHelper::isOpenGLES()) interop_res = dxva::InteropResourcePtr(new dxva::GLInteropResource(d3ddev)); #endif return true; error: close(); return false; }
bool VideoDecoderDXVAPrivate::open() { if (codec_ctx->codec_id == QTAV_CODEC_ID(HEVC)) { // runtime hevc check if (isHEVCSupported()) { qWarning("HEVC DXVA2 is supported by current FFmpeg runtime."); } else { qWarning("HEVC DXVA2 is not supported by current FFmpeg runtime."); return false; } } if (!D3dCreateDevice()) { qWarning("Failed to create Direct3D device"); goto error; } qDebug("D3dCreateDevice succeed"); if (!D3dCreateDeviceManager()) { qWarning("D3dCreateDeviceManager failed"); goto error; } if (!DxCreateVideoService()) { qWarning("DxCreateVideoService failed"); goto error; } if (!DxFindVideoServiceConversion(&input, &render)) { qWarning("DxFindVideoServiceConversion failed"); goto error; } IDirect3DDevice9Ex *devEx; d3ddev->QueryInterface(IID_IDirect3DDevice9Ex, (void**)&devEx); qDebug("using D3D9Ex: %d", !!devEx); SafeRelease(&devEx); /* TODO print the hardware name/vendor for debugging purposes */ return true; error: close(); return false; }
static int Open(vlc_va_t *external, int codec_id, const es_format_t *fmt) { vlc_va_dxva2_t *va = calloc(1, sizeof(*va)); if (!va) return VLC_EGENERIC; external->sys = va; /* */ va->log = VLC_OBJECT(external); va->codec_id = codec_id; (void) fmt; /* Load dll*/ va->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL")); if (!va->hd3d9_dll) { msg_Warn(va->log, "cannot load d3d9.dll"); goto error; } va->hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL")); if (!va->hdxva2_dll) { msg_Warn(va->log, "cannot load dxva2.dll"); goto error; } msg_Dbg(va->log, "DLLs loaded"); /* */ if (D3dCreateDevice(va)) { msg_Err(va->log, "Failed to create Direct3D device"); goto error; } msg_Dbg(va->log, "D3dCreateDevice succeed"); if (D3dCreateDeviceManager(va)) { msg_Err(va->log, "D3dCreateDeviceManager failed"); goto error; } if (DxCreateVideoService(va)) { msg_Err(va->log, "DxCreateVideoService failed"); goto error; } /* */ if (DxFindVideoServiceConversion(va, &va->input, &va->render)) { msg_Err(va->log, "DxFindVideoServiceConversion failed"); goto error; } /* TODO print the hardware name/vendor for debugging purposes */ external->description = DxDescribe(va); external->pix_fmt = PIX_FMT_DXVA2_VLD; external->setup = Setup; external->get = Get; external->release = Release; external->extract = Extract; return VLC_SUCCESS; error: Close(external); return VLC_EGENERIC; }
static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt) { vlc_va_sys_t *sys = calloc(1, sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; va->sys = sys; sys->codec_id = ctx->codec_id; (void) fmt; /* Load dll*/ sys->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL")); if (!sys->hd3d9_dll) { msg_Warn(va, "cannot load d3d9.dll"); goto error; } sys->hdxva2_dll = LoadLibrary(TEXT("DXVA2.DLL")); if (!sys->hdxva2_dll) { msg_Warn(va, "cannot load dxva2.dll"); goto error; } msg_Dbg(va, "DLLs loaded"); /* */ if (D3dCreateDevice(va)) { msg_Err(va, "Failed to create Direct3D device"); goto error; } msg_Dbg(va, "D3dCreateDevice succeed"); if (D3dCreateDeviceManager(va)) { msg_Err(va, "D3dCreateDeviceManager failed"); goto error; } if (DxCreateVideoService(va)) { msg_Err(va, "DxCreateVideoService failed"); goto error; } /* */ if (DxFindVideoServiceConversion(va, &sys->input, &sys->render)) { msg_Err(va, "DxFindVideoServiceConversion failed"); goto error; } sys->thread_count = ctx->thread_count; /* TODO print the hardware name/vendor for debugging purposes */ va->description = DxDescribe(sys); va->pix_fmt = PIX_FMT_DXVA2_VLD; va->setup = Setup; va->get = Get; va->release = Release; va->extract = Extract; return VLC_SUCCESS; error: Close(va); return VLC_EGENERIC; }