颜色转换器 DSP 的 IMFTransform 接口在 SetInputType/SetOutputType 上给出 E_INVALIDARG [英] IMFTransform interface of Color Converter DSP giving E_INVALIDARG on SetInputType/SetOutputType

查看:24
本文介绍了颜色转换器 DSP 的 IMFTransform 接口在 SetInputType/SetOutputType 上给出 E_INVALIDARG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用颜色转换器 DMO (http://msdn.microsoft.com/en-us/library/windows/desktop/ff819079(v=vs.85).aspx) 通过媒体基金会将 RBG24 转换为 YV12/NV12.我已经通过 CLSID_CColorConvertDMO 创建了一个 Color Converter DSP 实例,然后尝试设置所需的输入/输出类型,但即使使用由 GetOutputAvailableType 返回的媒体类型,调用也始终返回 E_INVALIDARG>GetInputAvailableType.如果我将媒体类型设置为 NULL 然后我得到媒体类型无效的错误,这是有道理的.我看过来自 MSDN 的示例,其中人们做同样的事情 - 枚举可用类型,然后将它们设置为输入类型 - 他们声称它有效,但我有点卡在 E_INVALIDARG 上.我知道没有代码示例很难回答这个问题,如果没有人有过类似的经历,我会尝试发布一个片段,但也许有人遇到过同样的问题?

I'm trying to use Color Converter DMO (http://msdn.microsoft.com/en-us/library/windows/desktop/ff819079(v=vs.85).aspx) to convert RBG24 to YV12/NV12 via Media Foundation. I've created an instance of Color Converter DSP via CLSID_CColorConvertDMO and then tried to set the needed input/output types, but the calls always return E_INVALIDARG even when using media types that are returned by GetOutputAvailableType and GetInputAvailableType. If I set the media type to NULL then i get the error that the media type is invalid, that makes sense. I've seen examples from MSDN, where people do the same - enumerate available types and then set them as input types - and they claim it works, but i'm kinda stuck on the E_INVALIDARG. I understand that this is hard to answer without a code example, if no one has had similar experience, I'll try to post a snipplet, but maybe someone has experienced the same issue?

推荐答案

此 DMO/DSP 是双接口的,既是带有 IMediaObject 的 DMO,又是带有 IMFTransform 的 MFT.这两个接口有很多共同点,下面是一段代码片段,用于测试 RGB24 到 YV12 转换的初始化:

This DMO/DSP is dual interfaced and is both a DMO with IMediaObject and an MFT with IMFTransform. The two interfaces share a lot common, and here is a code snippet to test initialization of RGB24 into YV12 conversion:

#include "stdafx.h"
#include <dshow.h>
#include <dmo.h>
#include <wmcodecdsp.h>

#pragma comment(lib, "strmiids.lib")
#pragma comment(lib, "wmcodecdspuuid.lib")

int _tmain(int argc, _TCHAR* argv[])
{
    ATLVERIFY(SUCCEEDED(CoInitialize(NULL)));
    CComPtr<IMediaObject> pMediaObject;
    ATLVERIFY(SUCCEEDED(pMediaObject.CoCreateInstance(CLSID_CColorConvertDMO)));
    VIDEOINFOHEADER InputVideoInfoHeader;
    ZeroMemory(&InputVideoInfoHeader, sizeof InputVideoInfoHeader);
    InputVideoInfoHeader.bmiHeader.biSize = sizeof InputVideoInfoHeader.bmiHeader;
    InputVideoInfoHeader.bmiHeader.biWidth = 1920;
    InputVideoInfoHeader.bmiHeader.biHeight = 1080;
    InputVideoInfoHeader.bmiHeader.biPlanes = 1;
    InputVideoInfoHeader.bmiHeader.biBitCount = 24;
    InputVideoInfoHeader.bmiHeader.biCompression = BI_RGB;
    InputVideoInfoHeader.bmiHeader.biSizeImage = 1080 * (1920 * 3);
    DMO_MEDIA_TYPE InputMediaType;
    ZeroMemory(&InputMediaType, sizeof InputMediaType);
    InputMediaType.majortype = MEDIATYPE_Video;
    InputMediaType.subtype = MEDIASUBTYPE_RGB24;
    InputMediaType.bFixedSizeSamples = TRUE;
    InputMediaType.bTemporalCompression = FALSE;
    InputMediaType.lSampleSize = InputVideoInfoHeader.bmiHeader.biSizeImage;
    InputMediaType.formattype = FORMAT_VideoInfo;
    InputMediaType.cbFormat = sizeof InputVideoInfoHeader;
    InputMediaType.pbFormat = (BYTE*) &InputVideoInfoHeader;
    const HRESULT nSetInputTypeResult = pMediaObject->SetInputType(0, &InputMediaType, 0);
    _tprintf(_T("nSetInputTypeResult 0x%08x\n"), nSetInputTypeResult);
    VIDEOINFOHEADER OutputVideoInfoHeader = InputVideoInfoHeader;
    OutputVideoInfoHeader.bmiHeader.biBitCount = 12;
    OutputVideoInfoHeader.bmiHeader.biCompression = MAKEFOURCC('Y', 'V', '1', '2');
    OutputVideoInfoHeader.bmiHeader.biSizeImage = 1080 * 1920 * 12 / 8;
    DMO_MEDIA_TYPE OutputMediaType = InputMediaType;
    OutputMediaType.subtype = MEDIASUBTYPE_YV12;
    OutputMediaType.lSampleSize = OutputVideoInfoHeader.bmiHeader.biSizeImage;
    OutputMediaType.cbFormat = sizeof OutputVideoInfoHeader;
    OutputMediaType.pbFormat = (BYTE*) &OutputVideoInfoHeader;
    const HRESULT nSetOutputTypeResult = pMediaObject->SetOutputType(0, &OutputMediaType, 0);
    _tprintf(_T("nSetOutputTypeResult 0x%08x\n"), nSetOutputTypeResult);
    // TODO: ProcessInput, ProcessOutput
    pMediaObject.Release();
    CoUninitialize();
    return 0;
}

这应该可以正常工作并打印出两个 S_OK...

This should work fine and print two S_OKs out...

这篇关于颜色转换器 DSP 的 IMFTransform 接口在 SetInputType/SetOutputType 上给出 E_INVALIDARG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆