Why does DoubleWeave change the field-order?

DoubleWeave doubles the number of frames by mixing fields from adjacent frames. One common use is to combine it with SelectEvery to telecine material, typically converting 24 fps progressive film to 29.97 fps interlaced video.

If the clip is progressive and is set as top-field-first, you would expect that the output from DoubleWeave also would be top-field-first, right?

Unfortunately, the way that DoubleWeave works on progressive clips isn't quite so intuitive. Suppose that the original video is composed of frames that look like:

A  B  C  D  E  (top field)
a  b  c  d  e  (bottom field)

(I'm using uppercase letters for the upper (top) fields and lowercase letters for the lower (bottom) fields.)

If the video is top-field first, when separated into fields, it would look like:

A  a  B  b  C  c  D  d  E  e
0  1  2  3  4  5  6  7  8  9  (field number)

DoubleWeave doesn't make any attempt to preserve field-order; instead, it combines every pair of adjacent fields. That is, it combines fields 0 and 1, 1 and 2, 2 and 3, and so forth to generate the following pairs:

(A a) (a B) (B b) (b C) (C c) (c D) (D d) (d E) (E e) (e A′)
 0 1   1 2   2 3   3 4   4 5   5 6   6 7   7 8   8 9   9

When these field pairs are combined to make frames, we then get:

A  B  B  C  C  D  D  E  E  A′ (top field)
a  a  b  b  c  c  d  d  e  e  (bottom field)

The field-order of the newly generated frames is bottom-field first, which is opposite of what we started with!

How can we avoid this problem? Simple: for progressive material, if you want to preserve the field-order of the original clip, call ComplementParity before calling DoubleWeave.