I420

From Avisynth wiki
Revision as of 22:34, 9 May 2013 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I420 is the exact same thing as YV12, but with the chroma plane order swapped (YV12 stores the planes in the order Y, Cr, Cb (or Y, V, U), while I420 stores them as Y, Cb, Cr (or Y, U, V)). In many (most?) practical applications, I420 is what people actually mean when they say YV12.

Avisynth treats both formats exactly the same, to the point that Info will report both of them as being YV12, IsYV12 will return true for both of them, and calling ConvertToYV12 on a clip of either format is a no-op regardless of the chroma plane order. For end users it is for most intents and purposes impossible to tell the difference (not that you should care anyway, it's none of your business). Most source filters will return I420 if you ask for YV12. However, the VfW interface will always output YV12, and swap the plane order if necessary.

If you somehow do manage to get the ordering wrong, it will most likely be immediately obvious to you (reddish colors will appear as bluish and vice versa) unless you are color blind or the clip is monochrome. You can trivially fix such problems (wrong chroma plane order, not color blindness) with a call to SwapUV.

For plugin writers: In all places except env->NewVideoFrame(vi), CS_YV12 and CS_I420 are considered identical. This distinction is to allow source filters to import YV12 and I420 video data directly into a PVideoFrame without needing to blit the individual planes.

A historical anecdote

For a very very long time MeGUI had a funny bug where it would complain about the script's output not being YV12, and offering to add ConvertToYV12() to the end of it for you. If you accepted its offer, it'd add ConvertToYV12() and then immediately pop up the same warning again. This would continue ad infinitum until you told it to stop. It'd then work just fine. This bug was eventually "fixed" by adding a "don't ask again" checkbox, and was left in that state for about two years until someone pointed out the difference (or perhaps the similarity) between YV12 and I420 to the MeGUI authors. Since the script output was I420, and the MeGUI authors didn't know what to do with that, they tried to add ConvertToYV12(), but that's a no-op on I420 and so the output format remained the same.

The moral of this story is that the definition of insanity is doing the same thing over and over and expecting different results.
(Attributed to Albert Einstein as well as to Benjamin Franklin and Mark Twain).

Personal tools