From patchwork Wed Jun 29 06:32:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 36519 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp121360pzh; Tue, 28 Jun 2022 23:34:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vjAw3L/KLtdosIjNOqnO2aIBLbI3qui3Nb3nEiQiyuYftoMYr4dicw10jSWS6S3WBDvtsM X-Received: by 2002:aa7:c881:0:b0:435:5dc4:5832 with SMTP id p1-20020aa7c881000000b004355dc45832mr2188160eds.265.1656484480405; Tue, 28 Jun 2022 23:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656484480; cv=none; d=google.com; s=arc-20160816; b=P/XyX0jc9xaII3uFPdZ4kaABNA07N25h3fRU2oQBY20K8Bl+4q+UZkZQLsl+l09LYd wPiJ7KHlAu9iJO/hPQSn1kHV3qYbdUfa6Lpu4/JL1TjgIq/ptDhJyA/6j3aWXu7fcQVk ZDL9Bg1x8mZFA1XlWT551KYxUVPdS+IyEplFdLKkmZmjXohcmLfuK1106ucSmunyR98D iWWwyLTe0fmRqZPpiytnW9eB9HG+0gaVil29crX3/Yp/M2pATPOrBYaO2khEKDbQfgj+ LRa+WqtpjfnJbeTT8lklxSwjMXzkLEeQ9WQGAG0N57bJlnGLni2Jva5LWFoUi5CABSIJ NN4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=DBwlNNUy7qdpmeVczfv7Qw+GlXMrmfVq/Ad2xfV3DH0=; b=FOsBoJfMK3te+2upgkiENqda0+PaFQB4rWSxHqH4MFR5Rv5kgAJTpYCoPt8xtPYC9Q gijZ2lrcQ1gqhFuoRIbJGKz5GphpNdnocClc/7ujm7IE4Siwou1l1Gib8gGhDDmki84/ mHfnyTlOFw4Pm1/Z3TAqCzCByi1TYoPLfr8UD4CW4qyB0Nxd5rM7ThLdPlFJdU3HCN6y 4DZb4azaF9MtETZRAUn7TwNorPKqW3gQ1uWJttW/mU9dp7I2tjl14YkT1O7R8AgSW+W1 n6PcUltJvzuarZg6DkbJCT6lrO6QNA9bOVc67/pX5kDGo83skCkTgw83zeNqWqVw+JYZ cuYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=MpbrsVm9; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gs13-20020a1709072d0d00b007269f9395d7si10546401ejc.482.2022.06.28.23.34.18; Tue, 28 Jun 2022 23:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=MpbrsVm9; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EDFD568B6CC; Wed, 29 Jun 2022 09:34:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E4C6968B672 for ; Wed, 29 Jun 2022 09:33:56 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656484442; x=1688020442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qeLfM2YUagz1A9dZF78vzkCMGvV4cYvTw126HNsX/Ps=; b=MpbrsVm9ba9zxCR/Y+pH+Yu3Mmfn8WBIOdnrB3JRnEC0MHRBNY95zakw ZLISWkKwTA1o5dpsFMNzwfRWfquTE0otzKc3na5WyeJlqXdYvBoS9psuy p8ojJImSeYvGcbsf1ymPpV+jypp8uGcPon7waHbAAWzCxccRfPKVXAicT jmbGAMKryvL0Q8d4sl7DCNY+bXlV3kye1s+5qTdg9C8a7BmHAfdI02gzf hy2H9P9EXtgWhbb0PNpY2T+hUBQ2N9aoU5mXsEJy6+kqmt7sGCc2+WCBG S9fNb62J3ANxB29jUPRoVBUP1bbbFDlgLXFzOp6JrUw+Ft9nIyZLudrB/ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="281973013" X-IronPort-AV: E=Sophos;i="5.92,230,1650956400"; d="scan'208";a="281973013" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 23:33:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,230,1650956400"; d="scan'208";a="595108605" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.39]) by fmsmga007.fm.intel.com with ESMTP; 28 Jun 2022 23:33:53 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Wed, 29 Jun 2022 14:32:45 +0800 Message-Id: <20220629063246.183-2-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220629063246.183-1-tong1.wu@intel.com> References: <20220629063246.183-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zn4dbTzbzH1K When a derive_device_type is not specified, 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 | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index 2e03dfc1fe..a0c2e134cf 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -72,26 +72,34 @@ static int hwmap_config_output(AVFilterLink *outlink) if (inlink->hw_frames_ctx) { hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data; - if (ctx->derive_device_type) { - enum AVHWDeviceType type; + enum AVHWDeviceType type; + 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; } - - err = av_hwdevice_ctx_create_derived(&device, type, - hwfc->device_ref, 0); - if (err < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to created derived " - "device context: %d.\n", err); + } 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; } - device_is_derived = 1; } + err = av_hwdevice_ctx_create_derived(&device, type, + hwfc->device_ref, 0); + if (err < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to created derived " + "device context: %d.\n", err); + goto fail; + } + device_is_derived = 1; + desc = av_pix_fmt_desc_get(outlink->format); if (!desc) { err = AVERROR(EINVAL);