使用MFT组件在Windows Phone 8.1 RT(XAML)中裁剪视频

时间:2014-11-07 18:58:15

标签: c# c++ windows-phone-8.1 video-processing ms-media-foundation

在WP 8.1 RT中使用MFT时遇到问题:裁剪视频从480 x 640到480 x 480(删除左右区域,不要将它们拉伸到新的比例)。我从Media extension sample倾斜并尝试修改灰度过滤器以使其完成工作,但由于我在C ++和MF编程中的限制而失败。任何人都可以通过指出一般指导如何删除不需要的像素并更改输出视频帧大小来帮助我吗?我做了研究,发现了一些使用Video Processor MFT或Video Resizer DSP的技巧(不适用于WP编程)。但我没有理解如何在WP项目中包含或使用它们。

以下是我在灰度滤镜中的修改代码:

// Convert NV12 image

void TransformImage_NV12(
const D2D_RECT_U &rcDest,
_Inout_updates_(_Inexpressible_(2 * lDestStride * dwHeightInPixels)) BYTE *pDest,
_In_ LONG lDestStride,
_In_reads_(_Inexpressible_(2 * lSrcStride * dwHeightInPixels)) const BYTE *pSrc,
_In_ LONG lSrcStride,
_In_ DWORD dwWidthInPixels,
_In_ DWORD dwHeightInPixels,
_In_ int EffectValue)
{
// NV12 is planar: Y plane, followed by packed U-V plane.

// Y plane
for (DWORD y = 0; y < dwHeightInPixels; y++)
{
    if (y < dwHeightInPixels / 2)
        CopyMemory(pDest, pSrc, dwWidthInPixels);
    pDest += lDestStride;
    pSrc += lSrcStride;
}

// U-V plane

// NOTE: The U-V plane has 1/2 the number of lines as the Y plane.

// Lines above the destination rectangle.
DWORD yn = 0;
const DWORD y0 = min(rcDest.bottom, dwHeightInPixels);

// Lines within the destination rectangle.
// 128 = 256/2 => fill this value to memory of U V plane to make grayscale the effect
for (; yn < y0 / 2; yn++)
{
    //CopyMemory(pDest, pSrc, rcDest.left);
    if (yn < y0 / 4)
        CopyMemory(pDest, pSrc, dwWidthInPixels);
    //FillMemory(pDest + rcDest.left, rcDest.right - rcDest.left, EffectValue);
    //CopyMemory(pDest + rcDest.right, pSrc + rcDest.right, dwWidthInPixels - rcDest.right);
    pDest += lDestStride;
    pSrc += lSrcStride;
}
}

它产生的视频只有顶部,底部填充绿色。

0 个答案:

没有答案