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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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>
            国产一区再线| 欧美国产一区二区三区激情无套| 亚洲国产高清高潮精品美女| 国内精品一区二区| 激情五月综合色婷婷一区二区| 欧美亚州一区二区三区| 欧美日本一区二区三区| 欧美日韩一区三区四区| 亚洲一区二区三区777| 亚洲女人天堂成人av在线| 亚洲精品综合精品自拍| 欧美国产先锋| 久久这里只有精品视频首页| 欧美国产欧美亚洲国产日韩mv天天看完整| 国产精品亚洲激情| 久久精品99国产精品| 欧美中在线观看| 亚洲精选一区| 国产精品一区久久| 欧美高清影院| 久久九九热re6这里有精品| 欧美在线免费播放| 久久亚洲精品中文字幕冲田杏梨| 欧美大片一区二区| 亚洲午夜电影在线观看| 老司机成人在线视频| 国产精品草莓在线免费观看| 伊人色综合久久天天| 亚洲午夜av| 欧美大胆a视频| 欧美一区二区三区精品| 欧美日韩大陆在线| 极品尤物av久久免费看| 亚洲综合日韩| 亚洲国产日韩一级| 亚洲免费在线精品一区| 欧美日韩国产经典色站一区二区三区| 国产亚洲欧美一区| 亚洲性感激情| 亚洲人成在线观看一区二区| 久久久精品国产免费观看同学| 欧美日韩精品一区二区| 亚洲人成人一区二区在线观看| 久久不射2019中文字幕| 在线视频精品一区| 欧美日韩另类字幕中文| 亚洲伦理在线| 亚洲二区在线| 欧美国产激情| 亚洲乱码国产乱码精品精天堂| 久久综合九色综合网站| 午夜精品成人在线视频| 国产精品毛片在线| 亚洲一区制服诱惑| 亚洲色图自拍| 国产精品视频999| 午夜精品国产精品大乳美女| 亚洲精品网址在线观看| 欧美精品成人一区二区在线观看| 尤妮丝一区二区裸体视频| 久久久久久电影| 欧美一激情一区二区三区| 国产精品制服诱惑| 久久国产88| 久久精品网址| 在线成人av网站| 亚洲第一精品福利| 欧美激情偷拍| 在线综合亚洲| 性18欧美另类| 在线电影一区| 亚洲第一在线| 亚洲图中文字幕| 亚洲亚洲精品三区日韩精品在线视频| 欧美视频一区二区三区…| 亚洲女人天堂av| 亚洲欧美在线网| 极品日韩久久| 最新日韩av| 国产精品人人做人人爽人人添| 欧美一级日韩一级| 久久精品久久99精品久久| 91久久午夜| 在线视频精品一| 伊人男人综合视频网| 亚洲精品婷婷| 国产婷婷色一区二区三区在线 | 久久深夜福利| 日韩香蕉视频| 午夜精品成人在线| 亚洲精品一区在线观看| 亚洲在线第一页| 亚洲国产欧美一区二区三区久久| 亚洲日韩第九十九页| 国产私拍一区| 夜夜嗨av一区二区三区四季av| 国产精品日韩欧美一区| 欧美激情在线有限公司| 国产精品看片资源| 亚洲国产成人午夜在线一区| 国产精品免费观看视频| 欧美激情一区二区三区在线视频| 国产精品老牛| 亚洲精选中文字幕| 亚洲国产日韩在线一区模特| 亚洲欧美国产另类| 一区二区三区视频在线看| 久久久久久午夜| 欧美一区二区三区免费视频 | 狠狠色丁香久久综合频道| 亚洲片区在线| ●精品国产综合乱码久久久久| 一本色道久久88综合日韩精品| 亚洲国产精品福利| 久久精品99无色码中文字幕| 午夜欧美精品| 欧美四级在线观看| 亚洲日本一区二区三区| 亚洲福利视频网站| 久久精品最新地址| 久久久久在线| 国内成+人亚洲| 亚洲综合欧美日韩| 亚洲欧美偷拍卡通变态| 欧美色道久久88综合亚洲精品| 亚洲电影免费观看高清完整版| 国产亚洲精品aa午夜观看| 亚洲一区亚洲| 欧美一区二区三区另类| 国产精品制服诱惑| 亚洲欧美日韩在线不卡| 欧美一区二区国产| 国产精品女人久久久久久| 亚洲午夜精品网| 欧美在线一二三区| 久久se精品一区二区| 久久精品在这里| 国产一区二区三区电影在线观看 | 亚洲国产精品久久91精品| 久久视频在线看| 亚洲福利在线观看| 日韩午夜在线播放| 欧美日韩午夜激情| 亚洲影院色无极综合| 久久精品av麻豆的观看方式| 国产午夜久久久久| 久久婷婷国产综合尤物精品| 欧美成人在线影院| 日韩一级裸体免费视频| 国产精品夫妻自拍| 欧美亚洲在线播放| 亚洲福利av| 亚洲综合欧美日韩| 国产综合网站| 欧美国产精品劲爆| 亚洲一区二区欧美日韩| 久久亚洲精选| 日韩一级黄色片| 国产女精品视频网站免费 | 久久综合久久综合九色| 亚洲国产精品黑人久久久| 在线亚洲一区| 国产一区二区三区四区老人| 欧美bbbxxxxx| 亚洲一区久久久| 女同一区二区| 亚洲已满18点击进入久久| 国产亚洲成年网址在线观看| 欧美va日韩va| 欧美一区二区日韩一区二区| 亚洲激情成人| 久久噜噜噜精品国产亚洲综合| 亚洲免费精品| 激情成人综合| 国产精品毛片大码女人| 欧美电影免费观看大全| 欧美在线3区| 亚洲图色在线| 亚洲人成绝费网站色www| 久久精品久久99精品久久| 99ri日韩精品视频| 怡红院精品视频在线观看极品| 欧美日韩亚洲综合一区| 久久亚洲欧洲| 欧美一区=区| 亚洲午夜精品久久久久久app| 欧美高清你懂得| 久久久国产精彩视频美女艺术照福利| 亚洲精品国精品久久99热一| 国产一区二区三区电影在线观看| 欧美精品一区在线| 老**午夜毛片一区二区三区| 亚欧成人在线| 亚洲一区二区成人在线观看| 亚洲人成在线免费观看| 欧美va天堂va视频va在线| 久久精品一区二区三区不卡牛牛| 亚洲影院在线观看| 亚洲先锋成人| 亚洲夜间福利|