I am aware that various video formats have different chroma placements. When converting to and from YV12 one should specifiy the Chroma In/OutPlacement as I understand.
- What is the chroma placement of an interlaced Huffyuv *.avi (UYVY,YUYV,YUY2) 4:2:2 capture? Is it always "DV"?
- How can I verify the chroma placement of a video file (i.e. DV, mpeg1 or mpeg2 .....)?
Any hint is appreciated.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 18 of 18
Thread
-
Last edited by Sharc; 14th May 2021 at 03:34.
-
(Haven't looked at chroma placement for ages, but here is my go at it,...)
What I do is assuming the source is YV12 and Rec601:- load the source
- separate the fields (if the source is interlaced)
- do a conversion from YV12 to RGB using the different versions Code:
ConvertToRGB(interlaced=false, matrix="Rec601", ChromaInPlacement="XXX")
I would chose RGB as target since normally Preview is always in RGB and thus the preview tool doesn't have to do additional conversions. - enlarge the image by a factor of 4
- add subtitles to identify what is what
- look for chroma misalignment
So as Avisynth script something like:
Code:clip = clip.SeparateFields() a = clip.ConvertToRGB(interlaced=false, matrix="Rec601", ChromaInPlacement="MPEG1").PointResize(clip.Width()*4,clip.Height()*4).Subtitle("MPEG1") b = clip.ConvertToRGB(interlaced=false, matrix="Rec601", ChromaInPlacement="DV").PointResize(clip.Width()*4,clip.Height()*4).Subtitle("DV") c = clip.ConvertToRGB(interlaced=false, matrix="Rec601", ChromaInPlacement="MPEG2").PointResize(clip.Width()*4,clip.Height()*4).Subtitle("MPEG2") Interleave (a,b,c)
I think the main problem is to spot the problem. So if there are easier ways to do this let me know.
Cu Selurusers currently on my ignore list: deadrats, Stears555 -
Sorry, the title is probably somewhat misleading. It should be Chroma Placement.
The Chroma Placement is a conversion parameter when converting to and from YV12(), for example:
ConvertToYV12(interlaced=true,ChromaOutPlacement=" DV")
ConvertToRGB32(interlaced=true,ChromaInPlacement=" DV")
It can be "DV", "mpeg1" or "mpeg2". Therefore my question about the Huffyuv interlaced 4:2:2 captures when I convert it to YV12() and to RGB32().
MediaInfo does not report it.
Edit: Just overlapped with Selur's reply. Thank you. Will try it out. Apparently there is no tool to report it, and it's not a big issue when it is set incorrectly.Last edited by Sharc; 14th May 2021 at 05:02.
-
and it's not a big issue when it is set incorrectly.
It's easier to spot with cartoons, screen captures or something similar where you have larger uni colored areas.users currently on my ignore list: deadrats, Stears555 -
Thank you for the link. It's interesting and educational.
4:2:2
Y’CBCR studio digital video according to Rec. 601, including professional DV50 systems and the 422 profile of MPEG-2 (sometimes
denoted 422P) use 4:2:2 sampling. In the 4:2:2 scheme, CB and CR
components are each subsampled by a factor of 2 horizontally; their
effective positions are coincident (cosited) with alternate luma
samples.
4:2:0
Figure 2 shows MPEG-2’s 4:2:0 subsampling for frame-coded
(progressive) pictures. For field-coded interlaced (top and bottom)
pictures, the situation is more complicated; a description of chroma
subsampling for field-coded pictures is outside the scope of this document. -
Just to get this straight: HuffYUV (or pretty much any other codec, lossless or not) does not know (or even care) about chroma placement. It takes 4:2:2, compresses it, and decompresses it to whatever it was before. Chroma placement does not matter to the codec.
In my experience and humble opinion, all capture devices outputting 4:2:2 (UYVY, YUYV, YUY2) use MPEG2 chroma placement.
Which makes sense because "DV" and "MPEG1" chroma placements only apply to some 4:2:0 and 4:1:1 formats. -
Look at Figure 2 in the link jagabo provided.
4:4:4, 4:2:2, 4:1:1 are always sampled the same way, so no ambiguity there.
For 4:2:0 there are different chroma placement options, so when converting to/from 4:2:0 chroma placement is important.
Cu Selurusers currently on my ignore list: deadrats, Stears555 -
Interlaced 4:2:0 is the same as progressive 4:2:0 except it's based on fields rather than frames. Ie, the first chroma samples are for lines 0 and 2, not lines 0 and 1.
-
Thanks everybody for the comments.
That's what I thought as well. The script below triggered my doubts though.
Only for "DV" chroma placement the case A and B produced identical outputs.
Maybe the script doesn't prove anything, and I was mainly confusing myself .......
Code:source=AVISource("422i.avi") #Case A: convert to YV12, then separate the fields A = source.AssumeTFF() A_DV = A.ConvertToYV12(matrix="Rec601", interlaced = true, ChromaOutPlacement ="DV").AssumeFrameBased().SeparateFields() A_MPEG1 = A.ConvertToYV12(matrix="Rec601", interlaced = true, ChromaOutPlacement ="MPEG1").AssumeFrameBased().SeparateFields() A_MPEG2 = A.ConvertToYV12(matrix="Rec601", interlaced = true, ChromaOutPlacement ="MPEG2").AssumeFrameBased().SeparateFields() #Case B: separate the fields, then convert to YV12 B=source.AssumeTFF() B_DV = B.AssumeFrameBased().SeparateFields().ConvertToYV12(matrix="Rec601",interlaced=false, ChromaOutPlacement ="DV") B_MPEG1 = B.AssumeFrameBased().SeparateFields().ConvertToYV12(matrix="Rec601",interlaced=false, ChromaOutPlacement ="MPEG1") B_MPEG2 = B.AssumeFrameBased().SeparateFields().ConvertToYV12(matrix="Rec601",interlaced=false, ChromaOutPlacement ="MPEG2") #highlighting the difference diff1=subtract(A_DV,B_DV).Levels(127, 1, 129, 0, 255,coring=true).subtitle("DV") diff2=subtract(A_MPEG1,B_MPEG1).Levels(127, 1, 129, 0, 255,coring=true).subtitle("MPEG1") diff3=subtract(A_MPEG2,B_MPEG2).Levels(127, 1, 129, 0, 255,coring=true).subtitle("MPEG2") return interleave(diff1,diff2,diff3)
-
I don't seem to get that result. I get differences everywhere in the resulting video (no completely gray frames at all).
There is one big flaw in this script however: separating the fields and then doing the YUY2 to YV12 conversion with interlaced=false generally produces incorrect interlaced YV12 (as in "Case B")! It is not supposed to yield the same result as using interlaced=true on frames ("Case A").Last edited by Skiller; 17th May 2021 at 22:28.
-
Strange. For "DV" I am getting a completely gray picture with RGB(137,137,137) or YUV(134,128,128).
My Avisynth is v3.7.0 x86 (32 bit because of the HUFFYUV)
There is one big flaw in this script however: separating the fields and then doing the YUY2 to YV12 conversion with interlaced=false generally produces incorrect interlaced YV12 (as in "Case B")! It is not supposed to yield the same result as using interlaced=true on frames ("Case A").
So the script fails to serve the purpose of finding the ChromaPlacement more eye-catching. I tried to apply Selur's script but I couldn't really verify the chroma placement for this source.
Edit:
I found this which shows the chroma placement of 4:2:0 MPEG1 and interlaced MPEG2 and "DV PAL"
https://www.mir.com/DMG/chroma.html
I think it gives an idea how the luma/chroma grid looks when we 'SeparateFields()' in Avisynth, skipping every other scanline and displaying the field at half height, no?Last edited by Sharc; 18th May 2021 at 08:41. Reason: Link added
-
Just wanted to give it a shot in Vapoursynth. Can someone fill the blank or correct it if knowing whats the equivalent:
Avisynth: ChromaOutPlacement ="MPEG1" ... Vapoursynth: chromaloc_s="center"
Avisynth: ChromaOutPlacement ="MPEG2" ... Vapoursynth: chromaloc_s="left"
Avisynth: ChromaOutPlacement ="DV" ......... Vapoursynth: chromaloc_s=blank .... "top_left" guessingLast edited by _Al_; 18th May 2021 at 17:54.
-
I'm still on classic AVS 2.6.0 so that could potentially be a cause for discrepancies, but if it is I would be baffled as to why there would have been changes in regards to such behavior in color space conversions.
Anyway, let's test something.
Please run this standalone script and report back if the output is grey or has some horizontal colored stripes.
Code:ColorBars(pixel_type="YUY2") A=ConvertToYV12(interlaced=true, chromaresample="Spline16") B=SeparateFields().ConvertToYV12(interlaced=false, chromaresample="Spline16").weave() Subtract(A,B).Levels(127,1,129, 0,255, coring=true)
interlaced=true should not make it grey either.
What this is supposed to demonstrate is that doing the YUY2 to YV12 conversion on field separated video (B) compared to frame based video (A) yields different results (resulting in colored stripes rather than a gray video).
Which leads to my next issue...
You misunderstood me there and I hope the above script emphasizes my point: If you do the conversion from YUY2 to YV12 on field separated video – no matter if you are using interlaced=true or false – the result is incorrect YV12 chroma (that is if the script above produces colored stripes for you as well).
Which is not surprising considering your analog tape source has a horizontal chroma res of about 80 columns. Any mismatch in chroma placement becomes pretty much invisible with such a low chroma res.
But I think you are overthinking this. Unless you have a really oddball 4:2:2 capture device, the chroma placement will be MPEG2.Last edited by Skiller; 18th May 2021 at 20:13.
-
Thank you for your comments.
There has been a long discussion on v 2.58 .... 2.6.0 and chroma placement/format conversion issues here:
https://forum.doom9.org/showthread.php?t=147629
I don't know what has been changed or fixed in the meantime. There are chances though.
I see. Now this is what I am getting with your script, for interlace='false' or 'true':
[Attachment 58978 - Click to enlarge]
[Attachment 58979 - Click to enlarge]
Agree, it's not critical for these low resolution VHS captures. My intention was mainly to understand what's happening, and to do the conversions "technically correct" as much as possible.
Now I am not even 100% sure if my captured .avi is really 4:2:2 as reported by MediaInfo. My current capture setup is: VCR tape player via SCART (composite) -> Composite IN of Pana EH50 (in passthrough mode for 'TBC') -> Pana EH50 S2-video OUT (suppressing the dotcrawl of the composite, probably thanks to the EH50 internal 3D comb filter, I assume) -> Hauppauge USB-Live2. Hope it didn't convert to 4:1:1 DV or misplace the chroma at some point along the capturing process.
Edit: It's really 4:2:2 because the U an V planes have half width and full height. 4:1:1 would be 1/4 width only for the U and V planes, right? And yes, for 4:2:2 there is by definition no ambiguity with the Chroma Placement, it is aligned horizontally (just subsampled) and vertically with the luma samples. I hope (or trust) that my capture setup does not violate it even when it captures interlaced fields. The ambiguity with chroma placements and interlace issues apply for 4:2:0 conversion only, I understand.
Added:
As another test I changed my avisynth 3.7.0 to 2.60. Surpisingly, the result of my script in post #12 changed, producing colors for "DV" as well, while the result of your script in post #16 is the same (at a first glance). So something seems to have changed from 2.60 to 3.70 with respect to format conversions. Uggghh.....Last edited by Sharc; 19th May 2021 at 08:21. Reason: see 'Added:....'
-
Further on the subject (sorry to be a nagger):
This paper explains on page 7, Figures 6 and 7, the chroma placement and subsampling in more detail. It is shown for progessive frames and explains for 4:2:0 the two variants MPEG-1 and MPEG-2 (Figure 4, page 6).
https://poynton.ca/PDFs/Merging_RGB_and_422.pdf
This article shows 3 varieties for 4:2:0 subsampling, with 2 variants for interlaced 4:2:0 (MPEG-2 and SMPTE DV-PAL).
https://www.mir.com/DMG/chroma.html
When the fields of SMPTE DV-PAL are woven to interlaced frames the chroma placement is apparently different from MPEG-2, correct?
While MPEG-2 is a well known standard, where is SMPTE DV-PAL used? PAL TV broadcast? x265 field encoding?
How does avisynth convert the fields of a HUFFYUV 4:2:2 (YUY2) capture to interlaced 4:2:0 frames? According to the 'ChromaOutPlacement' parameter in ConvertToYV12(interlaced=true,ChromaOutPlacement=" xx")?
Just curious.Last edited by Sharc; 20th May 2021 at 05:45. Reason: Typo
Similar Threads
-
Question about color SMPTE color bars test patterns
By Videogamer555 in forum DVB / IPTVReplies: 11Last Post: 23rd Jan 2021, 06:38 -
Ad placement on front page seems off for me.
By gll99 in forum FeedbackReplies: 5Last Post: 22nd Oct 2020, 00:43 -
Help needed ASAP with color issue (Background same color as shirt talent)
By marciano999 in forum EditingReplies: 0Last Post: 13th Jul 2020, 11:40 -
Change in advertising placement?
By usually_quiet in forum FeedbackReplies: 5Last Post: 25th Feb 2020, 14:16 -
Elapsed time info placement in VLC media player
By rowjekto in forum Software PlayingReplies: 1Last Post: 3rd May 2018, 11:40