gstreamer文档中的RU4是什么意思

问题描述 投票:0回答:1
  • “RGB”RGB
       +--+--+--+ +--+--+--+
       |R0|G0|B0| |R1|G1|B1| ...
       +--+--+--+ +--+--+--+

        Component 0: R
          depth:           8
          pstride:         3
          offset:          0

        Component 1: G
          depth:           8
          pstride:         3
          offset:          1

        Component 2: B
          depth            8
          pstride:         3
          offset:          2

        Image
          default rstride: RU4 (width * 3)
          default size:    rstride (image) * height

以上是RGB格式的格式。但我不明白。 我有一个 RGB 格式的 GstBuffer。并使用其信息进行调试:

auto caps = gst_sample_get_caps(sample);
GstVideoFrame cuda_frame;
GstVideoInfo info;
gst_video_info_from_caps(&info, caps);
gst_video_frame_map(&cuda_frame, &info, buffer, (GstMapFlags) (GST_MAP_READ | GST_MAP_CUDA));
spdlog::debug("n components: {}, n plane: {}, frame size: {}, frame width: {}, frame height: {}",
    GST_VIDEO_FRAME_N_COMPONENTS(&cuda_frame),
    GST_VIDEO_FRAME_N_PLANES(&cuda_frame),
    GST_VIDEO_FRAME_SIZE(&cuda_frame),
    GST_VIDEO_FRAME_WIDTH(&cuda_frame),
    GST_VIDEO_FRAME_HEIGHT(&cuda_frame)
);
for (size_t i = 0; i < GST_VIDEO_FRAME_N_COMPONENTS(&cuda_frame); i++)
{
    spdlog::debug("[component {}] depth: {}, width: {}, height: {}, offset: {}, stride: {}, plane: {}, poffset: {}, pstride: {}",
        i,
        GST_VIDEO_FRAME_COMP_DEPTH(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_WIDTH(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_HEIGHT(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_OFFSET(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_STRIDE(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_PLANE(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_POFFSET(&cuda_frame, i),
        GST_VIDEO_FRAME_COMP_PSTRIDE(&cuda_frame, i)
    );
}
for (size_t i = 0; i < GST_VIDEO_FRAME_N_PLANES(&cuda_frame); i++)
{
    spdlog::debug("[plane {}] offset: {}, stride: {}",
        i,
        GST_VIDEO_FRAME_PLANE_OFFSET(&cuda_frame, i),
        GST_VIDEO_FRAME_PLANE_STRIDE(&cuda_frame, i)
    );
}
n components: 3, n plane: 1, frame size: 150528, frame width: 224, frame height: 224
[component 0] depth: 8, width: 224, height: 224, offset: 0, stride: 1024, plane: 0, poffset: 0, pstride: 3
[component 1] depth: 8, width: 224, height: 224, offset: 1, stride: 1024, plane: 0, poffset: 1, pstride: 3
[component 2] depth: 8, width: 224, height: 224, offset: 2, stride: 1024, plane: 0, poffset: 2, pstride: 3

可以解释一下 RU4 在这里的意思吗? pstride 和 rstride 是什么? 我知道组件的意思是通道,比如R、G、B。但是组件的offset、stride、plane、poffset和pstride是什么意思呢? 我认为我的缓冲区大小应该是 224 * 224 * 3 = 150528。帧大小实际上是 150528。但是缓冲区大小是 224 * 224 * 4 = 229376。为什么?

video gstreamer
1个回答
0
投票

pstride
是我认为的像素步长。
3
所以一个像素占用 3 个字节(R、G 和 B)。

stride
是每行的大小(以字节为单位)。是
1024
。这意味着每个像素行总共占用
1024
字节。

对于

224
的宽度,这意味着该行的像素数据占用
224 x 3 = 672
字节。行步幅为
1024
,这意味着在使用
672
字节后,该行还剩下
1024 - 672 = 352
字节。

这些

352
字节不包含图像数据(并且可能根本不包含有用的数据)。因此,每一行基本上都从每个步幅值的边界开始。

附注

224×224×4 = 200704
。我希望你的缓冲区是
stride x height
所以
1024 * 224 = 229376

© www.soinside.com 2019 - 2024. All rights reserved.