From patchwork Thu Jun 28 08:52:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shlomi Fish X-Patchwork-Id: 9550 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp1823929jad; Thu, 28 Jun 2018 01:52:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpckXfbop6DGHTtycM1aZgXGd2E3JIDO4vP6Gshtr9qIRLEfCaHtideinNGH1Bom3sLTznER X-Received: by 2002:a1c:34c9:: with SMTP id b192-v6mr7691065wma.21.1530175944512; Thu, 28 Jun 2018 01:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530175944; cv=none; d=google.com; s=arc-20160816; b=b0ADZlFbEuH6m/Ru95SsKwlKdHd62LTwQB9OSsa3CF0tuhuv7pQAzkZdZ+CSEq2Lto 53t62B21rVwJt3tqLN3HZLGlrzyWsTs3LULff3H6BHalbW8EsnhzSYxF5uu8L5OH/U44 XdAsmUQTBY07/xdpnTm9vRlETBU9TUgJq8c5YwujOw2YwcSyOpq/wZM2GAfOFTWFaoMf rBrrS039uLtzgMb3KlfcP82NnaawQCphc39Y5/L34hqaKABc2d3KWQEZ4SWxKokWuW9t takInP51KZVi+H3A9GmsWGE/6+65QWejfteTL6MOcFim9o/vRf5VrD8p+G9jlt8Gr6Sm nc+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:to:from:date:delivered-to :arc-authentication-results; bh=RdE3Bo4Qh8dlu1fA6VaU8Mg7vWPc95tMPLqQ0r16THc=; b=Gm851qSpXGksbnzJN29p5+9ok68EVGKVZI33tt7v4C/vCKRsscGhCOFlwjHIfLXTvG oN/isrLr9MfGqFOA5NPo5sw4M7UdHBuQdE+EQ9mD8ZnTzklc/tJswNEKOb/QjUsAXv/a 6YNJqvkiiQb7hZnq+KvjK2xijeAdjVy0BJfguAGud+OjZt/luVD9acQ6ZurqVCD0/vko TZCldWjJ0Q+D6rDllg/dIRm7Cdfkb0Ui+IbplMbaMK2/eCCDSDmNKVljfXEyL4KdKnjR th1623Qkt7z4pP5QfsGyNpGH6/fR3VorwC+BjzxdKUe6AaO1FB8hevbFUBGDYwGG1Pt/ WIyA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p10-v6si5685620wma.32.2018.06.28.01.52.24; Thu, 28 Jun 2018 01:52:24 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F1B7168A55C; Thu, 28 Jun 2018 11:52:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.46.224]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F217168A3A3 for ; Thu, 28 Jun 2018 11:52:13 +0300 (EEST) Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 353AF5F1F for ; Thu, 28 Jun 2018 03:52:14 -0500 (CDT) Received: from gator4065.hostgator.com ([192.185.4.76]) by cmsmtp with SMTP id YSf0f1Y2279N3YSf0fRdts; Thu, 28 Jun 2018 03:52:14 -0500 X-Authority-Reason: nr=8 Received: from [77.124.107.214] (port=60284 helo=telaviv1.shlomifish.org) by gator4065.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fYSez-004JFR-H7 for ffmpeg-devel@ffmpeg.org; Thu, 28 Jun 2018 03:52:13 -0500 Received: from telaviv1.shlomifish.org (telaviv1.shlomifish.org [127.0.0.1]) by telaviv1.shlomifish.org (Postfix) with ESMTP id D5FE12600A9 for ; Thu, 28 Jun 2018 11:52:10 +0300 (IDT) Date: Thu, 28 Jun 2018 11:52:10 +0300 From: Shlomi Fish To: FFmpeg development discussions and patches Message-ID: <20180628115210.20bd9d26@telaviv1.shlomifish.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-mageia-linux-gnu) MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4065.hostgator.com X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - shlomifish.org X-BWhitelist: no X-Source-IP: 77.124.107.214 X-Source-L: No X-Exim-ID: 1fYSez-004JFR-H7 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (telaviv1.shlomifish.org) [77.124.107.214]:60284 X-Source-Auth: shlomif@shlomifish.org X-Email-Count: 3 X-Source-Cap: c2hsb21pZjtzaGxvbWlmO2dhdG9yNDA2NS5ob3N0Z2F0b3IuY29t X-Local-Domain: yes Subject: [FFmpeg-devel] [PATCH] Refactor two near-identical clauses - take 2 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi all! Attached is the 2nd take of the patch for vf_weave.c. Please review. From c94e6cc8272e2bdb1d23014814dde02eafd739a6 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 28 Jun 2018 11:42:45 +0300 Subject: [PATCH] Refactor two near-identical clauses. The changes contained in this patch are hereby placed under the Expat licence. Share and enjoy! All tests pass. This is a revised version of the first patch, after incorporating some input. --- libavfilter/vf_weave.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c index 037f5d1cf2..663d79f511 100644 --- a/libavfilter/vf_weave.c +++ b/libavfilter/vf_weave.c @@ -84,6 +84,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; int i; + int weave; + int field1, field2; if (!s->prev) { s->prev = in; @@ -98,26 +100,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); + weave = (s->double_weave && !(inlink->frame_count_out & 1)); + field1 = weave ? s->first_field : (!s->first_field); + field2 = weave ? (!s->first_field) : s->first_field; for (i = 0; i < s->nb_planes; i++) { - if (s->double_weave && !(inlink->frame_count_out & 1)) { - av_image_copy_plane(out->data[i] + out->linesize[i] * s->first_field, - out->linesize[i] * 2, - in->data[i], in->linesize[i], - s->linesize[i], s->planeheight[i]); - av_image_copy_plane(out->data[i] + out->linesize[i] * !s->first_field, - out->linesize[i] * 2, - s->prev->data[i], s->prev->linesize[i], - s->linesize[i], s->planeheight[i]); - } else { - av_image_copy_plane(out->data[i] + out->linesize[i] * !s->first_field, - out->linesize[i] * 2, - in->data[i], in->linesize[i], - s->linesize[i], s->planeheight[i]); - av_image_copy_plane(out->data[i] + out->linesize[i] * s->first_field, - out->linesize[i] * 2, - s->prev->data[i], s->prev->linesize[i], - s->linesize[i], s->planeheight[i]); - } + av_image_copy_plane(out->data[i] + out->linesize[i] * field1, + out->linesize[i] * 2, + in->data[i], in->linesize[i], + s->linesize[i], s->planeheight[i]); + av_image_copy_plane(out->data[i] + out->linesize[i] * field2, + out->linesize[i] * 2, + s->prev->data[i], s->prev->linesize[i], + s->linesize[i], s->planeheight[i]); } out->pts = s->double_weave ? s->prev->pts : in->pts / 2; -- 2.18.0