首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >视频帧C++的Y和UV分离

视频帧C++的Y和UV分离
EN

Stack Overflow用户
提问于 2020-08-04 05:04:14
回答 1查看 594关注 0票数 0

我正在接收一个用GstVideoFrame编写的gstreamer元素的C++结构中的视频帧。

帧采用YUV420 NV12格式。

在这个gstreamer元素中,我试图在单独的缓冲区中复制y帧和uv帧。

根据videolan.org,YUV420 NV12数据存储在传入帧缓冲区中:(从网站复制的信息)

代码语言:javascript
复制
NV12:

Related to I420, NV12 has one luma "luminance" plane Y and one plane with U and V values interleaved.

In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.

For a 2×2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.

It can be helpful to think of NV12 as I420 with the U and V planes interleaved.

Here is a graphical representation of NV12. Each letter represents one bit:

    For 1 NV12 pixel: YYYYYYYY UVUV
    For a 2-pixel NV12 frame: YYYYYYYYYYYYYYYY UVUVUVUV
    For a 50-pixel NV12 frame: Y×8×50 (UV)×2×50
    For a n-pixel NV12 frame: Y×8×n (UV)×2×n

但我似乎无法计算缓冲区中y数据和uv数据的偏移量。

Update_1 :我有帧的高度和宽度来计算y-数据和uv-数据的大小,如下:

代码语言:javascript
复制
y_size = width * height;
uv_size = y_size / 2;

如对此有任何帮助或评论,将不胜感激。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-13 02:03:37

多亏了@Ext3h,我才能将y数据和uv数据从传入的YUV帧中分离出来。

代码语言:javascript
复制
y_data = (u8 *)GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
uv_data =(u8 *)GST_VIDEO_FRAME_PLANE_DATA (in_frame, 1);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63240547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档