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

牽著老婆滿街逛

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

Image Stride (Windows)

轉(zhuǎn)載自: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 楊粼波 閱讀(965) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲欧美中文另类| 欧美jizz19hd性欧美| 夜夜精品视频一区二区| 欧美激情欧美狂野欧美精品| 亚洲日本在线视频观看| 91久久夜色精品国产网站| 久久三级视频| 亚洲精品一线二线三线无人区| 欧美高潮视频| 欧美国产三区| 亚洲一区三区在线观看| 亚洲欧洲av一区二区三区久久| 国产欧美精品在线观看| 久久一区中文字幕| 老司机成人网| 亚洲一区二区在| 午夜精品久久久久久99热| 一区免费在线| 亚洲日本欧美在线| 国产麻豆午夜三级精品| 男女av一区三区二区色多| 欧美另类69精品久久久久9999| 亚洲一区高清| 欧美中文字幕不卡| 日韩视频在线观看一区二区| 亚洲性视频h| 亚洲电影免费观看高清完整版在线| 最新日韩在线视频| 国产婷婷色一区二区三区四区| 欧美激情视频在线播放| 国产精品私房写真福利视频| 你懂的一区二区| 国产精品久久中文| 亚洲国产精品成人一区二区| 国产精品一区二区三区乱码| 亚洲福利在线观看| 国产日韩精品在线| 亚洲乱码国产乱码精品精| 国产一区二区看久久| 亚洲人午夜精品| 一区免费视频| 欧美一区二区成人6969| 一本久久精品一区二区| 麻豆精品传媒视频| 久久九九99| 欧美性事在线| 亚洲美女黄色| 亚洲精品一区二区在线观看| 久久精品国产精品 | 欧美77777| 久久精品在线播放| 国产精品永久在线| 亚洲美女免费视频| 亚洲精品偷拍| 久久在线免费| 久久夜色精品亚洲噜噜国产mv| 国产精品久久久久久久久久久久| 欧美激情在线狂野欧美精品| 伊人激情综合| 久久精品视频在线观看| 久久精品人人做人人爽| 国产人久久人人人人爽| 国产精品99久久久久久久久| 一个色综合av| 欧美女激情福利| 亚洲日本成人在线观看| 99国产一区| 欧美日韩国产综合久久| 亚洲日本欧美日韩高观看| 91久久国产综合久久91精品网站| 久久综合亚洲社区| 欧美激情一区二区三区全黄| 亚洲日本电影| 欧美精品亚洲| 在线一区二区日韩| 性高湖久久久久久久久| 国产精品美女久久久浪潮软件| 一区二区三区免费网站| 香蕉成人久久| 国产一区二区三区高清| 久久亚洲二区| 91久久在线| 午夜精品一区二区三区在线视| 国产精品嫩草影院av蜜臀| 午夜精品99久久免费| 久久视频一区| 亚洲精品午夜精品| 欧美三级乱人伦电影| 亚洲一级二级| 麻豆精品传媒视频| 9久草视频在线视频精品| 国产精品久久久久av| 午夜激情久久久| 欧美国产日韩免费| 亚洲女同在线| 激情综合色综合久久综合| 欧美xart系列在线观看| 日韩视频一区二区三区在线播放| 午夜精品久久久久久久久久久久| 国产一区日韩欧美| 欧美激情在线免费观看| 亚洲欧美一区二区精品久久久| 美女网站久久| 亚洲欧美日韩天堂一区二区| 在线观看亚洲精品视频| 欧美色另类天堂2015| 久久久久免费| 亚洲视频第一页| 欧美国产一区二区| 欧美一区二区啪啪| 91久久精品国产91久久性色tv| 欧美乱妇高清无乱码| 久久精品国产99| 中文无字幕一区二区三区| 欧美超级免费视 在线| 亚洲欧美国产一区二区三区| 亚洲精品1区2区| 黄色免费成人| 国产目拍亚洲精品99久久精品| 欧美大胆成人| 久久久久久久性| 性做久久久久久| 一本高清dvd不卡在线观看| 欧美a级在线| 久久疯狂做爰流白浆xx| 中国成人在线视频| 亚洲人久久久| 亚洲国产视频一区二区| 国内精品99| 国产日韩欧美高清免费| 欧美手机在线视频| 欧美日韩不卡| 欧美激情中文不卡| 女主播福利一区| 猛男gaygay欧美视频| 久久伊人亚洲| 久久精品一区二区| 欧美在线播放| 久久国产视频网站| 欧美专区第一页| 欧美怡红院视频| 欧美综合77777色婷婷| 性做久久久久久免费观看欧美| 亚洲一二区在线| 亚洲永久精品大片| 午夜亚洲视频| 欧美一区二区三区免费观看 | 欧美一区二区三区四区在线观看| 在线一区日本视频| 日韩一区二区精品葵司在线| 亚洲精品影院在线观看| 亚洲精品视频在线| 99视频有精品| 亚洲欧美日韩一区二区| 羞羞视频在线观看欧美| 欧美一区二区| 久久免费精品日本久久中文字幕| 久久精品官网| 欧美18av| 日韩午夜在线播放| 亚洲一区二区三区在线| 性做久久久久久| 久久中文字幕导航| 欧美激情第3页| 国产精品伦理| 好吊色欧美一区二区三区视频| 尤物九九久久国产精品的分类| 亚洲国产成人精品久久久国产成人一区| 亚洲国产精品免费| 一本一本久久a久久精品综合麻豆| 一本色道久久综合| 午夜欧美不卡精品aaaaa| 久久gogo国模啪啪人体图| 久色婷婷小香蕉久久| 亚洲狠狠丁香婷婷综合久久久| 99re热精品| 欧美在线视频免费| 欧美国产精品一区| 国产精品一区=区| 亚洲第一主播视频| 亚洲影院污污.| 欧美成人午夜影院| 亚洲天堂av在线免费| 久久久999国产| 欧美日韩一区二区三区四区五区 | 狼人天天伊人久久| 欧美涩涩视频| 在线观看日产精品| 亚洲在线第一页| 欧美黄色小视频| 亚洲欧美日韩国产综合| 欧美v日韩v国产v| 国产区欧美区日韩区| 日韩一区二区精品| 久久综合狠狠综合久久综合88| 亚洲美女黄色| 免费亚洲一区二区| 国产日韩欧美综合精品| 日韩视频一区二区三区在线播放免费观看 | 日韩视频不卡中文|