aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_weave.c
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2018-06-28 11:42:45 +0300
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2018-07-04 18:48:10 +0200
commit1ecdcb61b0acf4a1f9bce002bff5d08b8a3e1213 (patch)
treeeddd4704c0ece07bd0cebc5b1f4e2eb4d4d4bdd9 /libavfilter/vf_weave.c
parent267ba2aa96354c5b6a1ea89b2943fbd7a4893862 (diff)
downloadffmpeg-1ecdcb61b0acf4a1f9bce002bff5d08b8a3e1213.tar.gz
lavfi/weave: Refactor two near-identical clauses.
The changes contained in this patch are hereby placed under the Expat licence. Reviewed-by: Paul B Mahol
Diffstat (limited to 'libavfilter/vf_weave.c')
-rw-r--r--libavfilter/vf_weave.c32
1 files 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;