0

I have a input.yuv image which I wants to use in my code as a input.

But I want to know whether it is 422,420 or 444 format and also wants to know whether it is planner and packed and what is its width, height and stride.

When I saw this image using https://rawpixels.net/ tool, I can see the perfect image with gray scale with dimensions 1152x512. But when I do with yuv420p or other options, the color and luma components are not with correct offset and hence showing the mixture of color and gray scale image with different offset(2 images in same screen).

Is there any way to write a C code to find above mentioned yuv details (dimensions, formats and types) ?

  • There undoubtedly is a way to do it — programs that interpret `.yuv` files do it, so there must be a way to do it. You've studied Wikipedia on [YUV](https://en.wikipedia.org/wiki/YUV), I assume. What was the problem with encoding (or decoding) the information? (I can guess, but…) Did you look on Stack Overflow? Google says there are quite a number of relevant questions (I searched using "yuv image format" as the search term). – Jonathan Leffler Jul 01 '21 at 06:20
  • "The .yuv file format is a convention - you can't be sure what does contain". See [YUV file format](https://stackoverflow.com/questions/5194285/yuv-file-format). – Rotem Jul 01 '21 at 20:14

1 Answers1

0

Not really. Files with a .yuv extension just contain raw pixel data normally in a planar format.

That would typically be width * height of luma pixels followed by either width/2height/2 (420) or widthheight/2 (422) Cb and Cr components.

They cam be 8 or 10 bits per pixel with 10 bits per pixel usually stored in 2 bytes. It's just really a case of trial and error to find out what it is.

Occasionally you find all sorts of arrangements of Y, Cb, Cr in files with a .yuv extension. Planar is most common though.