tags:

views:

437

answers:

1

I got a raw YUV file format all I know at this point is that the clip has a resolution of 176x144.

the Y pla is 176x144=25344 bytes, and the UV plan is half of that. Now, I did some readings about YUV, and there are different formats corresponding to different ways how the Y & US planes are stored.

Now, how can perform some sort of check in Cocoa to find the raw YUV file format. Is there a file header in the YUV frame where I can extract some information?

Thanks in advance to everyone

+2  A: 

Unfortunately, if it's just a raw YUV stream, it will just be the data for the frames written to disk, one after another. There probably won't be a header that indicates what specific format is being used.

It sounds like you have determined that it's a YUV 4:2:2 stream, so you just need to determine the interleaving order (the most common possibilities are listed here). In response to your previous question, I posted a function which converts a frame from the UYVY (Y422) YUV format to the 2VUY format used by Apple's YUV OpenGL extension. Your best bet may be to try that out and see how the images look, then modify the interleaving format until the colors and image clears up.

Brad Larson
sounds good, thanks a lot
ReachConnection
I just found out that my YUV format is NV12. any recommendations for next step?
ReachConnection
That looks to be a little trickier, because it's a planar format, not interleaved (according to the first link in my answer). You could modify my posted function to read all the Y values first, and put them in the right places within the output 2VUY frame, then go back and fill in the U (Cb) and V (Cr) values. Because it's a 4:2:0 instead of a 4:2:2 frame, each U and V value is used for two rows, in addition to being used for two columns: http://v4l2spec.bytesex.org/spec/r5470.htm
Brad Larson