How to find out resolution and count of frames in YUV 4:2:0 file?

こ雲淡風輕ζ 提交于 2019-11-28 07:49:55

YUV 4:2:0 planar looks like this:

----------------------
|     Y      | Cb|Cr |
----------------------

where:

Y = width x height pixels (bytes)
Cb = Y / 4 pixels (bytes)
Cr = Y / 4 pixels (bytes)

Total num pixels (bytes) = width * height * 3 / 2

This is how pixels are placed in 4:2:0 sub-sampling:

As you can see, each chroma value is shared between 4 luma-pixels.

Basically, the only thing you can do is to see which frame-sizes divides the total file-size evenly.

As an example, consider the classic forman-clip, which you can download from http://trace.eas.asu.edu/yuv/foreman/foreman_cif.7z

The size of that clip is 45619200 bytes. How do one get the dimensions and number of frames from that? Try different resolutions!

is it SDTV?

In [7]: 45619200 / float(720*576*3/2)
Out[7]: 73.33333333333333

nope!

is it QCIF?

In [8]: 45619200 / float(176*144*3/2)
Out[8]: 1200.0

might be...

is it CIF?

In [9]: 45619200 / float(352*288*3/2)
Out[9]: 300.0

might be...

Only way to find out is trying to display it.

Let's try QCIF

that doesn't look right. Lets try CIF

Bingo!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!