locked
how to use "Color Converter DSP" for change IYUV into NV12? RRS feed

  • Question

  • hi all,

    I want to change IYUV into NV12, but it used highly CPU resources if do it in software, so I want to use HW convert, such as "Color Converter DSP" or "VideoProcessorMFT", can anyone give me advise or detail document or sample?

    Thanks

    Jackic


    one work one gain!

    Thursday, December 20, 2012 10:09 AM

All replies

  • This works for me:

    hr = m_pYuYtoI420.CoCreateInstance(CLSID_CColorConvertDMO);

    hr = ConnectYUY2ToI420(m_pMjpgDecoder, m_pYuYtoI420);

    HRESULT CTopoBuilder::ConnectYUY2ToI420(IMFTransform* pMft1, IMFTransform* pMft2)
    {
    HRESULT hr = S_OK;
    CComPtr<IMFMediaType> pMediaType;
    DWORD mft1OutputStreamId = 0;
    DWORD mft2InputStreamId = 0;

    DWORD mft1TypeIndex = 0;

    do
    {
    BREAK_ON_NULL(pMft1, E_UNEXPECTED);
    BREAK_ON_NULL(pMft2, E_UNEXPECTED);

    // loop through all of the avialable output types exposed by the upstream MFT, and
    // try each of them as the input type of the downstream MFT.
    while(true)
    {
    pMediaType = NULL;

    // get the type with the mftTypeIndex index from the upstream MFT
    hr = pMft1->GetOutputAvailableType(mft1OutputStreamId, mft1TypeIndex++, &pMediaType);
    BREAK_ON_FAIL(hr);

    // if we succeeded, set the output type on the upstream component
    hr = pMft1->SetOutputType(mft1OutputStreamId, pMediaType, 0);
    BREAK_ON_FAIL(hr);

    IMFMediaType* pOutType;
    MFCreateMediaType(&pOutType);
    hr = pOutType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
    hr = pOutType->SetGUID(MF_MT_SUBTYPE, MEDIASUBTYPE_I420);

    hr = pMft2->SetOutputType(mft2InputStreamId, pOutType, 0);
    hr = pMft2->SetInputType(mft2InputStreamId, pMediaType, 0);

    if(SUCCEEDED(hr))
    {
    break;
    }
    }
    BREAK_ON_FAIL(hr);
    }
    while(false);

    return hr;
    }

    CComPtr<IMFTopologyNode> pYuYtoI420Node;
    hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &pYuYtoI420Node);
    BREAK_ON_FAIL(hr);
    // set the output stream ID on the stream sink topology node
    hr = pYuYtoI420Node->SetObject(m_pYuYtoI420);
    BREAK_ON_FAIL(hr);
    m_pTopology->AddNode(pYuYtoI420Node);

    pSourceNode->ConnectOutput(0, pMjpgNode, 0);
    pMjpgNode->ConnectOutput(0, pYuYtoI420Node, 0);
    pYuYtoI420Node->ConnectOutput(0, pEncoderNode, 0);

    Have fun

    Saturday, December 22, 2012 5:46 AM
  • hi atelyshev,

    thanks for your reply,

    but I try this way, it cannot color convert, I do this function color convert in video decoder, and herein donot create TopoloyNode, if you do it successfully, could you share me sample code.

    thanks in advance.

    Jackic 


    one work one gain!


    • Edited by Jackic Thursday, February 21, 2013 8:56 AM modified
    Monday, December 24, 2012 3:45 AM
  • Well,

    I am confused, as far as I understand you have for instance one MFT (or source) that produces samples in IYUV and another MFT (or sink) that accepts NV12. Correct? 

    In this case code that I showed should work (look at hr code BTW). Actually you have 2 ways, one let topobuilder guess what should be done and second just build topo yourself, look this example, probably best one Microsoft was able to make:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ee663624(v=vs.85).aspx

    book 

    Developing Microsoft Media Foundation Applications helps as well. And if your code is not very long just insert it here.

    Regards

    Aleksey

    Sunday, December 30, 2012 5:45 AM