平面YUV420数据布局 [英] Planar YUV420 data layout

查看:283
本文介绍了平面YUV420数据布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用 OpenH264 编解码器,据说以<$ c $输出数据c> YUV 4:2:0平面格式。解码后,我得到一个数组 width * height * 1.5 元素,在显示时,它们看起来像这样:

In my project I use OpenH264 codec, which is said to output data in the YUV 4:2:0 planar format. After decoding I get one array with width * height * 1.5 elements, which, when displaying, looks like this image:

http://o3d.googlecode。 com / svn / trunk / samples_webgl / assets / shaving_cream.png

为什么主要区域下面有四个区域(包含Y-负责灰度 - 元素),而不是两个,就像在我的第二张照片上?这是否意味着格式不同或我错了,我的世界刚刚崩溃了?

Why there are four areas below the main one (which contains Y - responsible for grayscale - elements ), instead of two, like on my second picture? Is that mean that the format is different or am I wrong and my world just collapsed?

我认为重生应该是这样的:

I thought that the resoult should have looked like this:

推荐答案

这正是你的假设。您只是忽略了在图像宽度上有一半的U和V像素。所以U数据的偶数行在左边,奇数在右边。接下来是V数据。

It is exactly the way you assume. You are just overlooking that there are half as many U and V pixels across the width of the image. So the even numbered lines of U data are on the left, the odd numbered ones on the right. Followed by the V data.

为了按照你想要的方式排列它,解码器必须交错U和V数据。它没有这样做。只是在转换为RGB之前不要开始查看图像:)

To get it arranged the way you want to look at it, the decoder would have to interleave the U and V data. It doesn't do that. Just don't start looking at the image until you converted to RGB :)

这篇关于平面YUV420数据布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆