青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

Image Stride (Windows)

轉載自:http://msdn.microsoft.com/zh-cn/library/windows/desktop/aa473780(v=vs.85).aspx

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.

Diagram showing an image plus padding.

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.

Diagram showing top-down and bottom-up images.

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.

The following example code shows a generalized approach for writing this kind of function. This is not a complete working example, because it abstracts many of the specific details.

void ProcessVideoImage(
    BYTE*       pDestScanLine0,     
    LONG        lDestStride,        
    const BYTE* pSrcScanLine0,      
    LONG        lSrcStride,         
    DWORD       dwWidthInPixels,     
    DWORD       dwHeightInPixels
    )
{
    for (DWORD y = 0; y < dwHeightInPixels; y++)
    {
        SOURCE_PIXEL_TYPE *pSrcPixel = (SOURCE_PIXEL_TYPE*)pDestScanLine0;
        DEST_PIXEL_TYPE *pDestPixel = (DEST_PIXEL_TYPE*)pSrcScanLine0;

        for (DWORD x = 0; x < dwWidthInPixels; x +=2)
        {
            pDestPixel[x] = TransformPixelValue(pSrcPixel[x]);
        }
        pDestScanLine0 += lDestStride;
        pSrcScanLine0 += lSrcStride;
    }
}

This function takes six parameters:

  • A pointer to the start of scan line 0 in the destination image.
  • The stride of the destination image.
  • A pointer to the start of scan line 0 in the source image.
  • The stride of the source image.
  • The width of the image in pixels.
  • The height of the image in pixels.

The general idea is to process one row at a time, iterating over each pixel in the row. Assume that SOURCE_PIXEL_TYPE and DEST_PIXEL_TYPE are structures representing the pixel layout for the source and destination images, respectively. (For example, 32-bit RGB uses the RGBQUAD structure. Not every pixel format has a predefined structure.) Casting the array pointer to the structure type enables you to access the RGB or YUV components of each pixel. At the start of each row, the function stores a pointer to the row. At the end of the row, it increments the pointer by the width of the image stride, which advances the pointer to the next row.

This example calls a hypothetical function named TransformPixelValue for each pixel. This could be any function that calculates a target pixel from a source pixel. Of course, the exact details will depend on the particular task. For example, if you have a planar YUV format, you must access the chroma planes independently from the luma plane; with interlaced video, you might need to process the fields separately; and so forth.

To give a more concrete example, the following code converts a 32-bit RGB image into an AYUV image. The RGB pixels are accessed using an RGBQUAD structure, and the AYUV pixels are accessed using a DXVA2_AYUVSample8 structure structure.

//-------------------------------------------------------------------
// Name: RGB32_To_AYUV
// Description: Converts an image from RGB32 to AYUV
//-------------------------------------------------------------------
void RGB32_To_AYUV(
    BYTE*       pDest,
    LONG        lDestStride,
    const BYTE* pSrc,
    LONG        lSrcStride,
    DWORD       dwWidthInPixels,
    DWORD       dwHeightInPixels
    )
{
    for (DWORD y = 0; y < dwHeightInPixels; y++)
    {
        RGBQUAD             *pSrcPixel = (RGBQUAD*)pSrc;
        DXVA2_AYUVSample8   *pDestPixel = (DXVA2_AYUVSample8*)pDest;
        
        for (DWORD x = 0; x < dwWidthInPixels; x++)
        {
            pDestPixel[x].Alpha = 0x80;
            pDestPixel[x].Y = RGBtoY(pSrcPixel[x]);   
            pDestPixel[x].Cb = RGBtoU(pSrcPixel[x]);   
            pDestPixel[x].Cr = RGBtoV(pSrcPixel[x]);   
        }
        pDest += lDestStride;
        pSrc += lSrcStride;
    }
}

The next example converts a 32-bit RGB image to a YV12 image. This example shows how to handle a planar YUV format. (YV12 is a planar 4:2:0 format.) In this example, the function maintains three separate pointers for the three planes in the target image. However, the basic approach is the same as the previous example.

void RGB32_To_YV12(
    BYTE*       pDest,
    LONG        lDestStride,
    const BYTE* pSrc,
    LONG        lSrcStride,
    DWORD       dwWidthInPixels,
    DWORD       dwHeightInPixels
    )
{
    assert(dwWidthInPixels % 2 == 0);
    assert(dwHeightInPixels % 2 == 0);

    const BYTE *pSrcRow = pSrc;
    
    BYTE *pDestY = pDest;

    // Calculate the offsets for the V and U planes.

    // In YV12, each chroma plane has half the stride and half the height  
    // as the Y plane.
    BYTE *pDestV = pDest + (lDestStride * dwHeightInPixels);
    BYTE *pDestU = pDest + 
                   (lDestStride * dwHeightInPixels) + 
                   ((lDestStride * dwHeightInPixels) / 4);

    // Convert the Y plane.
    for (DWORD y = 0; y < dwHeightInPixels; y++)
    {
        RGBQUAD *pSrcPixel = (RGBQUAD*)pSrcRow;
        
        for (DWORD x = 0; x < dwWidthInPixels; x++)
        {
            pDestY[x] = RGBtoY(pSrcPixel[x]);    // Y0
        }
        pDestY += lDestStride;
        pSrcRow += lSrcStride;
    }

    // Convert the V and U planes.

    // YV12 is a 4:2:0 format, so each chroma sample is derived from four 
    // RGB pixels.
    pSrcRow = pSrc;
    for (DWORD y = 0; y < dwHeightInPixels; y += 2)
    {
        RGBQUAD *pSrcPixel = (RGBQUAD*)pSrcRow;
        RGBQUAD *pNextSrcRow = (RGBQUAD*)(pSrcRow + lSrcStride);

        BYTE *pbV = pDestV;
        BYTE *pbU = pDestU;

        for (DWORD x = 0; x < dwWidthInPixels; x += 2)
        {
            // Use a simple average to downsample the chroma.

            *pbV++ = ( RGBtoV(pSrcPixel[x]) +
                       RGBtoV(pSrcPixel[x + 1]) +       
                       RGBtoV(pNextSrcRow[x]) +         
                       RGBtoV(pNextSrcRow[x + 1]) ) / 4;        

            *pbU++ = ( RGBtoU(pSrcPixel[x]) +
                       RGBtoU(pSrcPixel[x + 1]) +       
                       RGBtoU(pNextSrcRow[x]) +         
                       RGBtoU(pNextSrcRow[x + 1]) ) / 4;    
        }
        pDestV += lDestStride / 2;
        pDestU += lDestStride / 2;
        
        // Skip two lines on the source image.
        pSrcRow += (lSrcStride * 2);
    }
}

In all of these examples, it is assumed that the application has already determined the image stride. You can sometimes get this information from the media buffer. Otherwise, you must calculate it based on the video format. For more information about calculating image stride and working with media buffers for video, see Uncompressed Video Buffers.

Related topics

Video Media Types
Media Types

posted on 2013-01-25 10:07 楊粼波 閱讀(951) 評論(0)  編輯 收藏 引用

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            影音先锋日韩有码| 美女精品在线| 欧美精品www| 欧美一级播放| 悠悠资源网亚洲青| 黄色一区二区在线| 亚洲特级片在线| 中国女人久久久| 最新亚洲视频| 欧美不卡高清| 伊甸园精品99久久久久久| 欧美一二三视频| 亚洲六月丁香色婷婷综合久久| 久久人人九九| 精品88久久久久88久久久| 久久久久女教师免费一区| 国内成人在线| 亚洲精品一区二区三区福利| 久久人人九九| 久久久久91| 一区二区三区亚洲| 久久躁日日躁aaaaxxxx| 久久不见久久见免费视频1| 国产乱码精品| 午夜精品在线视频| 一区二区三区免费在线观看| 久久成人综合视频| 国户精品久久久久久久久久久不卡| 欧美一级淫片播放口| 亚洲男人天堂2024| 国产一级久久| 麻豆91精品| 欧美第十八页| 亚洲桃花岛网站| 亚洲一区二区在线观看视频| 国产日韩欧美在线播放不卡| 在线亚洲国产精品网站| 亚洲午夜高清视频| 午夜日韩视频| 精品电影一区| 亚洲激情成人在线| 国产精品网站在线| 久久精品视频99| 免费亚洲一区二区| 在线亚洲欧美| 久久久国产一区二区三区| 亚洲人成网站在线播| 在线亚洲一区二区| 国产精品久久久久免费a∨| 亚洲女性裸体视频| 久久精品女人| 一本一本久久a久久精品综合麻豆| 午夜一区在线| 亚洲伊人色欲综合网| 亚洲大胆女人| 亚洲视频图片小说| 亚洲国产精品久久精品怡红院| 日韩亚洲一区在线播放| 国产综合色在线| 亚洲精品久久久久中文字幕欢迎你 | 久久青草欧美一区二区三区| 欧美福利影院| 久久久女女女女999久久| 欧美理论视频| 欧美专区中文字幕| 欧美视频日韩视频在线观看| 欧美xxxx在线观看| 国产精品爽爽爽| 亚洲第一偷拍| 国产精品免费视频xxxx| 亚洲电影中文字幕| 精品999在线播放| 亚洲影音先锋| 宅男在线国产精品| 亚洲一区二区三区精品在线| 久久精品国产在热久久| 欧美一区二视频| 午夜久久久久久| 在线一区二区三区四区五区| 欧美诱惑福利视频| 国产一区二区三区在线观看精品 | 最近看过的日韩成人| 国产无一区二区| 久久精品国产成人| 欧美视频免费看| 久久婷婷av| 国产综合视频在线观看| 牛人盗摄一区二区三区视频| 国产日韩在线播放| 亚洲国产欧美日韩| 亚洲精品国产欧美| 欧美va亚洲va国产综合| 一区免费在线| 久久精品国产69国产精品亚洲| 欧美一级久久久久久久大片| 国产伦精品一区二区三区四区免费| 亚洲人成网在线播放| 一级成人国产| 欧美日韩一区二区免费视频| 日韩视频在线你懂得| 在线视频一区观看| 国产精品卡一卡二卡三| 亚洲一区国产精品| 国产一区二区在线免费观看 | 欧美亚洲成人精品| 中文在线不卡| 欧美中文在线视频| 牛人盗摄一区二区三区视频| 欧美a级片网站| 国产精品青草久久久久福利99| 一本色道久久综合亚洲精品婷婷| 中文网丁香综合网| 国产精品专区一| 久久久另类综合| 欧美国产精品人人做人人爱| 亚洲国产精品va在线看黑人 | 欧美 日韩 国产在线| 亚洲人成啪啪网站| 欧美午夜激情小视频| 亚洲伊人久久综合| 久久久亚洲高清| 亚洲人成网站精品片在线观看| 免费高清在线一区| 亚洲婷婷免费| 欧美成人精品影院| 中日韩美女免费视频网址在线观看 | 久久激情婷婷| 激情婷婷欧美| 欧美精品日韩精品| 欧美一区二区三区久久精品茉莉花 | 99re8这里有精品热视频免费 | 国产欧美日韩激情| 亚洲午夜精品网| 老牛国产精品一区的观看方式| 亚洲国产视频直播| 蜜乳av另类精品一区二区| 99精品视频免费| 免费视频亚洲| 亚洲一区在线观看免费观看电影高清| 国产日本欧洲亚洲| 欧美成人免费网| 性做久久久久久久久| 亚洲黄色有码视频| 久久亚洲精品欧美| 亚洲影视中文字幕| 欧美午夜理伦三级在线观看| 久久久久久久性| 欧美激情 亚洲a∨综合| 欧美伊人影院| 亚洲性xxxx| 日韩天堂在线观看| 亚洲缚视频在线观看| 国产一区二区久久精品| 欧美三区在线| 欧美福利视频| 久久久xxx| 欧美在线观看你懂的| 亚洲一区在线看| 免费看的黄色欧美网站| 好看不卡的中文字幕| 欧美第一黄网免费网站| 蜜臀av在线播放一区二区三区| 久久国内精品视频| 欧美一区二区在线| 亚洲一区日韩| 一本色道久久综合精品竹菊| 亚洲精品影视在线观看| 亚洲啪啪91| 午夜精品影院在线观看| 亚洲一区免费视频| 一区二区三区国产在线| 亚洲国产婷婷香蕉久久久久久99| 欧美视频四区| 欧美日韩国产影片| 欧美日韩一区二区免费视频| 欧美激情性爽国产精品17p| 欧美成人伊人久久综合网| 中日韩高清电影网| 亚洲最黄网站| 噜噜噜91成人网| 免费成人毛片| 亚洲电影第1页| 亚洲精品乱码久久久久久蜜桃麻豆 | 国内久久视频| 狠狠久久亚洲欧美专区| 国产综合欧美在线看| 亚洲成人直播| 亚洲欧洲在线视频| 在线视频你懂得一区| 午夜天堂精品久久久久| 久久久久国产精品www| 欧美jjzz| 亚洲精品美女在线观看播放| 99精品视频免费观看| 亚洲性视频网站| 亚洲人成网在线播放| 久久成人精品一区二区三区| 国产精品素人视频| 亚洲午夜国产成人av电影男同| 亚洲国产精品一区制服丝袜 |