From patchwork Tue Aug 24 05:31:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29750 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2724632iov; Mon, 23 Aug 2021 22:33:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyQ0DxD5mOD30l/XuzTC8Hoiu4NCcWVucd9zqGBAYpvUfJnVeWOWg8mlFjoLlQVx3sQ9io X-Received: by 2002:a05:6402:2684:: with SMTP id w4mr41646970edd.69.1629783233084; Mon, 23 Aug 2021 22:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629783233; cv=none; d=google.com; s=arc-20160816; b=sOTjyDXrzRMw3iB5UKgNb47TyO1mr4nMVpbIGN3sOIkBLYr6uVdNyfuzlsgwqrjf1l 5hSuax2JTbGEARYNLRkYA0o0IVz3GSihp0EiKjM73jW5+QsIRiNLoN1WUStto7Ol7hCG fkYcNxWm2tjIo4lLFpdc0M68s4utkLEXRI/Fcn1qjbv+XYLukIXSkaPLxqIop3k3KoYh hsFBxQMzIqtJhX9VrnFVLIiPquBjfWe3GpnpGjqjkQIMVTY8LfTheBRMEdyhMICEELJ2 6Y/XGHJkpCx6e0f809W0CO7vw7MkY2ufBYc/hyq3GioWTlYoqxRcohg8Ia6AuuTn1A5x bakw== 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=rJFVm3sunTRk4oJpQijCBsuy/6QyV4Ru8eO9IWiHyi0=; b=oM9Z69BVCZ8jcxyW65axyg1ZTNrWzJjVoKOVq160r7nJNYCL7GQu5Y2ZhHm3zi4GDU AWl2wBiCyjhuJiHfgtAU1OoS/7HaNm+9rkPX7HUci8u8YYbaIRM6QGMjtHNKydLWFy5L U4kgvmWWDXB9WL9Tu7AgimBynu9lGxYnztepORYA3xj9a704W7nz8oSmZwHwoRb5zBQD iOmG1jT1lc4KlMwjWIJATfkuM7gLLnNb8lwkbvAlFdrFVBCBD/kJqdFFq15gybE1qHHp DLH0xmTSg//oGSQiJoGczzwJh4Gus/ScgfzPwWo+WzBnWjEwux6n8qVbPL/X5M+VVNHu kbUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ucLcO4jZ; 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 hr29si19414985ejc.256.2021.08.23.22.33.52; Mon, 23 Aug 2021 22:33:53 -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=ucLcO4jZ; 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 DD52E68A2F6; Tue, 24 Aug 2021 08:32:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE95F68A0B6 for ; Tue, 24 Aug 2021 08:32:46 +0300 (EEST) Received: by mail-pj1-f52.google.com with SMTP id 28-20020a17090a031cb0290178dcd8a4d1so1320387pje.0 for ; Mon, 23 Aug 2021 22:32:46 -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=pMo2jvem+nmmtNm6BdIjY6ppcu0qgnG/gB4kLphCeko=; b=ucLcO4jZdGSepfKX93KfVIJI+qfl3GL4zbwjAXm5S+e4CPeu/OFb54fShzyZwIV7TD E2sg0touN3j1L1JqUCaORtxEpaiS1Ka/w94Pjvuazjj/0IBjgUDvzFpH2Dx1jaArTrAj pV91Afjgp4AFPxLkz/8dUJZtq1Pqez2pZQHM1V4AmaTsybPSGoTiTHbwaOxGm7sZwDVK D1xxaV95JRObrftM7prawaW0U8TuQFREN/KNGdjELxGgpRbaapjiOqjQAqQ/wgQ8nvBC I3HqBt+OliSd3cayvtYUzJgGBfTvqS+afruxxMbFEbr/zTomzP+4cJINsohAEQESqgIS zLlw== 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=pMo2jvem+nmmtNm6BdIjY6ppcu0qgnG/gB4kLphCeko=; b=cYIlk+YjuyPLR7hBykunpdWye0OJHUN87nEHsw4X9KMYfkT7HkvWdhJETuDuHSOz+h UHAzl6uFSe9Nm5YOoaYlNTAEKpgnNBgP5JwDY/BDYOa4khcvqb+vjqDucB0eOf26UmzY yt7yqM6S3sJ+alETIxM1DE7CVsfFmEUWOT9+Ev/CEZ/ljRxWTUCqCAes2mT2GN6Y1hpC wF8xsM2LGbCNCy+gzcZowX79FQJwik6NSZjC0OtO+3CCsPAUxJeliR0ujRpb/urx9mRG qyR80bI7QfSVlqByg0VtsyCjrXfaVeezmbFD1XaG2J5ERQfF1XqwQg7jvnJlpzra2OTs iHWQ== X-Gm-Message-State: AOAM533zoJv9u4rzR92GSUjtl0B/o1+Gh8jxEaHB0n5c1j8K8gRpJ27I H02rxWSinQpWRKb7mOPhLYr+CqxadXoalQ== X-Received: by 2002:a17:90a:7a8b:: with SMTP id q11mr2456497pjf.189.1629783165039; Mon, 23 Aug 2021 22:32:45 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.221.236]) by smtp.googlemail.com with ESMTPSA id z12sm7095207pfe.79.2021.08.23.22.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 22:32:44 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Aug 2021 11:01:51 +0530 Message-Id: <20210824053151.14305-7-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824053151.14305-1-shubhanshu.e01@gmail.com> References: <20210824053151.14305-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 7/7] libavfilter: Send only input frame for DNN Detect and Classify 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: Z2fMOWY5IhQf This commit updates the following two filters to send only the input frame and send NULL as output frame instead of input frame to the DNN backends. 1. vf_dnn_detect 2. vf_dnn_classify Signed-off-by: Shubhanshu Saxena --- libavfilter/dnn/dnn_backend_common.c | 2 +- libavfilter/dnn/dnn_backend_openvino.c | 5 +++-- libavfilter/vf_dnn_classify.c | 14 ++++++-------- libavfilter/vf_dnn_detect.c | 14 ++++++-------- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c index d2bc016fef..6a9c4cc87f 100644 --- a/libavfilter/dnn/dnn_backend_common.c +++ b/libavfilter/dnn/dnn_backend_common.c @@ -38,7 +38,7 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func return AVERROR(EINVAL); } - if (!exec_params->out_frame) { + if (!exec_params->out_frame && func_type == DFT_PROCESS_FRAME) { av_log(ctx, AV_LOG_ERROR, "out frame is NULL when execute model.\n"); return AVERROR(EINVAL); } diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 76dc06c6d7..f5b1454d21 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -272,14 +272,14 @@ static void infer_completion_callback(void *args) av_log(ctx, AV_LOG_ERROR, "detect filter needs to provide post proc\n"); return; } - ov_model->model->detect_post_proc(task->out_frame, &output, 1, ov_model->model->filter_ctx); + ov_model->model->detect_post_proc(task->in_frame, &output, 1, ov_model->model->filter_ctx); break; case DFT_ANALYTICS_CLASSIFY: if (!ov_model->model->classify_post_proc) { av_log(ctx, AV_LOG_ERROR, "classify filter needs to provide post proc\n"); return; } - ov_model->model->classify_post_proc(task->out_frame, &output, request->lltasks[i]->bbox_index, ov_model->model->filter_ctx); + ov_model->model->classify_post_proc(task->in_frame, &output, request->lltasks[i]->bbox_index, ov_model->model->filter_ctx); break; default: av_assert0(!"should not reach here"); @@ -819,6 +819,7 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams * if (model->func_type == DFT_ANALYTICS_CLASSIFY) { // Classification filter has not been completely // tested with the sync mode. So, do not support now. + avpriv_report_missing_feature(ctx, "classify for sync execution"); return DNN_ERROR; } diff --git a/libavfilter/vf_dnn_classify.c b/libavfilter/vf_dnn_classify.c index d5ee65d403..d1ba8dffbc 100644 --- a/libavfilter/vf_dnn_classify.c +++ b/libavfilter/vf_dnn_classify.c @@ -225,13 +225,12 @@ static int dnn_classify_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t AVFrame *in_frame = NULL; AVFrame *out_frame = NULL; async_state = ff_dnn_get_result(&ctx->dnnctx, &in_frame, &out_frame); - if (out_frame) { - av_assert0(in_frame == out_frame); - ret = ff_filter_frame(outlink, out_frame); + if (async_state == DAST_SUCCESS) { + ret = ff_filter_frame(outlink, in_frame); if (ret < 0) return ret; if (out_pts) - *out_pts = out_frame->pts + pts; + *out_pts = in_frame->pts + pts; } av_usleep(5000); } while (async_state >= DAST_NOT_READY); @@ -258,7 +257,7 @@ static int dnn_classify_activate(AVFilterContext *filter_ctx) if (ret < 0) return ret; if (ret > 0) { - if (ff_dnn_execute_model_classification(&ctx->dnnctx, in, in, ctx->target) != DNN_SUCCESS) { + if (ff_dnn_execute_model_classification(&ctx->dnnctx, in, NULL, ctx->target) != DNN_SUCCESS) { return AVERROR(EIO); } } @@ -269,9 +268,8 @@ static int dnn_classify_activate(AVFilterContext *filter_ctx) AVFrame *in_frame = NULL; AVFrame *out_frame = NULL; async_state = ff_dnn_get_result(&ctx->dnnctx, &in_frame, &out_frame); - if (out_frame) { - av_assert0(in_frame == out_frame); - ret = ff_filter_frame(outlink, out_frame); + if (async_state == DAST_SUCCESS) { + ret = ff_filter_frame(outlink, in_frame); if (ret < 0) return ret; got_frame = 1; diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index 809d70b930..637874b2a1 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -368,13 +368,12 @@ static int dnn_detect_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *o AVFrame *in_frame = NULL; AVFrame *out_frame = NULL; async_state = ff_dnn_get_result(&ctx->dnnctx, &in_frame, &out_frame); - if (out_frame) { - av_assert0(in_frame == out_frame); - ret = ff_filter_frame(outlink, out_frame); + if (async_state == DAST_SUCCESS) { + ret = ff_filter_frame(outlink, in_frame); if (ret < 0) return ret; if (out_pts) - *out_pts = out_frame->pts + pts; + *out_pts = in_frame->pts + pts; } av_usleep(5000); } while (async_state >= DAST_NOT_READY); @@ -401,7 +400,7 @@ static int dnn_detect_activate(AVFilterContext *filter_ctx) if (ret < 0) return ret; if (ret > 0) { - if (ff_dnn_execute_model(&ctx->dnnctx, in, in) != DNN_SUCCESS) { + if (ff_dnn_execute_model(&ctx->dnnctx, in, NULL) != DNN_SUCCESS) { return AVERROR(EIO); } } @@ -412,9 +411,8 @@ static int dnn_detect_activate(AVFilterContext *filter_ctx) AVFrame *in_frame = NULL; AVFrame *out_frame = NULL; async_state = ff_dnn_get_result(&ctx->dnnctx, &in_frame, &out_frame); - if (out_frame) { - av_assert0(in_frame == out_frame); - ret = ff_filter_frame(outlink, out_frame); + if (async_state == DAST_SUCCESS) { + ret = ff_filter_frame(outlink, in_frame); if (ret < 0) return ret; got_frame = 1;