From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 51729406A0 for ; Tue, 25 Apr 2023 07:30:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7848B68BEF5; Tue, 25 Apr 2023 10:30:14 +0300 (EEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D58268B9FC for ; Tue, 25 Apr 2023 10:30:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682407812; x=1713943812; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CeS1ec12Z0+g3baTXuNnAQrHLQiSVFoTpN0hGl193qg=; b=TIvAq8Hc+Xt3vb4x/PBiR+zKOuI6i/sHLzStkdUQfEDH5BJwXQA8d4Rn pmGd4KyBl5+WxrkUJhkDuiAoUttOProPnI+E8Rjvq+eY3/eO+ty5Olc6m IxmT2Om3UJV0alk8cu7Z9RO2J8Vtryw5NsiQz/Ix324RF6NTdgumPMAnB MwL9QDVfOBZFL8fdq26t43rPZECj43zxxWvyA30pcSuxmJtJ+7uXWBJnT CBGmilQ9c1lJRE/3ELBYo0aZGXiHud8R4fH6nMkIy09cUGjKmGls/MDJN 1yyaymbZDN2CubFhaHn00Yx7VMSLuq7Xd9C4LS1PfI4bF2g1pGU9bLebO A==; X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="374630975" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="374630975" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 00:29:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="867798312" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="867798312" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.59]) by orsmga005.jf.intel.com with ESMTP; 25 Apr 2023 00:29:57 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Apr 2023 15:26:17 +0800 Message-Id: <20230425072620.512-2-tong1.wu@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230425072620.512-1-tong1.wu@intel.com> References: <20230425072620.512-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 2/5] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Tong Wu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: When both derive_device_type and device context are not presented during hw->hw map, the hwmap filter should be able to retrieve AVHWDeviceType from outlink->format and create corresponding hwdevice context. Signed-off-by: Tong Wu --- libavfilter/vf_hwmap.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index e246b22603..e5b40233b2 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -70,16 +70,31 @@ static int hwmap_config_output(AVFilterLink *outlink) device_is_derived = 0; if (inlink->hw_frames_ctx) { + enum AVHWDeviceType type; hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data; - if (ctx->derive_device_type) { - enum AVHWDeviceType type; + desc = av_pix_fmt_desc_get(outlink->format); + if (!desc) { + err = AVERROR(EINVAL); + goto fail; + } - type = av_hwdevice_find_type_by_name(ctx->derive_device_type); - if (type == AV_HWDEVICE_TYPE_NONE) { - av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n"); - err = AVERROR(EINVAL); - goto fail; + if (ctx->derive_device_type || (!device && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL))) { + if (ctx->derive_device_type) { + type = av_hwdevice_find_type_by_name(ctx->derive_device_type); + if (type == AV_HWDEVICE_TYPE_NONE) { + av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n"); + err = AVERROR(EINVAL); + goto fail; + } + } else { + type = av_hwdevice_get_type_by_pix_fmt(outlink->format); + if (type == AV_HWDEVICE_TYPE_NONE) { + av_log(avctx, AV_LOG_ERROR, "Could not get device type from " + "format %s.\n", av_get_pix_fmt_name(outlink->format)); + err = AVERROR(EINVAL); + goto fail; + } } err = av_hwdevice_ctx_create_derived(&device, type, @@ -92,12 +107,6 @@ static int hwmap_config_output(AVFilterLink *outlink) device_is_derived = 1; } - desc = av_pix_fmt_desc_get(outlink->format); - if (!desc) { - err = AVERROR(EINVAL); - goto fail; - } - if (inlink->format == hwfc->format && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) && !ctx->reverse) { -- 2.39.1.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".