From patchwork Wed Aug 25 10:39:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29771 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp434847iov; Wed, 25 Aug 2021 03:40:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNOp+T7nnj+o0kVne1oW9b8xlGsQEpmhBEWEdQUagaRhtyJ1zcanmCdAl+huf9vuaxoVr7 X-Received: by 2002:a17:906:8cd:: with SMTP id o13mr46084591eje.341.1629888048025; Wed, 25 Aug 2021 03:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629888048; cv=none; d=google.com; s=arc-20160816; b=ovqRQ56SMwd2MR6+bQG5+bHMnc4Kz2WjkxOH55AWSxwYa3a/51MvuuexNQ9mt6bBmJ nxwnWaUfPVbXmvtG3VHUO0MFV4fWCQNDa85JDB9cwIxoHQPnuDbgnvMZfZsaeBea6FyN 77nxJaWTmWGFYpvHUH8hlzS1M/aj/8NmxURnxoXY3s8qaghTzlA46P1hVOKVA7utSQFi OHGUe2LA+DvmNnpynTAk9/Ki5qwSmeasKzfLIY8w6f6QFUWX0Z25NXBpsuCiNFgzB1cK znTBXoorkPGstBPa+fSa7fbAV5mY56J+oqhpuo3s1sy/QFJmordzithYOySci9wk5Wb7 V53Q== 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=tgeb9EeUFRLp7ILdglfym8VhzXOPzTcP3IskwCvOEoQ=; b=azSNjEaUQICc78cwJZrCRGgDukvU3ytTWHVFXJeqhgXUQxX4onujluaOUrrFRiYSgS RiGhZfp/7dVbWV2dlDe4QSV+whWlGN7U/3LO+HObIx00mtnnP5fVGlCpxQG103p+lyf2 N+G1V2F1hj3qS7E9bq8R40iEFhxNUvbm/Yeyi2nkkfWoM55WtgvCrHceLWcTXnsjtDp7 Z28N5CvOD9+xWjsyK+krXP+BvPxrlSbvJdYuvzFIlY6vGnJKP1tQ5UyvxWl6UeBkIudk QoMcki2sGYIMCV4dSYvUcYM3IvaqOFAwrz404GgYBa5GefvGciEHhOVcOe0tEzdckNC/ 1hzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=mVXCD0fD; 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 qw31si5518380ejc.633.2021.08.25.03.40.47; Wed, 25 Aug 2021 03:40:47 -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=mVXCD0fD; 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 D903468A2F4; Wed, 25 Aug 2021 13:40:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9704168A273 for ; Wed, 25 Aug 2021 13:40:17 +0300 (EEST) Received: by mail-pg1-f178.google.com with SMTP id e7so22642846pgk.2 for ; Wed, 25 Aug 2021 03:40:17 -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=kerxkJIFTEUo1lakrAXtZvZ6zlf+he6RHyzlWv+8W5I=; b=mVXCD0fDCCeaSiXoo/KgBPQeizhImOaPmw/miByzyD/MG29e83U5JEB2yt60nOhc5E li6P6fudKD04kDKDxZ8KyMeX+/pCqBzpQJf+FbPCXj76H2rtP4M/VY3V27JXPp++m72N CwM2Qiy4w2vSX9mP9i/BQbrt5OtQIFjf79BlR8fetyneIIXxGnz/aIQ/BaTNFeuSa6Qe oPUKd4HVzFPLTE1nw64SE+/iJEc6ozYopzZviCB5h+dxddcIN2h9BLnM50/WtzofY7fQ jfIXNNg28e0T10uE5ZHk+Pv0KlSx2R2DeDG0hjiGzilinBKqRrsZlqQe5zt2ur27ev4y d9JA== 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=kerxkJIFTEUo1lakrAXtZvZ6zlf+he6RHyzlWv+8W5I=; b=HmMnfUvdwRetKJB0N/Vsk48xO2HXZChZ8Sk5TKf/0f+FhqOydkSkIkzB/VPZ5gK9Ew myFpNunzhI3xaP1+JiFpNZX3tLnUVig7NztyVYbA049qvqcTEcv+6M+JulPMSWbgg29s j+BSYJV/VYDXNkO/4AhyP2mMDs9iX6gUr063H1DjL9eBzje/ekrtcD3jQRsNKWIyn9iC UIElvBX8isiEHHh5xNTK9AbU/SB4Wo/XvyAPlZqlUoRCwT9xjnZClT6YyCoNehOe/bMT eoyoq6BnNLRjA4InrFLI70SKAY7qsUptQHgdKy/71Er3/s06So9R1qO4VQVjUqq547JP ZxWg== X-Gm-Message-State: AOAM532ytnpdVr7FgqaIN7Eo0zi0lXiY3QlTqZfcZyPfSkGZnHteeZKP +K9t+3sTOyc2hYVQ+yJQAlk0Ijw9hmHG7g== X-Received: by 2002:aa7:83c6:0:b029:3e0:1f64:6f75 with SMTP id j6-20020aa783c60000b02903e01f646f75mr43597172pfn.69.1629888015638; Wed, 25 Aug 2021 03:40:15 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.221.29]) by smtp.googlemail.com with ESMTPSA id w16sm4548735pff.130.2021.08.25.03.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 03:40:15 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Aug 2021 16:09:36 +0530 Message-Id: <20210825103940.28798-3-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210825103940.28798-1-shubhanshu.e01@gmail.com> References: <20210825103940.28798-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 3/7] libavfilter: Remove synchronous functions from DNN filters 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: Rezi7onYTT22 This commit removes the unused sync mode specific code from the DNN filters since the sync and async mode are now unified from the filters' perspective. Signed-off-by: Shubhanshu Saxena --- libavfilter/vf_dnn_detect.c | 71 +--------------------------- libavfilter/vf_dnn_processing.c | 84 +-------------------------------- 2 files changed, 4 insertions(+), 151 deletions(-) diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index 11de376753..809d70b930 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -353,63 +353,6 @@ static int dnn_detect_query_formats(AVFilterContext *context) return ff_set_common_formats_from_list(context, pix_fmts); } -static int dnn_detect_filter_frame(AVFilterLink *inlink, AVFrame *in) -{ - AVFilterContext *context = inlink->dst; - AVFilterLink *outlink = context->outputs[0]; - DnnDetectContext *ctx = context->priv; - DNNReturnType dnn_result; - - dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, in); - if (dnn_result != DNN_SUCCESS){ - av_log(ctx, AV_LOG_ERROR, "failed to execute model\n"); - av_frame_free(&in); - return AVERROR(EIO); - } - - return ff_filter_frame(outlink, in); -} - -static int dnn_detect_activate_sync(AVFilterContext *filter_ctx) -{ - AVFilterLink *inlink = filter_ctx->inputs[0]; - AVFilterLink *outlink = filter_ctx->outputs[0]; - AVFrame *in = NULL; - int64_t pts; - int ret, status; - int got_frame = 0; - - FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); - - do { - // drain all input frames - ret = ff_inlink_consume_frame(inlink, &in); - if (ret < 0) - return ret; - if (ret > 0) { - ret = dnn_detect_filter_frame(inlink, in); - if (ret < 0) - return ret; - got_frame = 1; - } - } while (ret > 0); - - // if frame got, schedule to next filter - if (got_frame) - return 0; - - if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { - if (status == AVERROR_EOF) { - ff_outlink_set_status(outlink, status, pts); - return ret; - } - } - - FF_FILTER_FORWARD_WANTED(outlink, inlink); - - return FFERROR_NOT_READY; -} - static int dnn_detect_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) { DnnDetectContext *ctx = outlink->src->priv; @@ -439,7 +382,7 @@ static int dnn_detect_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *o return 0; } -static int dnn_detect_activate_async(AVFilterContext *filter_ctx) +static int dnn_detect_activate(AVFilterContext *filter_ctx) { AVFilterLink *inlink = filter_ctx->inputs[0]; AVFilterLink *outlink = filter_ctx->outputs[0]; @@ -496,16 +439,6 @@ static int dnn_detect_activate_async(AVFilterContext *filter_ctx) return 0; } -static av_unused int dnn_detect_activate(AVFilterContext *filter_ctx) -{ - DnnDetectContext *ctx = filter_ctx->priv; - - if (ctx->dnnctx.async) - return dnn_detect_activate_async(filter_ctx); - else - return dnn_detect_activate_sync(filter_ctx); -} - static av_cold void dnn_detect_uninit(AVFilterContext *context) { DnnDetectContext *ctx = context->priv; @@ -537,5 +470,5 @@ const AVFilter ff_vf_dnn_detect = { FILTER_INPUTS(dnn_detect_inputs), FILTER_OUTPUTS(dnn_detect_outputs), .priv_class = &dnn_detect_class, - .activate = dnn_detect_activate_async, + .activate = dnn_detect_activate, }; diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c index 7435dd4959..55634efde5 100644 --- a/libavfilter/vf_dnn_processing.c +++ b/libavfilter/vf_dnn_processing.c @@ -244,76 +244,6 @@ static int copy_uv_planes(DnnProcessingContext *ctx, AVFrame *out, const AVFrame return 0; } -static int filter_frame(AVFilterLink *inlink, AVFrame *in) -{ - AVFilterContext *context = inlink->dst; - AVFilterLink *outlink = context->outputs[0]; - DnnProcessingContext *ctx = context->priv; - DNNReturnType dnn_result; - AVFrame *out; - - out = ff_get_video_buffer(outlink, outlink->w, outlink->h); - if (!out) { - av_frame_free(&in); - return AVERROR(ENOMEM); - } - av_frame_copy_props(out, in); - - dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, out); - if (dnn_result != DNN_SUCCESS){ - av_log(ctx, AV_LOG_ERROR, "failed to execute model\n"); - av_frame_free(&in); - av_frame_free(&out); - return AVERROR(EIO); - } - - if (isPlanarYUV(in->format)) - copy_uv_planes(ctx, out, in); - - av_frame_free(&in); - return ff_filter_frame(outlink, out); -} - -static int activate_sync(AVFilterContext *filter_ctx) -{ - AVFilterLink *inlink = filter_ctx->inputs[0]; - AVFilterLink *outlink = filter_ctx->outputs[0]; - AVFrame *in = NULL; - int64_t pts; - int ret, status; - int got_frame = 0; - - FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); - - do { - // drain all input frames - ret = ff_inlink_consume_frame(inlink, &in); - if (ret < 0) - return ret; - if (ret > 0) { - ret = filter_frame(inlink, in); - if (ret < 0) - return ret; - got_frame = 1; - } - } while (ret > 0); - - // if frame got, schedule to next filter - if (got_frame) - return 0; - - if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { - if (status == AVERROR_EOF) { - ff_outlink_set_status(outlink, status, pts); - return ret; - } - } - - FF_FILTER_FORWARD_WANTED(outlink, inlink); - - return FFERROR_NOT_READY; -} - static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) { DnnProcessingContext *ctx = outlink->src->priv; @@ -345,7 +275,7 @@ static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) return 0; } -static int activate_async(AVFilterContext *filter_ctx) +static int activate(AVFilterContext *filter_ctx) { AVFilterLink *inlink = filter_ctx->inputs[0]; AVFilterLink *outlink = filter_ctx->outputs[0]; @@ -410,16 +340,6 @@ static int activate_async(AVFilterContext *filter_ctx) return 0; } -static av_unused int activate(AVFilterContext *filter_ctx) -{ - DnnProcessingContext *ctx = filter_ctx->priv; - - if (ctx->dnnctx.async) - return activate_async(filter_ctx); - else - return activate_sync(filter_ctx); -} - static av_cold void uninit(AVFilterContext *ctx) { DnnProcessingContext *context = ctx->priv; @@ -454,5 +374,5 @@ const AVFilter ff_vf_dnn_processing = { FILTER_INPUTS(dnn_processing_inputs), FILTER_OUTPUTS(dnn_processing_outputs), .priv_class = &dnn_processing_class, - .activate = activate_async, + .activate = activate, };