What RUN(RU2, RU4) means in the document of Raw Video Media Types

For example

  • “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

What’s the meaning of RU4 here? I have got a raw/video buff with format RGB from nvh264dec and cudaconvertscale, I found RU4 (width * 3) == 1024. But width == 224. I don’t understand how RU4 make width * 3 == 672 become 1024

RU stands for Round Up. So, RU4 is round up to the next multiple of 4, RU8, does 8, RUN will round up to some specified power of 2.

The values you are looking at are the defaults. If you have a producer of the video frames that doesn’t follow the defaults, then you will get different values. e.g. a GPU API may like a stride that is a power of 2 (1024).

This C code will print the default stride which is 672 which also happens to equal 224 * 3

// gcc $(pkg-config --cflags gstreamer-video-1.0) test.c -o test $(pkg-config --libs gstreamer-video-1.0)
#include <gst/video/video.h>
int main(int argc, char *argv[])
{
  gst_init (&argc, &argv);
  GstVideoInfo vinfo;
  gst_video_info_set_format(&vinfo, GST_VIDEO_FORMAT_RGB, 224, 10);
  gst_println("%u", vinfo.stride[0]);
  return 0;
}
1 Like