From patchwork Tue Aug 24 05:31:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29754 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2724220iov; Mon, 23 Aug 2021 22:33:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwXx7cGHE0fFSANqwM7GHxbJ911ar0eR0ptBFY5YROmbgCTnrQFBc0TvXxVJenLcvsupVR X-Received: by 2002:a17:907:7718:: with SMTP id kw24mr40542447ejc.316.1629783188640; Mon, 23 Aug 2021 22:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629783188; cv=none; d=google.com; s=arc-20160816; b=xFsZvPQAosI4mBdIaaETRbr6Wq+YDGcV/zHVfm91ROIyU43UXo3Dge29Esog2WAwK1 DtMkeBLY8xmnyBLkJvGVzcm9vfv/ztqa9q5QWmL9yCqcW83ai0yKyA9Osw/mnOGmNBAG 9K2UhKj8X5nzjR0Jx+xwKiQILIceA3LWnYIBTC7N19nEz9TyiGI+WnqqLwY1KHXVvsXa Jew8SGK83WdVZHg+EqhqPfpVrvsvWmtrHgAiQddc6Jiigi/YiXSHbJVNJIL4hqau0CsU lRIR5mWNHZvxRcEbAkkhHFZIcu56Nyf5GyX5JyglAdHPixtamb+mqoDCe7b8LjiQTEMu LZEQ== 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=oxXE9L8HS8z6HJT7Rwxn2G2OdSKK2HoF3rbqP700wT6StB44c93jWAkh3m7nNLrEPk 1uDHi0NQ81cIVMHSob5lAWZWW0DpBBnoy80ECkplEuglmOq2LG9+s/diefdQ0xqnGuIu czxWlvu7Qo7xeRL38UhYwmg4r9TIzoy7UC4vKPu67nyAUPDAQfab7MMKbP0hezPWRS3S QIlbkpwRQgcp2+MZVoGAEjUdUEdCMDouoLyRuYLXlis0ljAUqtrqwfPx1TBqnr4G8xzP 1Gl2hNiQ5cP3SDf9UrSmye2AnhCtmpRRsRkrqFfMo8KEKIvwyExz6QSgACIa/AbM3fnN DrdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=EOpGH3+H; 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 hr29si19412885ejc.256.2021.08.23.22.33.08; Mon, 23 Aug 2021 22:33:08 -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=EOpGH3+H; 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 55430689FB5; Tue, 24 Aug 2021 08:32:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0564680074 for ; Tue, 24 Aug 2021 08:32:39 +0300 (EEST) Received: by mail-pg1-f172.google.com with SMTP id q68so1651075pga.9 for ; Mon, 23 Aug 2021 22:32:39 -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=EOpGH3+HmDL3K6//H3fmrhziSL1zUbzvDQTmmMS+iTs8jkDEybCFwXznVrmoHcHWZe lhem96eCpScJvPgqF9DqI6rG1lrWWTKNOVKcsTFxVongGlUVYhM234v1X0gQRv0+TEua UEic8HSWwF8foajCh22Ofye5VQvqDYkpfGdt0/sykjMZZ81cQdMxvYVWLqu9jw67jHXv xRH6m7i4f5SYa6fVp2R5Jl436C0Rws1erhgxwrsagPR2TcMUNgkVO8YgjJ3kqrPYSklV JqWOyjXIzW/3WzRlFbC7UEJ455JDvqsf9wU3np7p9GY+9A1be+kN2Vb7H7byHKEvJI5J rh4A== 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=Yjtut908oriB1iaVApESRhkCoAS3zADm3JD3Z+DvJghoSSs+2Ypsp4Pw/8RTHvBcl5 GUVqTZWLIL2Bewp/pnW6UhXj6AKT+76/xvAb8dUlPJ0vkcUDIqpbAl9c6BjR3pUh+cnf OTTE76JCCGEglu/+xX+CyNJKHILRwLGO3MfNDcRjylAGSI31PQz4oFcLj5t+UkZDiKeP KjB+9IUvlPk5GaFTqXnq0w5nMc46CnLIfGj4g3XEOAZqCrHMAea3KPQVkGvc1nTkdJZq zpGntyazWJyPjhR50RZhxSUoJQhBU4Bqo4htOkqw5tnHZeIChmxbvGPqSIQi6EQjGDo/ 5Rag== X-Gm-Message-State: AOAM532zPiZpnvIjbKljeT6GNcLz3bM8PqwRvXtCY81Z5zf0BR1MSomV 95xOD3vhcIv/MOCJkj5tI9Fpv68NAQT2SQ== X-Received: by 2002:a05:6a00:158a:b0:3eb:432e:9acd with SMTP id u10-20020a056a00158a00b003eb432e9acdmr5190575pfk.0.1629783157973; Mon, 23 Aug 2021 22:32:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 22:32:37 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Aug 2021 11:01:47 +0530 Message-Id: <20210824053151.14305-3-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 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: KoRbLuk1KGFU 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, };