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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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>
            欧美专区福利在线| 亚洲视频精品在线| 麻豆精品传媒视频| 久久久国产成人精品| 激情欧美一区| 亚洲黄网站在线观看| 免费成人黄色| 亚洲视频一区| 欧美一级理论片| 亚洲二区视频| 日韩一区二区免费高清| 国产欧美精品一区二区色综合| 久久久高清一区二区三区| 久久网站热最新地址| 一本色道久久加勒比88综合| 亚洲一区美女视频在线观看免费| 激情综合激情| 日韩一级黄色大片| 黄色在线一区| 亚洲毛片播放| 一区二区三区在线观看欧美 | 国产一区二区在线免费观看| 女女同性精品视频| 欧美视频国产精品| 女仆av观看一区| 国产精品久久久久久久9999 | 午夜精品福利在线| 欧美88av| 久久一区二区三区超碰国产精品| 欧美日韩蜜桃| 免费欧美日韩国产三级电影| 国产精品美女主播| 亚洲国产欧美在线人成| 国精品一区二区三区| 夜夜嗨av一区二区三区| 亚洲黄色免费| 久久国产精品亚洲va麻豆| 亚洲欧美日韩成人| 欧美精品www| 免费亚洲电影| 激情成人综合| 午夜视频一区在线观看| 午夜精品久久久久| 欧美精品免费在线观看| 欧美粗暴jizz性欧美20| 狠狠色狠狠色综合| 午夜日韩av| 欧美一二三视频| 欧美亚男人的天堂| 日韩视频在线观看免费| 99视频国产精品免费观看| 毛片av中文字幕一区二区| 鲁鲁狠狠狠7777一区二区| 国模一区二区三区| 欧美一区二区视频97| 久久成人综合视频| 国产乱码精品一区二区三| 亚洲系列中文字幕| 翔田千里一区二区| 国产精品一区=区| 亚洲欧美日韩一区二区在线 | 亚洲精品欧美专区| 蘑菇福利视频一区播放| 欧美激情一区二区三区蜜桃视频 | 亚洲精品日韩在线观看| 一区二区免费在线观看| 欧美日韩一级黄| 亚洲精品人人| 亚洲欧美视频在线观看视频| 国产九九精品视频| 欧美永久精品| 欧美国产欧美综合| 亚洲看片网站| 欧美视频免费| 午夜精品一区二区在线观看 | 亚洲欧美一区二区三区在线| 国产精品视频福利| 欧美一级黄色录像| 亚洲成色www久久网站| 亚洲精品综合| 国产精品久久久久久久第一福利| 亚洲欧美日韩精品| 欧美a级一区二区| 99精品久久久| 国产女精品视频网站免费| 久久久久国色av免费观看性色| 欧美国产日韩一区二区| 亚洲男人的天堂在线aⅴ视频| 国产农村妇女精品| 欧美第十八页| 午夜精品电影| 亚洲国产你懂的| 欧美中文在线免费| 亚洲经典视频在线观看| 国产精品视频网站| 蜜臀久久99精品久久久久久9| 亚洲视频在线一区观看| 蜜臀av一级做a爰片久久| 亚洲色图自拍| 黄网站色欧美视频| 欧美日韩精品一区视频| 久久国产精品99久久久久久老狼| 亚洲国产日韩在线一区模特| 亚洲尤物在线视频观看| 亚洲国产精品成人久久综合一区 | 欧美aa在线视频| 亚洲一区欧美二区| 亚洲黄色视屏| 久久亚裔精品欧美| 亚洲综合视频网| 亚洲美女电影在线| 黄色成人精品网站| 国产精品日韩精品| 欧美日韩999| 美女91精品| 久久精品亚洲| 午夜精品免费视频| 一本久道久久综合狠狠爱| 欧美激情麻豆| 久热精品视频在线观看一区| 性色av香蕉一区二区| 一区二区三区免费在线观看| 亚洲国产精品悠悠久久琪琪| 黑人巨大精品欧美一区二区小视频| 欧美视频在线视频| 欧美日本在线观看| 欧美国产激情| 麻豆精品传媒视频| 久久久欧美精品sm网站| 欧美专区在线播放| 亚洲欧美一区二区三区久久| 亚洲无线一线二线三线区别av| 一本久久综合亚洲鲁鲁五月天| 亚洲日本国产| 亚洲精品国产无天堂网2021| 欧美.日韩.国产.一区.二区| 老司机凹凸av亚洲导航| 免费亚洲电影在线| 蜜桃久久精品乱码一区二区| 麻豆freexxxx性91精品| 乱中年女人伦av一区二区| 另类av一区二区| 裸体丰满少妇做受久久99精品| 久久夜色精品国产亚洲aⅴ| 老鸭窝毛片一区二区三区| 噜噜噜久久亚洲精品国产品小说| 欧美v日韩v国产v| 亚洲成色777777女色窝| 亚洲精品日韩久久| 亚洲一区国产一区| 欧美一区二区免费| 久久久久久久97| 免费观看不卡av| 欧美区视频在线观看| 国产精品v日韩精品v欧美精品网站| 国产精品高潮呻吟久久av无限| 国产麻豆午夜三级精品| 国产自产精品| 亚洲欧洲一区二区在线观看| 一区二区三区国产| 午夜视频在线观看一区二区| 久久久亚洲精品一区二区三区| 欧美成人激情在线| 亚洲精品日韩精品| 欧美一进一出视频| 欧美激情第10页| 国产精品视频| 亚洲精品乱码久久久久久按摩观| 亚洲视频中文字幕| 久久久www成人免费毛片麻豆| 欧美激情一区二区三区| 亚洲主播在线播放| 久色成人在线| 国产精品久久久久毛片软件| 韩日在线一区| 亚洲一区二区三区激情| 欧美成人精品在线播放| 一区二区三区高清不卡| 久久久噜噜噜久久中文字免| 欧美日韩网站| 在线观看欧美日韩国产| 亚洲女同同性videoxma| 欧美激情一区二区| 性久久久久久久| 欧美日韩国产精品专区| 好看的日韩av电影| 亚洲欧美激情视频| 亚洲二区视频在线| 欧美呦呦网站| 国产精品影院在线观看| 99视频一区二区| 免费成人高清视频| 午夜精彩国产免费不卡不顿大片| 欧美日本国产| 亚洲国产精品悠悠久久琪琪| 久久久夜精品| 午夜激情一区| 国产精品日韩欧美一区二区三区 | 欧美激情国产日韩| 欧美一级免费视频|