diff mbox

[FFmpeg-devel] Refactor two near-identical clauses - take 2

Message ID 20180628115210.20bd9d26@telaviv1.shlomifish.org
State New
Headers show

Commit Message

Shlomi Fish June 28, 2018, 8:52 a.m. UTC
Hi all!

Attached is the 2nd take of the patch for vf_weave.c. Please review.

Comments

Shlomi Fish July 4, 2018, 9:20 a.m. UTC | #1
On Thu, 28 Jun 2018 11:52:10 +0300
Shlomi Fish <shlomif@shlomifish.org> wrote:

> Hi all!
> 
> Attached is the 2nd take of the patch for vf_weave.c. Please review.
> 

Ping.
Paul B Mahol July 4, 2018, 2:43 p.m. UTC | #2
On 7/4/18, Shlomi Fish <shlomif@shlomifish.org> wrote:
> On Thu, 28 Jun 2018 11:52:10 +0300
> Shlomi Fish <shlomif@shlomifish.org> wrote:
>
>> Hi all!
>>
>> Attached is the 2nd take of the patch for vf_weave.c. Please review.
>>
>
> Ping.

If expat license is compatible with LGPL that it is ok for merge.

Otherwise it should not be committed.
Carl Eugen Hoyos July 4, 2018, 4:45 p.m. UTC | #3
2018-06-28 10:52 GMT+02:00, Shlomi Fish <shlomif@shlomifish.org>:

> Attached is the 2nd take of the patch for vf_weave.c. Please review.

For future patches:

> The changes contained in this patch are hereby placed under the Expat licence.

If you add a new file (like a new filter or decoder) please feel free
to use the MIT license if you prefer it over the LGPL.
If you change a small number of lines in an existing file, please avoid
this, two developers already spent time on this unneeded line.

Carl Eugen
Carl Eugen Hoyos July 4, 2018, 4:55 p.m. UTC | #4
2018-06-28 10:52 GMT+02:00, Shlomi Fish <shlomif@shlomifish.org>:

> Attached is the 2nd take of the patch for vf_weave.c. Please review.

Patch applied.

Thank you, Carl Eugen
Shlomi Fish July 4, 2018, 6:04 p.m. UTC | #5
Hi,

On Wed, 4 Jul 2018 18:45:09 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2018-06-28 10:52 GMT+02:00, Shlomi Fish <shlomif@shlomifish.org>:
> 
> > Attached is the 2nd take of the patch for vf_weave.c. Please review.  
> 
> For future patches:
> 
> > The changes contained in this patch are hereby placed under the Expat
> > licence.  
> 
> If you add a new file (like a new filter or decoder) please feel free
> to use the MIT license if you prefer it over the LGPL.
> If you change a small number of lines in an existing file, please avoid
> this, two developers already spent time on this unneeded line.
> 

my intention in that was to avoid licensing my changes under the LGPL, so
future maintainers will be able to change the licence of the file to a
different one, should it be desirable. Next time, I will provide a better
phrasing, however.

> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Shlomi Fish July 4, 2018, 6:05 p.m. UTC | #6
On Wed, 4 Jul 2018 18:55:42 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2018-06-28 10:52 GMT+02:00, Shlomi Fish <shlomif@shlomifish.org>:
> 
> > Attached is the 2nd take of the patch for vf_weave.c. Please review.  
> 
> Patch applied.
> 

Thanks!

> Thank you, Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

From c94e6cc8272e2bdb1d23014814dde02eafd739a6 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
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