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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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>
            亚洲日韩第九十九页| 亚洲区一区二| 亚洲欧美激情视频在线观看一区二区三区| 欧美aⅴ99久久黑人专区| 久久久午夜精品| 亚洲国产精品成人综合色在线婷婷| 久久亚洲春色中文字幕| 久久婷婷人人澡人人喊人人爽 | 亚洲精品你懂的| 美女久久一区| 一区二区国产日产| 亚洲一区二区毛片| 激情亚洲网站| 亚洲成色www久久网站| 欧美日韩高清区| 欧美一区二区在线观看| 久久久99精品免费观看不卡| 亚洲人久久久| 午夜电影亚洲| 亚洲日本va在线观看| 亚洲视频在线观看免费| 激情婷婷欧美| 日韩写真视频在线观看| 国产原创一区二区| 亚洲日本va午夜在线电影| 国产麻豆日韩欧美久久| 欧美激情精品久久久久久免费印度| 欧美理论在线播放| 久久不射网站| 欧美日韩国产a| 久热精品视频| 国产精品三级视频| 亚洲国产精品成人| 国产欧美一区二区精品性| 亚洲经典在线看| 一区二区亚洲精品国产| 亚洲一区二区三区在线播放| 亚洲高清在线观看| 亚洲综合二区| 亚洲线精品一区二区三区八戒| 久久成人综合网| 亚洲欧美视频在线观看| 欧美激情91| 欧美顶级大胆免费视频| 韩国一区二区在线观看| 亚洲视频免费在线观看| 日韩视频在线观看一区二区| 久久精品在线观看| 久久久久久久一区二区三区| 欧美日精品一区视频| 亚洲大胆美女视频| 一色屋精品视频在线观看网站| 亚洲亚洲精品三区日韩精品在线视频 | 91久久综合亚洲鲁鲁五月天| 激情五月婷婷综合| 欧美专区第一页| 午夜精品久久久久久99热| 欧美日韩中国免费专区在线看| 欧美成人免费小视频| 精品成人国产| 久久精品国产一区二区三| 久久精品国产亚洲aⅴ| 国产精品影片在线观看| 亚洲午夜av在线| 午夜精品久久久久| 国产欧美大片| 欧美一进一出视频| 久久久久久综合| 黑人操亚洲美女惩罚| 久久成人免费日本黄色| 久久亚洲一区| 亚洲国产精品久久久久婷婷老年| 久久久蜜桃一区二区人| 欧美大片va欧美在线播放| 亚洲黄色天堂| 欧美日韩系列| 亚洲制服av| 另类激情亚洲| 亚洲欧洲一区二区三区久久| 欧美激情四色| 亚洲一区二区视频在线| 久久成人免费日本黄色| 一区二区三区中文在线观看| 美日韩精品免费观看视频| 最新成人在线| 羞羞视频在线观看欧美| 精久久久久久久久久久| 欧美大片91| 亚洲自拍都市欧美小说| 麻豆freexxxx性91精品| 亚洲精品国产系列| 国产精品美女主播| 久久免费视频这里只有精品| 亚洲精品在线三区| 久久久久国内| 日韩一级成人av| 国产视频久久| 欧美日韩999| 先锋亚洲精品| 亚洲激情婷婷| 久久久精品国产免大香伊| 亚洲美女中文字幕| 国产日韩精品一区二区三区| 免费欧美电影| 性欧美暴力猛交69hd| 亚洲国产欧美在线人成| 久久国产精品久久精品国产| 亚洲伦理在线| 国产主播一区二区三区| 欧美日韩亚洲高清| 男人的天堂亚洲| 午夜欧美视频| 欧美色网在线| 老司机午夜精品| 欧美夜福利tv在线| 99这里只有久久精品视频| 欧美国产日韩在线| 久久精品网址| 亚洲欧美综合精品久久成人| 亚洲精品在线免费观看视频| 国产午夜精品全部视频在线播放| 欧美精品18+| 久久综合九色综合欧美就去吻| 亚洲一区二区3| 日韩视频免费在线| 亚洲国产视频a| 欧美大片在线观看| 久久女同互慰一区二区三区| 欧美一进一出视频| 亚洲性视频网址| 亚洲美女色禁图| 亚洲精品久久久蜜桃| 亚洲高清av在线| 伊人久久大香线蕉av超碰演员| 国产欧美一区二区精品仙草咪 | 欧美一级专区| 午夜国产精品视频| 亚洲欧美成aⅴ人在线观看| 一区二区三区|亚洲午夜| 亚洲精品久久久久久久久久久久久 | 欧美一区二区性| 性欧美8khd高清极品| 午夜精品美女久久久久av福利| 99国产精品久久久久老师| 亚洲精选视频在线| 亚洲美女淫视频| 夜夜嗨av一区二区三区四季av| 亚洲人成人一区二区三区| 亚洲日本欧美| 亚洲精品一区二区三区不| 亚洲毛片在线看| 一区二区三区欧美亚洲| 亚洲先锋成人| 欧美一区二区三区免费大片| 欧美在线一级视频| 可以看av的网站久久看| 欧美第十八页| 亚洲狼人综合| 亚洲天堂成人在线观看| 亚洲欧美日韩一区在线观看| 欧美专区第一页| 久久尤物视频| 欧美日韩视频在线观看一区二区三区 | 性高湖久久久久久久久| 久久久久久久波多野高潮日日| 久久婷婷国产麻豆91天堂| 欧美久久精品午夜青青大伊人| 欧美日韩国产成人在线观看| 欧美性猛交99久久久久99按摩| 国产精品亚洲产品| 在线免费不卡视频| 亚洲视频在线观看视频| 久久国产精品久久国产精品| 欧美暴力喷水在线| 一区二区三区四区五区精品| 先锋影音久久| 欧美黑人在线播放| 国产欧美一区二区三区久久| 亚洲电影中文字幕| 亚洲欧美一区二区视频| 免播放器亚洲| 亚洲天堂av高清| 美女视频黄免费的久久| 国产精品乱子久久久久| 亚洲国产精品专区久久| 性欧美在线看片a免费观看| 欧美日韩在线观看一区二区| 国内偷自视频区视频综合| 日韩一二三在线视频播| 久久嫩草精品久久久久| 在线一区二区日韩| 免费成人在线观看视频| 国产精品视频网| 日韩视频中文| 欧美gay视频| 欧美诱惑福利视频| 欧美网站在线观看| 亚洲毛片在线观看.| 免费视频亚洲| 久久激情综合|