9

i have captured video using AVFoundation .i have set (video setting )and get in outputsamplebuffer kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange format. But i need YUV420 format for further processing .

My doubt is

1.difference among 420YpCbCr8BiPlanarVideoRange,420YpCbCr8BiPlanarFULLRange, 420YpCbCr8PlanarFullRange,420YpCbCr8Planar and YUV420 ?
2.how can i convert 420YpCbCr8BiPlanarVideoRange to YUV420 ?
3. How to Convert YUV420 To 32BGRA ?

4) or some other Way to do this??? that is Any open source library or Apple Framework....

i have gone through Accelerate framework ...... it has image conversion for following planar8,planerF,RGBA8888 etc... Any way to equal those formats with 32BGRA/YUV420/ 420YpCbCr8BiPlanarVideoRange and Do my requirement?????

Thanks in advance

thanks in advance

Vasu Ashok
  • 1,413
  • 3
  • 17
  • 37
  • 2) I think 420YpCbCr8BiPlanarVideoRange is NV12, and YUV420 is I420. To convert from NV12 to I420, you should use libyuv. It is also used for I420 -> BGRA – onmyway133 Jun 13 '13 at 15:47

1 Answers1

33

The main differences are:

If you have a biplanar format, then the Y data (luminance) and the CbCr data (chroma or color information) are in two separate memory areas called planes. You can use CVPixelBufferGetBaseAddressOfPlane with index 0 to get the Y data and index 1 to get the CbCr data. If the format is planar, then both kinds of data are in the same plane (first all the Y values, then all Cb values and finally the Cr values).

If you have a full range format, then the values from 0 to 255 are used for each luma or chroma value. Video range format only use values from 16 to 235 (for some historical reasons).

The term 420 indicates how much luma and how much chroma information the format contains. It basically says that there is luma information for each pixel and chroma information for each 2x2 block.

YUV420 is - as far as I can tell - not a precisely specified format. It is often use for a planar YpCbCr 420 format.

Codo
  • 75,595
  • 17
  • 168
  • 206
  • 1
    @codo ,Thanks Lot detailed Explanation .+1 for that . One more small doubt . Then kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange and YUV 420 are same write???? – Vasu Ashok Jun 11 '11 at 09:32
  • @Codo:: Whether Possible Way to convert Biplaner to planer?. Because my codec need YUV420 planer but i have biplanner format. Accelerate frameworking image conversion library have option for planer. Whether it ll useful for me? – Vasu Ashok Jun 11 '11 at 11:07
  • @Asta ni enohpi: What has happend to the third question about the YUV420 fomat? Have you deleted it (together with my answer)? – Codo Jun 11 '11 at 18:43
  • @Codo:UnKnowingly Deleted While Edit my Question.Due to poor network Couldn't Rollback – Vasu Ashok Jun 12 '11 at 04:49
  • 2
    Turning the biplanar image format into a planar is simply: just copy the two planes into a single memory block. The planar format is just the concatenation of the luma and the chroma plane. But I'm still not sure what target format you need: YUV420 is simply not a precise description. And while I've given you a lot of information about image formats, I've the impression you in fact need a video format. Please post as much details about the target format as possible. – Codo Jun 12 '11 at 08:14
  • THANKS Codo, all most my blocks are clear Concept wise . i am very new to image processing .Sorry bcoz of all my unclear silly Questions .Actually My Requirement:Need to pass YUV420 to VP8 codec to encode/decode process and at the end convert YUV420 (Codec output)into 32BGRA to render in view .Now i ll convert biplanar to planar as your way but before that i ll alloc memory for that buffer right? Shall i set size as h*W*3? and then ll point out 2 planes memory to single memory .Forgive me anything Wrong – Vasu Ashok Jun 12 '11 at 09:01
  • If you want BGRA, ask for BGRA. I wrote a function to convert the various YUV formats to BGRA for error-reporting purposes (the iPhone 3G supports 422 "yuvs" and "2vuy" instead of 420v), but it's *really slow*. – tc. Jun 18 '11 at 15:23