Log in

View Full Version : SelectEven/SelectOdd ... odd wiki statements


halsboss
25th November 2008, 12:09
Hi, I came across what appears to be conflicting definitions and seek your advice.

http://en.wikipedia.org/wiki/Field_dominance says
Interlacing divides the frame into two fields, scanning the odd numbered lines first and then the even numbered lines. Each field is scanned in 1/60th of a second under NTSC (actually 1/59.94 in drop frame color TV video) or 1/50th of a second under PAL. Proper field dominance selection in linear editing systems will maintain color framing synch.

http://avisynth.org/mediawiki/Select says
Since frames are numbered starting from zero, SelectEven actually selects the first, third, fifth,... frames by human counting conventions.


http://www.mir.com/DMG/interl.html says
What are "even" and "odd" fields? That's crazy-talk. Even worse, it's really ambiguous and confusing. Don't use those words.


So I guess the correct usage in AviSynth is like
SeparateFields()
Shift = (GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
E = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0, Shift)
O = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -Shift)
Ec = SelectEven().Spline36Resize(NewWidth, NewHeight/2, 0, 2*Shift)
Oc = SelectOdd( ).Spline36Resize(NewWidth, NewHeight/2, 0, -2*shift)
Interleave(E, O)
IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last
Weave()

where it's always even (top) then odd (bottom) ? Just treble-checking.

Guest
25th November 2008, 14:31
If you are asking is even == top and odd == bottom, the answer is yes.

IanB
25th November 2008, 15:06
If you are asking is even == top and odd == bottom, the answer is yes. But only for Top Field First material.


SelectEven() always selects the first, third, fifth, ... avisynth frames. (0, 2, 4, ...)

SelectOdd() always selects the second, fourth, sixth, ... avisynth frames. (1, 3, 5, ...)

These functions are independent of field order!


SeparateFields() splits a interlaced full frame clip into a clip of individual fields. The order is dependant on the specified field order or parity as BenRG has named it.

For Top Field First material the top fields become 0, 2, 4, ... and the bottom fields become 1, 3, 5, ...

Bottom Field First material the bottom fields become 0, 2, 4, ... and the top fields become 1, 3, 5, ...

The example script you quote is Gavino's YV12 mod to my interlaced resize functionality. It is temporal field order agnostic and always processes each top field the same way and each bottoms field the opposite way.


To bind Top and Bottom to Even and Odd you need to know (specify) the field order.

Guest
25th November 2008, 15:26
I thought he was talking about even and odd fields.

Even field = top field
Odd field = bottom field

2Bdecided
25th November 2008, 18:20
FYI...

http://www.pembers.freeserve.co.uk/World-TV-Standards/Line-Standards.html#Vertical

Because, in the interlaced system, there is an odd number of lines in each frame, it follows that each field contains a number of full lines plus one half line. The fields that have the half line at the end are called 'odd' and those with a full line at the end are called 'even'. This nomenclature is unfortunate because it is intuitive to suppose that fields given the numbers 1, 3, 5, 7 etc are 'odd' and the intervening ones are 'even', when this is not the case for all standards. In fact in the 625-line standard Field 1 is 'even' and Field 2 is 'odd'.In the 625-standard, by his numbering, top field = 1, bottom field = 2.

btw, that website is actually more definitive than the various international video standards documents - it's well worth a read if you're a video anorak!


As Ian has explained, AVIsynth selecteven and odd have nothing to do with this!

I always use selectevery(2,0) anyway - saves me having to remember what selecteven does!

Cheers,
David.

halsboss
28th November 2008, 14:55
Cringes. SelectEven and SelectOdd after separatefields() depend on statement of TFF or BFF if I understood IanB. For my usually TFF stuff, the top fields become 0, 2, 4, ... and the bottom fields become 1, 3, 5, ...

Thankyou all. This is more challenging than I thought possible.

halsboss
28th November 2008, 23:42
Just checking -

I have BFF DV sources from my Canon DV MV920 handycam - does the SelectEven/SelectOdd still give me a correct result if I use a script based on the above and want to leave it as BFF for encoding in HC ?
eg
AssumeBFF().SeparateFields()
E = SelectEven().Convolution3D(0, 32, 128, 16, 64, 10, 0)
O = SelectOdd( ).Convolution3D(0, 32, 128, 16, 64, 10, 0)
Interleave(E, O)
Weave()

Edited out rubbish. If I'd read http://forum.doom9.org/showthread.php?p=1110710#post1110710 and http://forum.doom9.org/showthread.php?p=1110741#post1110741 then it'd be clear that it works properly for both TFF and BFF... as does MTi.


1. E.g. Take a TFF source :-
[TB],[TB],[TB],...
Bob it
[Tb],[tB],[Tb],[tB],[Tb],[tB],... - Lowercase is interpolated fields
4,0,3 selects
[TB],[TB],[TB],...
4,1,2 selects
,[bt],[bt],...

2. E.g. Take a BFF source :-
[B][BT],[BT],[BT],...
Bob it
[Bt],[bT],[Bt],[bT],[Bt],[bT],... - Lowercase interpolated fields
4,0,3 selects
[BT],[BT],[BT],...
4,1,2 selects
[tb],[tb],[tb],...
long story short:
AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave() -> TFF
AssumeBFF().SeparateFields().SelectEvery(4, 0, 3).Weave() -> BFF
AssumeTFF().SeparateFields().SelectEvery(4, 1, 2).Weave() -> BFF
AssumeBFF().SeparateFields().SelectEvery(4, 1, 2).Weave() -> TFF

http://avisynth.org/mediawiki/MT

* MTi() that creates two threads and let each thread process one field before combining them like this avs function

function PseudoMTi(clip c,string filter)
{
a=eval("c.AssumeFieldBased().SeparateFields.selecteven()."+filter)
b=eval("c.AssumeFieldBased().SeparateFields.selectodd()."+filter)
interleave(a,b).weave()
}

like the other pseudoscript a and b are executed in parallel. Note that only two threads are created so it will only use two (virtual) cores.

stickboy
28th November 2008, 23:44
Cringes. SelectEven and SelectOdd after separatefields() depend on statement of TFF or BFF if I understood IanB. For my usually TFF stuff, the top fields become 0, 2, 4, ... and the bottom fields become 1, 3, 5, ...

Thankyou all. This is more challenging than I thought possible.If you find it too complicated, you could use my JDL_SelectTopField/JDL_SelectBottomField functions (http://www.avisynth.org/stickboy/).

stickboy
28th November 2008, 23:49
Erm, just checking - I have BFF DV sources from my Canon DV MV920 handycam - does the SelectEven/SelectOdd still give me a correct result if I use a script based on the above and leave it as BFF for encoding in HC ?
eg


Also, will MTi process BFF correctly and leave it as BFF ?I don't know what MTi is, but the script you gave will preserve the field order and dominance, yes.