none
IMFTransform NV12 to RGB24 RRS feed

  • Question

  • Hello there!
    My camera natively provides data in NV12 and I need to do some conversion to RGB24. I am trying to do so by MFT.

    			IMFActivate **transformActivateArray = NULL;
    			UINT32 MFTcount;
    			hr = MFTEnumEx(MFT_CATEGORY_VIDEO_PROCESSOR, MFT_ENUM_FLAG_ALL, inputVideoTypes, outputVideoTypes, &transformActivateArray, &MFTcount);
    			if (FAILED(hr))
    			{
    				exit(3);
    			}		
    			if (MFTcount == 0)
    				exit(7);
    			IMFTransform **VP = new IMFTransform*[MFTcount];
    			for (DWORD i = 0; i < MFTcount; i++)
    			{
    				hr = transformActivateArray[i]->ActivateObject(__uuidof(IMFTransform), (void**)&VP[i]);
    			}
    			DWORD* inputCount = new DWORD[MFTcount];
    			DWORD* outputCount = new DWORD[MFTcount];
    			for (DWORD i = 0; i < MFTcount; i++)
    			{
    				hr = VP[i]->GetStreamCount(&inputCount[i], &outputCount[i]);
    			}
    			DWORD **inputids = new DWORD*[MFTcount];
    			DWORD **outputids = new DWORD*[MFTcount];
    			for (DWORD i = 0; i < MFTcount; i++)
    			{
    				inputids[i] = new DWORD[inputCount[i]];
    				outputids[i] = new DWORD[outputCount[i]];
    			}
    			for (DWORD i = 0; i < MFTcount; i++)
    			{
    				VP[i]->GetStreamIDs(inputCount[i], inputids[i], outputCount[i], outputids[i]);
    				if (FAILED(hr))
    					exit(5);
    			}		
    			DWORD flag1 = -1;
    			DWORD flag2 = -1;
    			for (DWORD i = 0; i < MFTcount; i++)
    			{
    				for (DWORD j = 0; j < inputCount[i]; j++)
    				{
    					hr = VP[i]->GetInputAvailableType(0, 0, &streamType);
    					if (SUCCEEDED(hr)) 
    					{
    						flag1 = i;
    						flag2 = j;
    						break;
    					}
    				}
    			}
    			if (flag1 == -1 && flag2 == -1)
    				exit(2);
    			
    
    			hr = VP[0]->SetInputType(0, streamType2, 0);
    			hr = VP[0]->GetOutputAvailableType(0, 0, &streamType3);
    			hr = VP[0]->SetOutputType(0, streamType3, 0);
    			hr = VP[0]->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL);
    			hr = VP[0]->ProcessInput(0, sample, 0);
    			DWORD flags4;
    			hr = VP[0]->GetOutputStatus(&flags4);
    			while (flags4 == 0)
    			{
    				VP[0]->ProcessInput(0, sample, 0);
    			}

    Currently it looks like this. streamType2 is gotten earlier by:

    hr = sourceReader->GetNativeMediaType(MF_SOURCE_READER_FIRST_VIDEO_STREAM, i, &streamType2);

    The problem is that SetOutput method returns: cannot find a demanged attribute, and I dont really get, what is wrong.
    Can anyone point where I am doing things bad way?
    Thank you



    • Moved by litdev Friday, July 6, 2018 12:14 PM
    Thursday, July 5, 2018 9:53 PM

Answers

All replies