网络上的解释:
When a video image is stored in memory, the memory buffer might contain extra padding bytes after each row of pixels. The padding bytes affect how the image is stored in memory, but do not affect how the image is displayed.
The stride is the number of bytes from one row of pixels in memory to the next row of pixels in memory. Stride is also called pitch. If padding bytes are present, the stride is wider than the width of the image, as shown in the following illustration.

Two buffers that contain video frames with equal dimensions can have two different strides. If you process a video image, you must take the stride into account.
In addition, there are two ways that an image can be arranged in memory. In a top-down image, the top row of pixels in the image appears first in memory. In a bottom-up image, the last row of pixels appears first in memory. The following illustration shows the difference between a top-down image and a bottom-up image.

A bottom-up image has a negative stride, because stride is defined as the number of bytes need to move down a row of pixels, relative to the displayed image. YUV images should always be top-down, and any image that is contained in a Direct3D surface must be top-down. RGB images in system memory are usually bottom-up.
Video transforms in particular need to handle buffers with mismatched strides, because the input buffer might not match the output buffer. For example, suppose that you want to convert a source image and write the result to a destination image. Assume that both images have the same width and height, but might not have the same pixel format or the same image stride.
一些疑问:
上面讲的应该是告诉我们要注意有这么个概念存在,可是为什么当初要引进stride这个概念呢?恐怕这是实际运用的时候遇到的,搜索了一下,有一种观点是“字节对齐”,例子中讲的是按照4字节对齐,我们知道,一行中有n个像素,每个像素占用m个字节来存储,那么一行有效数据的大小将在内存中占用n x m 个字节,这样的一行存在内存中,如果本身nm的值不是4的倍数,内存存取的效率会打折扣,这个字节对齐在很多地方应用,都是为了存取的效率问题,就是不知道这样理解是否是stride引进的原意?待确定,望游者留言讨论。
本文深入探讨了图像技术中的stride概念,包括其引入背景、作用以及如何影响图像处理过程。通过实例分析,解释了stride与字节对齐的关系,强调了其对内存管理和图像处理效率的重要性。

2041

被折叠的 条评论
为什么被折叠?



