VideoHelp Forum
+ Reply to Thread
Results 1 to 18 of 18
Thread
  1. 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.
    Last edited by Sharc; 14th May 2021 at 03:34.
    Quote Quote  
  2. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Not sure what you mean by color placement. You can open the media file in mediainfo, text view, gives all kinds of details
    Quote Quote  
  3. (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")
      XXX = MPEG1/MPEG2/DV
      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
    (similar can be done when converting to YV12)

    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)
    Looking at the images and the sandbox, you can see that only the 'DV' chroma placement has no misalignment.
    I think the main problem is to spot the problem. So if there are easier ways to do this let me know.

    Cu Selur
    Image Attached Thumbnails Click image for larger version

Name:	DV.png
Views:	48
Size:	489.4 KB
ID:	58858  

    Click image for larger version

Name:	MPEG1.png
Views:	43
Size:	484.8 KB
ID:	58859  

    Click image for larger version

Name:	MPEG2.png
Views:	38
Size:	487.0 KB
ID:	58860  

    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  4. 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.
    Quote Quote  
  5. and it's not a big issue when it is set incorrectly.
    Whether it's an easily noticeable issue or not mainly depends on the content.
    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
    Quote Quote  
  6. 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.
    So I understand that this applies for HUFFYUV 4:2:2 (interlaced capture) as well. It corresponds to "DV" chroma placement


    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.
    Interlaced 4:2:0, oh well .....
    Quote Quote  
  7. Member Skiller's Avatar
    Join Date
    Oct 2013
    Location
    Germany
    Search PM
    Originally Posted by Sharc View Post
    So I understand that this applies for HUFFYUV 4:2:2 (interlaced capture) as well. It corresponds to "DV" chroma placement
    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.
    Quote Quote  
  8. 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 Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  9. 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.
    Quote Quote  
  10. Thanks everybody for the comments.

    Originally Posted by Skiller View Post
    In my experience and humble opinion, all capture devices outputting 4:2:2 (UYVY, YUYV, YUY2) use MPEG2 chroma placement.
    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)
    Image Attached Files
    Quote Quote  
  11. Member Skiller's Avatar
    Join Date
    Oct 2013
    Location
    Germany
    Search PM
    Originally Posted by Sharc View Post
    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.
    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.
    Quote Quote  
  12. Originally Posted by Skiller View Post
    Originally Posted by Sharc View Post
    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.
    I don't seem to get that result. I get differences everywhere in the resulting video (no completely gray frames at all).
    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").
    Noted. I thought that I should set 'interlaced=false' for the separated fields. When I change it to 'true' I am getting a non-grey output for "DV" as well.

    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
    Quote Quote  
  13. 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" guessing
    Last edited by _Al_; 18th May 2021 at 17:54.
    Quote Quote  
  14. Member Skiller's Avatar
    Join Date
    Oct 2013
    Location
    Germany
    Search PM
    Originally Posted by Sharc View Post
    My Avisynth is v3.7.0 x86 (32 bit because of the HUFFYUV)
    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)
    Notes: chromaresample="Spline16" is just there to circumvent an ancient bug in YUY2<->YV12 conversions.
    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...



    Originally Posted by Sharc View Post
    I thought that I should set 'interlaced=false' for the separated fields.
    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).



    Originally Posted by Sharc View Post
    I tried to apply Selur's script but I couldn't really verify the chroma placement for this source.
    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.
    Quote Quote  
  15. Thank you for your comments.

    Originally Posted by Skiller View Post
    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.
    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.

    Originally Posted by Skiller View Post
    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).
    I see. Now this is what I am getting with your script, for interlace='false' or 'true':

    Image
    [Attachment 58978 - Click to enlarge]
    Image
    [Attachment 58979 - Click to enlarge]


    Originally Posted by Skiller View Post
    But I think you are overthinking this. Unless you have a really oddball 4:2:2 capture device, the chroma placement will be MPEG2.
    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:....'
    Quote Quote  
  16. 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
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!