From patchwork Tue Sep 24 10:18:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15248 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9B8C444A8DB for ; Tue, 24 Sep 2019 13:18:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 79DD3688391; Tue, 24 Sep 2019 13:18:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 12BEA68836F for ; Tue, 24 Sep 2019 13:18:20 +0300 (EEST) Received: by mail-pl1-f173.google.com with SMTP id w10so798444plq.5 for ; Tue, 24 Sep 2019 03:18:19 -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; bh=gbEuJw2qCqR78Q9Ao4lEuuTdDhI9f9wL7f2BNEQmPp0=; b=WgoJ0eWdBSX9B0B9ZiKb1PlYkUIdunsIvWhbc/Owdb6iHEoR8awtbHtZEhHnq5NR1O EiGEZ1vfxy7ZvpEj8grXs3ogzpdMKOTtJJhRAPxfTX+OmBtmxvhGDiDOA6Uc1QqOksa5 WedFUOBHFh8VREEVGsJGpvRuQdLRRFNkagGzCy71FVzJysml/qmXCF0PAchEM5mJe3hk liwAnEEZ4dlHgv5Eth2MSenI8uWPnaAZ5u85T+PIv0ckYhwY0JcOvJdj8FtH62C2Whip CBIxy7nX5vkSVJ0yxrP1SKuOA/gcbuCRf4oa0BmDX/4R+8Ihm5GN3KCEpfulKSwcF+R5 mvzw== 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; bh=gbEuJw2qCqR78Q9Ao4lEuuTdDhI9f9wL7f2BNEQmPp0=; b=IO4xtoH7x6CV7YKG5pv9UiGerpBIbARHbb4hQAVNnOYK/GrpMca0gDhQIzqsJ4lSRs x4IhM+4S2FUdWzUcLyFmz1NBhyYX7o+4yr97Q6mVP2I6+LKapekiPv0SoHRIX3B/szlc WNuArK64BZRX+kU2GY0dzLORgxhCT+FovIDapm08steofPk8HsITPAQZiAHFF94cLTzk vFciSXPFISwsDzY8zl3kYZdB0tKGYXD06g6Q7EocKdoA7xH3Gn9n7uTsRf1Y0fYwXL0u 0JShI+ValcfH8mhawJf0C8S19E+aUDF5AMcOgmLOROA8O+PrUhoafz04wI1c60l7v6N+ Korw== X-Gm-Message-State: APjAAAVyl1dQKcHMTLuNAUwnwJgl6je46jGV7toQcanW+KNvWh+YGHxj /f80Hxb6Qj9W2FkEjybPl7rSkfRz X-Google-Smtp-Source: APXvYqzCmyAMyOtZpkGKWB9BX13UoDjbr3HR9/d3wNFTkgzzCBnJwhUsQ1TnV415JNGC/O3LEDHcxg== X-Received: by 2002:a17:902:6b84:: with SMTP id p4mr2412623plk.168.1569320298167; Tue, 24 Sep 2019 03:18:18 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id r1sm1469324pgv.70.2019.09.24.03.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Sep 2019 03:18:17 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Sep 2019 18:18:08 +0800 Message-Id: <20190924101809.13656-2-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190924101809.13656-1-lance.lmwang@gmail.com> References: <20190921144932.32241-1-lance.lmwang@gmail.com> <20190924101809.13656-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_framerate: refine the filter_slice code for better readiablity X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/framerate.h | 1 + libavfilter/vf_framerate.c | 35 +++++++++++++---------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/libavfilter/framerate.h b/libavfilter/framerate.h index 8048dfa36a..3d8200b2fe 100644 --- a/libavfilter/framerate.h +++ b/libavfilter/framerate.h @@ -43,6 +43,7 @@ typedef struct FrameRateContext { int interp_end; ///< end of range to apply linear interpolation int line_size[4]; ///< bytes of pixel data per line for each plane + int height[4]; ///< bytes of pixel data per height for each plane int vsub; AVRational srce_time_base; ///< timebase of source diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index a5dad3c769..f16400e8ff 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -95,29 +95,20 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) { FrameRateContext *s = ctx->priv; ThreadData *td = arg; + AVFrame *work = s->work, *src1 = td->copy_src1, *src2 = td->copy_src2; uint16_t src1_factor = td->src1_factor; uint16_t src2_factor = td->src2_factor; int plane; - for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) { - int cpy_line_width = s->line_size[plane]; - uint8_t *cpy_src1_data = td->copy_src1->data[plane]; - int cpy_src1_line_size = td->copy_src1->linesize[plane]; - uint8_t *cpy_src2_data = td->copy_src2->data[plane]; - int cpy_src2_line_size = td->copy_src2->linesize[plane]; - int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height); - uint8_t *cpy_dst_data = s->work->data[plane]; - int cpy_dst_line_size = s->work->linesize[plane]; - const int start = (cpy_src_h * job ) / nb_jobs; - const int end = (cpy_src_h * (job+1)) / nb_jobs; - cpy_src1_data += start * cpy_src1_line_size; - cpy_src2_data += start * cpy_src2_line_size; - cpy_dst_data += start * cpy_dst_line_size; - - s->blend(cpy_src1_data, cpy_src1_line_size, - cpy_src2_data, cpy_src2_line_size, - cpy_dst_data, cpy_dst_line_size, - cpy_line_width, end - start, + for (plane = 0; plane < 4 && src1->data[plane] && src2->data[plane]; plane++) { + const int start = (s->height[plane] * job ) / nb_jobs; + const int end = (s->height[plane] * (job+1)) / nb_jobs; + uint8_t *src1_data = src1->data[plane] + start * src1->linesize[plane]; + uint8_t *src2_data = src2->data[plane] + start * src2->linesize[plane]; + uint8_t *dst_data = work->data[plane] + start * work->linesize[plane]; + + s->blend(src1_data, src1->linesize[plane], src2_data, src2->linesize[plane], + dst_data, work->linesize[plane], s->line_size[plane], end - start, src1_factor, src2_factor, s->blend_factor_max >> 1); } @@ -293,13 +284,13 @@ static int config_input(AVFilterLink *inlink) const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); int plane; + s->vsub = pix_desc->log2_chroma_h; for (plane = 0; plane < 4; plane++) { - s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w, - plane); + s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w, plane); + s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? s->vsub : 0); } s->bitdepth = pix_desc->comp[0].depth; - s->vsub = pix_desc->log2_chroma_h; s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16); if (!s->sad)