From patchwork Sat Jun 5 18:08:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 28101 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2139965iof; Sat, 5 Jun 2021 11:09:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylE797AOrTIIXtL2U9k2LbeeZQDArJ/dtmqXP1cmeOi1tjRizgj9SIs5yLt8VyFRSOwsm7 X-Received: by 2002:a17:907:9721:: with SMTP id jg33mr507525ejc.64.1622916551681; Sat, 05 Jun 2021 11:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622916551; cv=none; d=google.com; s=arc-20160816; b=f55RATGd8yFokhjBRHlNOIxVMVy2adfuLgya+Gzys/1M4d1PPUZ4h/mths/IC/VioK 3jPuBeALA670HdBqR/jOBxgx6zOiMebMOLvjsPz2ZP3TsgXlWiaJIAA4ceaPFIFgJocL JXj6Q3U5oUaFmEZhWEhfDnP57M28CHyU4L8a6Ki842j3TJvCwdt1Gasw8SwFradKlKIn B/Kh5VXrBzkkeLvG5bk+TGe3X8SC0+5CT/Tc+yHmYzjgy74MBUcLYgW6Po6aH8aG2REA dDz825rrohRrl0AD/0voAklZmKte1/7qRnVmLPqMsJLhynQet3s/2UDaU9sWoC5rtmKK RW0w== 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=enkXEmoLATIGnVyFqWx1KfSuHunLl0HGnAhTwRKtEhI=; b=d4bIPCx/22WlX3KSspvestJZSEuMsrLrZTMDcot1SxLu3xQlzbLXWtHlufYIqMKAoK vW3QQrYluqMrSFPv6PuR89qKdmZE/rt2TzM51FjHlUOIqrQQKptsjZzMLdKREsKBAfIt E7vTOj8T3bXUvOkGuu2uu8WFiVvbxTsn4Y5XOhxaRtwdC5pI19spBCimgTtYoX4tv0r5 ndM11Mvn09hw3TlAJR1WgQWBXEbdp5ojibBx0j2z3whsiZW1+VYcbK7tk7zLije6uC8u giq1fCO7iGqbewYSfZs6BhPiO0VJStk6az2D36v8sE9jKmQPJCtJGBA5nu/+T1eDm9uz jkwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="WcLiAx//"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t12si9427156edc.333.2021.06.05.11.09.11; Sat, 05 Jun 2021 11:09:11 -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=@gmail.com header.s=20161025 header.b="WcLiAx//"; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3027068A601; Sat, 5 Jun 2021 21:08:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C8FC68A5EC for ; Sat, 5 Jun 2021 21:08:50 +0300 (EEST) Received: by mail-pf1-f170.google.com with SMTP id h12so7040846pfe.2 for ; Sat, 05 Jun 2021 11:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NiWqJtj+P+9dijQdiV2TF8bwccUw6X6PrwK9rCOzSHQ=; b=WcLiAx//o/VmWtaCn9ocwbazTgg+T/YcfVfSX+RA46LMPFXIAYJcrt/0Ul7jrQ5NnU /lcMucHfgY1C4iPaAY8bZDvlUcaf14rRZ69fKVnA3T8myRs00eRerI0oGmCskXh4i3eS O7mszDQHAppLLja0rmIhxZyuULMznVE+D5abwHX8ttSPpVD+2XGRNxpu81dSq5+QGGj7 VZrb7ehL2Ybnj3GVSF2KkXE4zWFQrjSXnD8HoGju96VChzlP7kiKuFlISaxx5iJRR2O8 SRvAVZ35gtREHhVxGu0MCnu0fU1/wnvij5JpwIRwJ3GRS+xi6/mlfmm9lS3R+JQevAMr 74iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NiWqJtj+P+9dijQdiV2TF8bwccUw6X6PrwK9rCOzSHQ=; b=sKky8xJQCN6jB+hDLycyVEf8ghyXrHTkdTCjZrpz6Sr9Nm9LjQY+Tm6wKE7ZZGKlmN ebJ+Lj5LEjVt4mWlj8tSvRLAdF0xjZ/yE0c90vr+9Wr/xVAQ8P1OXYpnPIib97HOlKw/ m4cMqpLnksCu+iNplzH6ynUlaV+YdOsxZG/+tB4RzvWxBStRLq3GJRrVbOI3EOA3BtVV Hwkv0hwAgyZh7T1lx/F5IN00L38gQINRZTQ2htIy4kS+C/dJzW3k3ueg3X6Nh6vHLPYJ PVLE9GvPK8YUQthxoC6ABsvCdYdx29QIg0dvuGTihP/SdA/rAfY7jjOcDKBbUiIVNVAI vNxA== X-Gm-Message-State: AOAM533nShQW9z9VrnvutacqPMRQrspffHs0mRpXmapDlzXjmUnqDfmm p44d0+pTPHtQm4K1p+bng0vkpSfEZPveDg== X-Received: by 2002:a62:87c9:0:b029:2ea:572c:e4b1 with SMTP id i192-20020a6287c90000b02902ea572ce4b1mr10320923pfe.34.1622916528390; Sat, 05 Jun 2021 11:08:48 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.221.215]) by smtp.googlemail.com with ESMTPSA id w14sm7818176pjf.12.2021.06.05.11.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 11:08:48 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Jun 2021 23:38:06 +0530 Message-Id: <20210605180806.65831-5-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210605180806.65831-1-shubhanshu.e01@gmail.com> References: <20210605180806.65831-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2 5/5] lavfi/dnn: Fill Task using Common Function 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: Shubhanshu Saxena Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sy5UcST6usRy This commit adds a common function for filling the TaskItems in all three backends. Signed-off-by: Shubhanshu Saxena --- libavfilter/dnn/dnn_backend_common.c | 20 ++++++++++++++++++++ libavfilter/dnn/dnn_backend_common.h | 15 +++++++++++++++ libavfilter/dnn/dnn_backend_openvino.c | 23 +++++++---------------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c index a522ab5650..4d9d3f79b1 100644 --- a/libavfilter/dnn/dnn_backend_common.c +++ b/libavfilter/dnn/dnn_backend_common.c @@ -49,3 +49,23 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func return 0; } + +DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc) { + if (task == NULL || exec_params == NULL || backend_model == NULL) + return DNN_ERROR; + if (do_ioproc != 0 && do_ioproc != 1) + return DNN_ERROR; + if (async != 0 && async != 1) + return DNN_ERROR; + + task->do_ioproc = do_ioproc; + task->async = async; + task->input_name = exec_params->input_name; + task->in_frame = exec_params->in_frame; + task->out_frame = exec_params->out_frame; + task->model = backend_model; + task->nb_output = exec_params->nb_output; + task->output_names = exec_params->output_names; + + return DNN_SUCCESS; +} diff --git a/libavfilter/dnn/dnn_backend_common.h b/libavfilter/dnn/dnn_backend_common.h index d962312c16..df59615f40 100644 --- a/libavfilter/dnn/dnn_backend_common.h +++ b/libavfilter/dnn/dnn_backend_common.h @@ -48,4 +48,19 @@ typedef struct InferenceItem { int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func_type, DNNExecBaseParams *exec_params); +/** + * Fill the Task for Backend Execution. It should be called after + * checking execution parameters using ff_check_exec_params. + * + * @param task pointer to the allocated task + * @param exec_param pointer to execution parameters + * @param backend_model void pointer to the backend model + * @param async flag for async execution. Must be 0 or 1 + * @param do_ioproc flag for IO processing. Must be 0 or 1 + * + * @retval DNN_SUCCESS if successful + * @retval DNN_ERROR if flags are invalid or any parameter is NULL + */ +DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc); + #endif diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index c2487c35be..709a772a4d 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -793,14 +793,9 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams * } } - task.do_ioproc = 1; - task.async = 0; - task.input_name = exec_params->input_name; - task.in_frame = exec_params->in_frame; - task.output_names = &exec_params->output_names[0]; - task.out_frame = exec_params->out_frame ? exec_params->out_frame : exec_params->in_frame; - task.nb_output = exec_params->nb_output; - task.model = ov_model; + if (ff_dnn_fill_task(&task, exec_params, ov_model, 0, 1) != DNN_SUCCESS) { + return DNN_ERROR; + } if (extract_inference_from_task(ov_model->model->func_type, &task, ov_model->inference_queue, exec_params) != DNN_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "unable to extract inference from task.\n"); @@ -841,14 +836,10 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, DNNExecBasePa return DNN_ERROR; } - task->do_ioproc = 1; - task->async = 1; - task->input_name = exec_params->input_name; - task->in_frame = exec_params->in_frame; - task->output_names = &exec_params->output_names[0]; - task->out_frame = exec_params->out_frame ? exec_params->out_frame : exec_params->in_frame; - task->nb_output = exec_params->nb_output; - task->model = ov_model; + if (ff_dnn_fill_task(task, exec_params, ov_model, 1, 1) != DNN_SUCCESS) { + return DNN_ERROR; + } + if (ff_queue_push_back(ov_model->task_queue, task) < 0) { av_freep(&task); av_log(ctx, AV_LOG_ERROR, "unable to push back task_queue.\n");