VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. Member
    Join Date
    May 2007
    Location
    United Kingdom
    Search Comp PM
    Hi guys my 1st post.
    Would any of you know how to convert YUY2 to YV12 format.

    Currently I have a byte array which contains YUY2 data.
    The resolution should be 704x576.
    The byte array is of size - 811008. Should 704x576 not be 45504.

    Is there any code samples or an algorithm to do this?

    Many thanks...
    Al.
    Quote Quote  
  2. I think you meant to type 405504 but YUY2 is two bytes per pixel. 704*576*2 = 811008.

    YUY2 to YV12 is pretty simple. You should be able to figure it out from information at fourcc.org:

    http://fourcc.org/yuv.php

    Be sure to take into account interlacing if your output will be interlaced YV12.
    Quote Quote  
  3. Member
    Join Date
    May 2007
    Location
    United Kingdom
    Search Comp PM
    Ok so if I have these YUY2 bytes - YUYV YUYV
    If I convert them to YV12 bytes should I have YYYYVU?
    Quote Quote  
  4. Not exactly. YV12 is a planar format. You'll end up with three arrays, one of Y at the full resolution, followed by one of the V at half (both dimensions) resolution, and one of the U at half resolution.

    four YUY2 pixels (2x2 array):

    Code:
    Y(0,0) U(0,0) Y(0,1) V(0,0)
    Y(1,0) U(1,0) Y(1,1) V(1,0)
    to four YV12 pixels (2x2 array + 1x1 array + 1x1 array):

    Code:
    Y(0,0) Y(0,1)
    Y(1,0) Y(1,1)
    
    (V(0,0) + V(1,0)) / 2
    
    (U(0,0) + U(1,0)) / 2
    Additional infor for interlaced YV12:

    http://avisynth.org/mediawiki/Sampling
    Quote Quote  
  5. Member
    Join Date
    May 2007
    Location
    United Kingdom
    Search Comp PM
    Should the last line read (U(0,0) + U(1,0)) / 2?
    Quote Quote  
  6. Yes, typo. Fixed it.
    Quote Quote  
  7. Member
    Join Date
    May 2007
    Location
    United Kingdom
    Search Comp PM
    Would I be correct in assuming that after the conversion using the above resolution of 704*576 I will have these array sizes

    Y - 405504 bytes
    V - 101376 bytes
    U - 101376 bytes
    Quote Quote  
  8. Originally Posted by allyli2007
    Would I be correct in assuming that after the conversion using the above resolution of 704*576 I will have these array sizes

    Y - 405504 bytes
    V - 101376 bytes
    U - 101376 bytes
    Yes.
    Quote Quote  
  9. Member vhelp's Avatar
    Join Date
    Mar 2001
    Location
    New York
    Search Comp PM
    Afternoon allyli2007,

    Some time ago, I did some demonstrations** of the layout and posted some raw yuv
    images of those that I engineered into the tool. It was designed only to spit out the yuv
    images in binary format. And to open or import them in video editor like AVIsynth required
    one of their plugins. It was this method that I used to test our my tool's success not to
    mention, my understanding and correct coding, etc.

    I also wrote a tiny calculator to help me understand the Luma/Chroma placement, but at
    some point, I bOrked it and haven't found the energy to fix it. Maybe I should. Hmm.. I
    remember starting out with just a simple calculation (resoution based) and got the chroma
    size, and then the chroma playcement, and then.. Well, maybe later. Anyway.

    Here's an example of something that I posted two years ago from the last response I made
    on the subject (before other things bogged me down and I went onto other things) here.

    ** The point I'm making with the image you see below is to help suggest an
    idea for you to visualize the layout using a guide. This helped me to understand what I
    was learning.

    Explanation of the illustration-- The partial (though crude) image you see below is a basic
    representation of how the YUY2 layout can look. And in this pictured view, I had
    incorporated Color Coded Cells, Numerical Position, and the Color Values used. Its
    purpose was to aid in the actual format and look, and it helped me to verify my
    progress. I had a i420 and YV12 pic too, but I can't seem to find it, though those
    two never did make it to my last post on that thread. I was so close to releasing a
    utility (that spits out the layout like the one below) but my personal life got the
    better of me.

    -vhelp 4291

    Quote Quote  



Similar Threads