From patchwork Mon Feb 22 08:45:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Guangxin" X-Patchwork-Id: 25887 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EE60844A4FB for ; Mon, 22 Feb 2021 10:45:54 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADC3C687F5A; Mon, 22 Feb 2021 10:45:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B4B0687FD4 for ; Mon, 22 Feb 2021 10:45:46 +0200 (EET) IronPort-SDR: +JVKhvRWJcCatyrKlbfiWPGoSMPPturlwAYUhoe/cKTQsdKbL9cMX9Dl4GrnmeRuDzJ5lNLddr h7dPp/d/WTMA== X-IronPort-AV: E=McAfee;i="6000,8403,9902"; a="248435044" X-IronPort-AV: E=Sophos;i="5.81,196,1610438400"; d="scan'208";a="248435044" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 00:45:44 -0800 IronPort-SDR: HvY48RS/oB+EEDsC9n1/M8FsJ11C2OGiqT4gIakK59NqEkzF8TKoIHBpVF8I01LmfZSguQVh0j k024MiMnaeoA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,196,1610438400"; d="scan'208";a="389737107" Received: from trinity.sh.intel.com ([10.239.159.85]) by fmsmga008.fm.intel.com with ESMTP; 22 Feb 2021 00:45:43 -0800 From: Xu Guangxin To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Feb 2021 16:45:04 +0800 Message-Id: <20210222084504.339978-1-guangxin.xu@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avutils/hwcontext_qsv: set the source device in qsv_device_create X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Xu Guangxin Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" opencl_device_derive only handles AV_HWDEVICE_TYPE_VAAPI. We need a source device for qsv. this will fix following pipeline: ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -init_hw_device opencl=ocl@intel -hwaccel qsv -c:v h264_qsv -hwaccel_output_format qsv -i $input -filter_hw_device ocl -vf 'hwmap=derive_device=opencl,format=opencl,unsharp_opencl,hwmap=derive_device=qsv:reverse=1:extra_hw_frames=32' -c:v hevc_qsv -y test.h265 --- libavutil/hwcontext_qsv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 35a944f8f8..af3ee32cac 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1269,7 +1269,13 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, impl = choose_implementation(device); - return qsv_device_derive_from_child(ctx, impl, child_device, 0); + ret = qsv_device_derive_from_child(ctx, impl, child_device, 0); + if (ret == 0) { + ctx->internal->source_device = av_buffer_ref(priv->child_device_ctx); + if (!ctx->internal->source_device) + ret = AVERROR(ENOMEM); + } + return ret; } const HWContextType ff_hwcontext_type_qsv = {