Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
29th May 2006, 07:31 | #1 | Link |
Registered User
Join Date: May 2004
Posts: 163
|
interlaced YV12 problem
Code:
a=BlankClip(length=500, width=720, height=288, pixel_type="YUY2", fps=25, fps_denominator=1, audio_rate=48000, stereo=false, sixteen_bit=true, color=$FF0000) b=BlankClip(length=500, width=720, height=288, pixel_type="YUY2", fps=25, fps_denominator=1, audio_rate=48000, stereo=false, sixteen_bit=true, color=$00fF00) interleave(a,b) assumefieldbased() weave() #1 converttoyv12(interlaced=true) #2 #converttoyuy2(interlaced=true) both yuy2 outputs look the same the yuy2 and yv12 outputs look different. they should look the exactly the same. this would lead me to believe the YV12 codec is not working correctly. tried XVID and FFDshow-VFW. Or is this correct behaviour? |
29th May 2006, 07:40 | #2 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Conversion to YV12 and back is lossy by definition. YUY2 is fully sampled vertically; YV12 is not. If you throw away information you cannot get it back.
There is also a phenomenon called Chroma Upsampling Error (CUE) that you may be seeing. See here for technical details: http://www.avisynth.org/Sampling Last edited by Guest; 29th May 2006 at 07:44. |
29th May 2006, 07:42 | #3 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
No, they should be the same, since both fields are uniform. So if they aren't, it's a bug.
__________________
|
29th May 2006, 07:52 | #4 | Link |
Registered User
Join Date: Feb 2006
Posts: 823
|
No it's not a bug. Assuming that YV12 supports interlacing is wrong. I'm pretty sure that the YV12 data will be upsampled to RGB for display assumed as progressive as there is no way of signalling if YV12 data is interlaced or not. Again the YV12 format as such does not support this. It consists of 1 Y plane, 1 U plane and 1 V plane and since both U and V planes are halfheight it can't possibly be interlaced. (Chroma is always shared between line 1 and 2, line 3 and 4, etc.)
Of course 4:2:0 can be interlaced, but not the format known as YV12. Last edited by GodofaGap; 29th May 2006 at 07:54. |
29th May 2006, 07:55 | #5 | Link | |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Quote:
drcl, what difference do you see? @GodofaGap There are progressive and interlaced samplings for YV12. |
|
29th May 2006, 08:05 | #6 | Link |
Registered User
Join Date: Feb 2006
Posts: 823
|
Neuron2: where can I find the interlaced YV12. The format description here makes no mention of it --> http://www.fourcc.org/yuv.php#YV12.
Also in VirtualDub 1.6.14 I can definately see a difference between YV12 and YUY2. Perhaps Avery Lee's comments can clarify this. http://forums.virtualdub.org/index.p...&f=15&t=11044& |
29th May 2006, 08:06 | #7 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
I didn't say there was any flag to denote the different sampling *in AVI*. MPEG has such a flag. This is one reason why YV12 is a minefield and you have to know where you are stepping.
While Avery says that YV12 *shouldn't* be overloaded, in practice it often is. Last edited by Guest; 29th May 2006 at 08:10. |
29th May 2006, 08:52 | #9 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
For output, yes! But to provide maximum functionality from all and any input source we cater (clumsily) with interlaced YV12 layout. A lot of people like to reprocess clips to progressive form and like to do so with the minimum loss of data, we oblige.
Note also there are hacks within AVI to cope with interlaced 4:2:0 as bent YV12. A solution could be to have a different FourCC for interlaced 4:2:0 avi data, but until one is ratified we have nothing to implement against. See the article, http://www.avisynth.org/Sampling for lots of good discussion and further links. |
29th May 2006, 09:27 | #10 | Link | |
Registered User
Join Date: Feb 2006
Posts: 823
|
Quote:
For all clarity I do not think using/outputting interlaced YV12 is wrong, it is in fact very practical. I just wanted to explain where the problems as seen by drcl come from. |
|
29th May 2006, 11:52 | #11 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Maybe 2.6 can add new hooks to handle progressive/interlace mixing, but dgdecode's upconv seems like a far cleaner solution (other than having to use yuy2, not yv16). In that case it wouldn't be hard to just make up a YI12 (YV12 interlaced) 4cc and use that when avisynth outputs it? I'm sure avery would agree to that. (ConvertToYI12 would by the same as ConvertToYV12(interlaced=true) except for setting the new 4cc, for backwards compatibility, if desired.)
A bit off topic: Ian, is YV12->RGB roughly equivalent to the page's explanations of YV12->YUY2->RGB, but one step? Or is it entirely differently weighted? (Barring the addition of a 4:4:4 planar format, it'd be very nice to use something sharper than a very basic kernel to do the upsampling. Perhaps in the future it could be passed through resize filters, like lanczos or spline?) Last edited by foxyshadis; 29th May 2006 at 11:55. |
29th May 2006, 12:17 | #12 | Link |
Registered User
Join Date: Feb 2006
Posts: 823
|
I don't think it is very practical to use new fourcc's if it is only supported by VirtualDub. It would be easier if an existing 4:2:0 format would be used that properly supports interlacing. (Although 4:2:0 can never really do this due to vertically shared chroma.)
|
29th May 2006, 14:45 | #13 | Link | |||||
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Quote:
Quote:
Quote:
Quote:
Quote:
|
|||||
29th May 2006, 15:48 | #14 | Link | |
Registered User
Join Date: Feb 2006
Posts: 823
|
Quote:
|
|
29th May 2006, 16:19 | #15 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
It's doubtful such a format would ever be ratified by any body, as most commercial tools import DV/MPEG directly and don't need a lossless intermediary. If you and Avery Lee agree on a format that isn't in use now, to describe an encoding that you're the main producer of, others might follow. After all, almost every format out there were given fourccs by a company without any standard recognition.
|
29th May 2006, 19:26 | #16 | Link |
Registered User
Join Date: May 2004
Posts: 163
|
@neuron2
they just look different in virtualdub when zoomed, i cant explain. the conversion to yv12 then back to yuy2 looks the same as the original yuy2 isn't CUE only applicable to horizontal errors? its my understanding is, in respect to display representation, that yv12 and yuy2 are the same in luminance plane but chroma is vertically half in yv12. in interlacing the vertical is sampled across odd/even couplets of lines. so if i start with lines in yuy2..... 1: RED 2: BLUE 3: RED 4: BLUE Then convertoyv12(interlaced=true) i should still get red, blue ,red, blue; but in memory its represented differently as one piece of data for 2 lines as apposed to one for each line if i convert back... converttoyuy2(interlaced=true) i should be able to recover all the data losslessly, which it appears that i do. of course this would not be true for an image where lines 1 and 3 originally had different chroma values anyone else able to recreate this? Last edited by drcl; 30th May 2006 at 00:27. |
29th May 2006, 19:59 | #17 | Link |
brainless
Join Date: Mar 2003
Location: Germany
Posts: 3,653
|
in fact interlaced vs progressive Sampling conversions between YUY2 and YV12 are the extremes. There also is a thing inbetween...
If you want to make absolutely sure, that nothing goes wrong with chroma motion, then do interlaced sampling. This will preserve the fields at every cost (the price is much lower accuracy in vertical). If you want to achieve best possible resolution with progressive video, then stick for progressive sampling. This destroys the field structure, of course and also WILL show chroma combing on TV. The best of both worlds can be achieved with motion adaptive YUY2 <-> YV12 conversion routines. Such a function will sample everything static as progressive and everything that is combed as interlaced. Also this kind of conversion routine is the most lossless on because it does the mode decision upone the image content rather than the users (mis-) choice. Also not that interlaced subsampled YV12 can be upsampled the progressive way and progressive subsampled YV12 can be upsampled interlaced. This is possible because the sampling points of interlaced ond progressive YV12 are in the SAME place. This also is the reason, why there is NO interlacing flag for YV12. The interlaced signalling has to be made by the overlayed codec, like MPEG2 does.
__________________
Don't forget the 'c'! Don't PM me for technical support, please. Last edited by scharfis_brain; 29th May 2006 at 20:01. |
29th May 2006, 22:39 | #18 | Link | |
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
Quote:
[*] The stuff on your dvd is technically not YV12. The part which is 4:2:0 progressive is the same format as YV12, but 4:2:0 interlaced is not. This should be reflected in the docs one day. |
|
30th May 2006, 04:59 | #19 | Link |
Registered User
Join Date: May 2004
Posts: 163
|
it is the codec....
i just read the cue documentation again, it does explicitly state that yv12 codecs like XVID upsample interlaced yv12 incorrectly as they assume progressive, I guess virtual dub does the same, in fact all applications would assume it. Thats why CCE doesnt accept YV12 i guess.
I also realised that if i had used separatefields() then it would have been more obvious what was really going on. Only encoders that "know" that they are getting input from AVS in YV12 interlaced will encode correctly, I assume. ie HC/QuEnc Does XVID encoder sample correctly if the interlaced checkbox is set? So yv12 interlaced will always look wrong when converted to rgb by anything other than avs. It's not a bug. I'll read everything for that 5th time before i post again. Last edited by drcl; 30th May 2006 at 05:48. |
30th May 2006, 07:04 | #20 | Link | |
Lazy noob.
Join Date: Sep 2005
Posts: 65
|
Quote:
|
|
|
|