PDA

View Full Version : How lossy (and computationally intensive) is YUY2 --> YV12 (and back) conversion?


chaynik
2nd October 2009, 08:10
A lot of my source media originates as MPEG-2, already in the YV12 4:2:0 color format, however pretty much all video editing software (Final Cut Pro, Avid, etc) only thinks in 4:2:2 and higher. I use AviSynth for prepping the material for editorial (ivtc, etc) so I can stay within YV12 internally, but when rendering the prepped material for editorial, I must upsample to 4:2:2. Ironically, after editorial my destination format is either MPEG-2 or H.264, both 4:2:0, so this step is unfortunately completely redundant but necessary for compatibility.

The question is, how lossy is this practice? Does the chroma simply get doubled during conversion to YUY2 (and then discarded during conversion back to YV12) or does it get resampled (via bicubic or similar)? Does different software handle this conversion differently (AviSynth vs CCE, for example)? I would imagine if it's the former, the output would be lossless since it's a matter of first adding an extra pixel "every other time" and then throwing it away "every other time". If it's the latter, however, I imagine there would be some loss as it's akin to resizing a picture from 360x240 to 360x480 and then back to 360x240 (although here it only occurs in the chroma plane). How noticeable is this loss? Can it have a noticeable impact on let's say, h.264 compression efficiency?

I've also noticed that performance wise, I get much higher framerates in x264 encoding from a YV12 file over a YUY2 file (with ConvertToYV12 added), leading me to believe these calculations are somewhat computationally intensive (and I'm on an 8-core Xeon machine), hinting at pixels being resampled versus simply doubled/discarded.

Certain encoders like CCE take YUY2 only so the upconversion is a must even though the output is YV12. Would one recommend using a different mpeg2 encoder because of this (such as those in ffmpeg and/or mencoder) or again is this conversion of minor importance and minor impact on quality?

What are some rules/practices pertaining to all of this? Are there any workarounds I may not know of?

Thanks in advance.

Gavino
2nd October 2009, 11:02
The question is, how lossy is this practice? Does the chroma simply get doubled during conversion to YUY2 (and then discarded during conversion back to YV12) or does it get resampled (via bicubic or similar)?
In Avisynth 2.58, the chroma is linearly interpolated for YV12<->YUY2 conversions (equivalent in effect to bilinear resampling), so neither conversion is lossless. See here (http://avisynth.org/mediawiki/Sampling) for the details.

In Avisynth 2.60, you will have additional options to choose the resampling method, and can choose point resampling for lossless operation.

chaynik
3rd October 2009, 08:53
Thank you for your reply. I see an alpha of 2.60 is on SourceForge, has said resampling method been already implemented? How stable is the 2.60 alpha, are there a lot of core changes?

Gavino
3rd October 2009, 10:09
See this thread in the Development forum. According to this, the new options are available:
* Added ChromaPlacement and ChromaResample options to planar colour conversions

2Bdecided
6th October 2009, 10:51
I think you can, with care, separate out the chroma channels and do whatever resizing you want, e.g. point resizing, or resizing where only the pixels you will later throw away are interpolated, and the ones you will later keep are passed straight through.

What you really want for the second stage (but it doesn't exist - yet!) is something like convertbacktoyv12 - which, like the existing convertbacktoyuy2, just point resizes down without filtering.

Cheers,
David.