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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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>
            亚洲尤物视频网| 国产精品乱码一区二三区小蝌蚪| 亚洲第一免费播放区| 欧美在线亚洲| 久久这里只精品最新地址| 久色婷婷小香蕉久久| 欧美黄色小视频| 日韩天天综合| 亚洲欧美一区二区激情| 香蕉久久国产| 老司机67194精品线观看| 欧美激情视频在线免费观看 欧美视频免费一 | 一区二区亚洲精品| 国产美女精品在线| 国产一区二区欧美| 亚洲国产人成综合网站| 亚洲一区久久| 欧美成人精精品一区二区频| 日韩小视频在线观看| 午夜精品亚洲| 欧美精品激情在线观看| 国产欧美日本在线| 亚洲免费观看在线视频| 欧美中文在线字幕| 亚洲国产小视频在线观看| 亚洲午夜电影网| 能在线观看的日韩av| 国产精品综合网站| 日韩一区二区高清| 久久久久一区| 亚洲视频一区二区在线观看 | 久久成人精品视频| 亚洲电影视频在线| 欧美影片第一页| 欧美性片在线观看| 亚洲日本va午夜在线电影| 久久精品国产一区二区三区免费看| 亚洲欧洲精品一区二区三区波多野1战4 | 国产精品亚洲а∨天堂免在线| 国模私拍一区二区三区| 亚洲一区三区电影在线观看| 亚洲国产成人精品女人久久久 | 激情综合色丁香一区二区| 亚洲午夜精品久久久久久浪潮| 毛片av中文字幕一区二区| 午夜精品久久久久久久男人的天堂| 欧美日产在线观看| 亚洲免费av观看| 亚洲第一色在线| 老**午夜毛片一区二区三区| 国外视频精品毛片| 久久久www| 欧美在线视频观看免费网站| 国产欧美日韩免费| 久久国产精品高清| 欧美在线一二三四区| 国产欧美日韩精品在线| 亚洲免费视频在线观看| 欧美视频一区二区三区| 你懂的国产精品| 欧美一区免费| 国产日韩视频| 麻豆精品精华液| 久久久爽爽爽美女图片| 精品电影一区| 欧美风情在线观看| 欧美电影电视剧在线观看| 亚洲精品在线看| 亚洲理论在线观看| 欧美色播在线播放| 午夜亚洲性色福利视频| 午夜精品区一区二区三| 国产日韩高清一区二区三区在线| 欧美亚洲日本网站| 欧美影院久久久| 在线观看的日韩av| 亚洲国产成人在线| 国产精品v片在线观看不卡| 午夜一区二区三视频在线观看 | 久久综合给合久久狠狠色| 亚洲国产精选| 一区二区三区视频在线观看| 国产色视频一区| 亚洲电影免费在线| 国产精品日韩高清| 欧美成人免费在线观看| 欧美日韩性视频在线| 欧美综合国产精品久久丁香| 久久久久五月天| 一区二区三区国产| 久久都是精品| 亚洲精品中文字幕在线| 亚洲无线一线二线三线区别av| 国产亚洲观看| 亚洲国产视频a| 国产女精品视频网站免费| 亚洲电影下载| 国产亚洲精品自拍| 亚洲美女视频在线观看| 好吊妞这里只有精品| av成人老司机| 亚洲国产精品嫩草影院| 亚洲性感美女99在线| 亚洲精品免费在线| 久久九九免费视频| 午夜在线成人av| 欧美日韩视频在线一区二区观看视频 | 久久资源av| 欧美一区1区三区3区公司| 欧美激情精品久久久久| 久久亚洲欧美| 国产农村妇女精品| 亚洲深夜福利| 一区二区三区精品视频在线观看| 久久黄色级2电影| 欧美一区二区三区在线视频 | 亚洲欧洲日韩综合二区| 香蕉成人伊视频在线观看 | 欧美四级在线| 亚洲盗摄视频| 国产一区二区精品久久| 一区二区精品在线| 日韩亚洲欧美在线观看| 久热精品在线视频| 快播亚洲色图| 激情久久久久久久| 久久精品国产视频| 久久久久综合网| 国内外成人免费激情在线视频网站| 亚洲综合成人婷婷小说| 亚洲专区一二三| 国产精品久久久久国产精品日日 | 欧美日本高清| 亚洲国产精品精华液网站| 亚洲大胆在线| 免费亚洲一区| 亚洲国产精品成人久久综合一区| 在线精品国精品国产尤物884a| 久久精品国产精品| 欧美69wwwcom| 亚洲片在线资源| 欧美精品在线视频| 99精品国产99久久久久久福利| 一本到12不卡视频在线dvd | 亚洲全部视频| 欧美激情精品久久久久久久变态| 亚洲国产黄色| 亚洲无毛电影| 国产亚洲精品久久久久久| 久久精品国产一区二区电影| 久久久一二三| 亚洲精品视频免费观看| 欧美日韩亚洲网| 午夜精品www| 欧美凹凸一区二区三区视频| 亚洲美女精品久久| 国产精品男人爽免费视频1| 欧美在线观看一区| 亚洲国产精品成人va在线观看| 亚洲手机在线| 国产综合一区二区| 欧美黄色免费| 亚洲欧美日韩一区在线观看| 久久综合一区二区| 一区二区欧美日韩| 狠狠色综合网站久久久久久久| 欧美电影在线观看| 亚洲欧美日本视频在线观看| 免费不卡视频| 午夜精品999| 亚洲国产精品久久久久秋霞不卡 | 午夜精品久久久久久99热软件| 老司机午夜免费精品视频| 亚洲精品乱码| 国产一区二区久久| 欧美精品在线观看播放| 久久精品视频一| 亚洲人成在线观看网站高清| 午夜欧美视频| 一区二区三区国产在线| 欧美不卡一卡二卡免费版| 亚洲日本成人| 国产日韩在线播放| 欧美视频在线一区| 巨乳诱惑日韩免费av| 一区二区三区日韩| 亚洲国产第一| 久久久久女教师免费一区| 一区二区精品在线观看| 亚洲成人在线观看视频| 国产日韩欧美不卡| 国产精品白丝av嫩草影院| 裸体一区二区三区| 久久精品国产999大香线蕉| av成人免费观看| 亚洲人成人一区二区三区| 免费欧美视频| 久久综合九色九九| 久久精品国产v日韩v亚洲| 亚洲欧美日韩天堂|