-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use dynamic pool for VPL QSV hwupload
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
- Loading branch information
1 parent
a856e91
commit 83852c8
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
debian/patches/0080-use-dynamic-pool-for-vpl-qsv-hwupload.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Index: FFmpeg/libavfilter/vf_hwupload.c | ||
=================================================================== | ||
--- FFmpeg.orig/libavfilter/vf_hwupload.c | ||
+++ FFmpeg/libavfilter/vf_hwupload.c | ||
@@ -32,6 +32,10 @@ | ||
#include "internal.h" | ||
#include "video.h" | ||
|
||
+#if CONFIG_LIBMFX | ||
+extern int ff_qsv_check_dynamic_pool_supported(AVHWDeviceContext *device_ctx); | ||
+#endif | ||
+ | ||
typedef struct HWUploadContext { | ||
const AVClass *class; | ||
|
||
@@ -163,6 +167,15 @@ static int hwupload_config_output(AVFilt | ||
ctx->hwframes->user_opaque = &texDesc; | ||
#endif | ||
|
||
+#if CONFIG_LIBMFX | ||
+ if (ctx->hwframes->format == AV_PIX_FMT_QSV) { | ||
+ AVHWDeviceContext *qsv_ctx = (AVHWDeviceContext *)ctx->hwdevice_ref->data; | ||
+ if (!ff_qsv_check_dynamic_pool_supported(qsv_ctx)) { | ||
+ ctx->hwframes->initial_pool_size = 0; | ||
+ } | ||
+ } | ||
+#endif | ||
+ | ||
err = av_hwframe_ctx_init(ctx->hwframes_ref); | ||
if (err < 0) | ||
goto fail; | ||
Index: FFmpeg/libavutil/hwcontext_qsv.c | ||
=================================================================== | ||
--- FFmpeg.orig/libavutil/hwcontext_qsv.c | ||
+++ FFmpeg/libavutil/hwcontext_qsv.c | ||
@@ -173,6 +173,8 @@ extern int ff_qsv_get_surface_base_handl | ||
enum AVHWDeviceType base_dev_type, | ||
void **base_handle); | ||
|
||
+extern int ff_qsv_check_dynamic_pool_supported(AVHWDeviceContext *device_ctx); | ||
+ | ||
static int qsv_init_surface(AVHWFramesContext *ctx, mfxFrameSurface1 *surf); | ||
|
||
/** | ||
@@ -205,6 +207,34 @@ int ff_qsv_get_surface_base_handle(mfxFr | ||
return AVERROR(EINVAL); | ||
} | ||
|
||
+int ff_qsv_check_dynamic_pool_supported(AVHWDeviceContext *device_ctx) | ||
+{ | ||
+ AVQSVDeviceContext *device_hwctx; | ||
+ mfxIMPL impl; | ||
+ mfxVersion ver; | ||
+ int ret; | ||
+ | ||
+ if (!device_ctx || device_ctx->type != AV_HWDEVICE_TYPE_QSV) | ||
+ return AVERROR(EINVAL); | ||
+ | ||
+ device_hwctx = device_ctx->hwctx; | ||
+ | ||
+ ret = MFXQueryIMPL(device_hwctx->session, &impl); | ||
+ if (ret == MFX_ERR_NONE) | ||
+ ret = MFXQueryVersion(device_hwctx->session, &ver); | ||
+ if (ret != MFX_ERR_NONE) | ||
+ return AVERROR_UNKNOWN; | ||
+ | ||
+ if (!QSV_RUNTIME_VERSION_ATLEAST(ver, 2, 9)) | ||
+ return AVERROR(ENOSYS); | ||
+ | ||
+ if (!(MFX_IMPL_VIA_VAAPI == MFX_IMPL_VIA_MASK(impl) || | ||
+ MFX_IMPL_VIA_D3D11 == MFX_IMPL_VIA_MASK(impl))) | ||
+ return AVERROR(ENOSYS); | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt) | ||
{ | ||
int i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters