Adding DX11 relevant device type checks and adjusting callback with proper MediaSDK pair type support.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -70,6 +70,7 @@ enum var_name { · 69 unmodified lines | |||
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | #define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19) | 72 | #define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19) |
| 73 | #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) | ||
| 73 | 74 | ||
| 74 | typedef struct QSVScaleContext { | 75 | typedef struct QSVScaleContext { |
| 75 | const AVClass *class; | 76 | const AVClass *class; |
| @@ -259,16 +260,16 @@ static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr) · 183 unmodified lines | |||
| 259 | 260 | ||
| 260 | static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) | 261 | static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) |
| 261 | { | 262 | { |
| 262 | *hdl = mid; | 263 | mfxHDLPair *pair_dst = (mfxHDLPair*)hdl; |
| 264 | mfxHDLPair *pair_src = (mfxHDLPair*)mid; | ||
| 265 | |||
| 266 | pair_dst->first = pair_src->first; | ||
| 267 | |||
| 268 | if (pair_src->second != (mfxMemId)MFX_INFINITE) | ||
| 269 | pair_dst->second = pair_src->second; | ||
| 263 | return MFX_ERR_NONE; | 270 | return MFX_ERR_NONE; |
| 264 | } | 271 | } |
| 265 | 272 | ||
| 266 | static const mfxHandleType handle_types[] = { | ||
| 267 | MFX_HANDLE_VA_DISPLAY, | ||
| 268 | MFX_HANDLE_D3D9_DEVICE_MANAGER, | ||
| 269 | MFX_HANDLE_D3D11_DEVICE, | ||
| 270 | }; | ||
| 271 | |||
| 272 | static int init_out_session(AVFilterContext *ctx) | 273 | static int init_out_session(AVFilterContext *ctx) |
| 273 | { | 274 | { |
| 274 | 275 | ||
| @@ -300,14 +301,18 @@ static int init_out_session(AVFilterContext *ctx) · 25 unmodified lines | |||
| 300 | return AVERROR_UNKNOWN; | 301 | return AVERROR_UNKNOWN; |
| 301 | } | 302 | } |
| 302 | 303 | ||
| 303 | for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) { | 304 | if (MFX_IMPL_VIA_VAAPI == MFX_IMPL_VIA_MASK(impl)) { |
| 304 | err = MFXVideoCORE_GetHandle(device_hwctx->session, handle_types[i], &handle); | 305 | handle_type = MFX_HANDLE_VA_DISPLAY; |
| 305 | if (err == MFX_ERR_NONE) { | 306 | } else if (MFX_IMPL_VIA_D3D11 == MFX_IMPL_VIA_MASK(impl)) { |
| 306 | handle_type = handle_types[i]; | 307 | handle_type = MFX_HANDLE_D3D11_DEVICE; |
| 307 | break; | 308 | } else if (MFX_IMPL_VIA_D3D9 == MFX_IMPL_VIA_MASK(impl)) { |
| 308 | } | 309 | handle_type = MFX_HANDLE_D3D9_DEVICE_MANAGER; |
| 310 | } else { | ||
| 311 | av_log(ctx, AV_LOG_ERROR, "Error unsupported handle type\n"); | ||
| 312 | return AVERROR_UNKNOWN; | ||
| 309 | } | 313 | } |
| 310 | 314 | ||
| 315 | err = MFXVideoCORE_GetHandle(device_hwctx->session, handle_type, &handle); | ||
| 311 | if (err < 0) | 316 | if (err < 0) |
| 312 | return ff_qsvvpp_print_error(ctx, err, "Error getting the session handle"); | 317 | return ff_qsvvpp_print_error(ctx, err, "Error getting the session handle"); |
| 313 | else if (err > 0) { | 318 | else if (err > 0) { |