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 47A7243800 for ; Wed, 29 Jun 2022 07:00:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1884E68B6EB; Wed, 29 Jun 2022 10:00:50 +0300 (EEST) Received: from out203-205-251-27.mail.qq.com (out203-205-251-27.mail.qq.com [203.205.251.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8FABD68069F for ; Wed, 29 Jun 2022 10:00:42 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1656486038; bh=MMJqC7OJSt2t2UTnJ99zbD9O4uHTmRNR+Tfi9GuQEPo=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=CIDHydkI1qa6waB1+J5nSQ3UeyxiRNgkNv+Ola+g0xQY93upRXmWnUkzbF7PPYK+v m+9vSr+PdjYm5ghxpAItAonMd8FBtg2RY2VsqgIcHl5fAzo8YQwHFYw1nc75oOXqUu c5I7Xx99XTmlu+b+w+T0aJ7ozluTQuAUyrPV2YUk= Received: from [192.168.255.10] ([59.37.125.122]) by newxmesmtplogicsvrsza8.qq.com (NewEsmtp) with SMTP id 252C445; Wed, 29 Jun 2022 15:00:37 +0800 X-QQ-mid: xmsmtpt1656486037tzh622nkz Message-ID: X-QQ-XMAILINFO: Mee1Vp/QiDAWDG1Dm+8hFWQA7jZcs6rmr6D4fgnhfDS2uM70Yc9G5qpkbTdFvK En0NPqX674v2uNMKtSREN+qnnQGdu2vjmHws0XTzwQTiTCpfFrLtYw12iUZ12ZIKRdR7VmuNyRPS Qcc9b7J4GC3QDF5Ls4QTTr4Tap8D3usHjVOQsoTroQwb5sRWpkEcHFZDSXJs57mNQbhVe4FHaPdm P7SfWYclwh4R7UFHcsq7uhhZO1Koq4teS23pn+5ZSSgOZ0kLC0Yw4WPn9eTJ+bQYW/TNy7L57FoV sgWHpBjq1RZKCksN3OiXS3U98ZYgcjZWzCniDUKu9GxkgotF9bHkMwADHsBUaLd5Gyad88/duP2D WBqVijznGh3eYVEnREMuZvWOu7AFrtF6DaEZxolibxlsONPJ82yvWJYk9zrxm9pk6z9cPXXBSNVc apX3HgUaqkyZ1Ln7E11RKkD6PwJhXKk3tSREeXtGgZRVmQgXDhg/l1VTLznJOxRKSWFlqiYaSxEW mYltEsIgW2l5WrnegKZ92xthi7GbaOwUfuQt3T0p5oHs+8imqH7I47CwiU28VOihJVRdmUNhwy2m 8quaVLRfL4SLXeV0npUeXudMiRijwnnp3+fTlRsoLJRqF+7yKG20nKw3hY152whQsZ4QBKAgvcJm mwR0ZAWopAXdJ+lPprwvjrf+kImCeNQQEXJzdGKgp9k+U7Lx287FweqTlc5tD5VKJZkoxjC8ZToY fdEg2iRYcekEJqdM+kJQYjOpMlpw0ZUq1kpZOIBiyAqPuTET7Zx+qaNK8S/zq3hl24/D7L3S92Vv XF1KlSswbFzAr1ImPHaZh6lFXchFf9wD43EAIjs1ThInP6SIdhhze/SAXS89hYAILYYBPrXs1q67 ttHSnJj8YAZ+kdSCgNxhswR5jtKfNGoNj0L9zmrq7NVyZXZLs6jGOdFCwtE3nRNTCzBuGl8jPu Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) From: =?utf-8?B?InpoaWxpemhhbyjotbXlv5fnq4spIg==?= In-Reply-To: <20220629063246.183-2-tong1.wu@intel.com> Date: Wed, 29 Jun 2022 15:00:36 +0800 X-OQ-MSGID: <7CE86067-7A88-4625-AFDF-EF6A9003DA4A@foxmail.com> References: <20220629063246.183-1-tong1.wu@intel.com> <20220629063246.183-2-tong1.wu@intel.com> To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3654.60.0.2.21) Subject: Re: [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 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: > On Jun 29, 2022, at 2:32 PM, Tong Wu wrote: > > 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; mixed declarations and code. > > + 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); I think a new device should be created only if if (device == NULL || ctx->derive_device_type != NULL) Now a new device is created unconditionally. > + 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); > -- > 2.35.1.windows.2 > > _______________________________________________ > 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". _______________________________________________ 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".