amerkoleci / Vortice.Windows

.NET bindings for Direct3D12, Direct3D11, WIC, Direct2D1, XInput, XAudio, X3DAudio, DXC, Direct3D9 and DirectInput.
MIT License
1.01k stars 73 forks source link

Fix IMFTransform.ProcessOutput() #252

Closed manju-summoner closed 2 years ago

manju-summoner commented 2 years ago

I fixed some IMFTransform.ProcessOutput() issues.


<map param="IMFTransform::ProcessOutput::dwFlags" type="_MFT_PROCESS_OUTPUT_FLAGS"/>
<map param="IMFTransform::ProcessOutput::pdwStatus" type="_MFT_PROCESS_OUTPUT_STATUS" attribute="out"/>

Type specified to dwFlags and pdwStatus. Added out attribute to pdwStatus to make the return value available.


<map param="IMFTransform::ProcessOutput::pOutputSamples" attribute="inout"/>

Added inout attribute to pOutputSamples to get IMFSample allocated in IMFTransform. Example

var buffer = new TOutputDataBuffer();
var info = mft.GetOutputStreamInfo(0);
var flags = (OutputStreamInfoFlags)info.Flags;
if (flags.HasFlag(OutputStreamInfoFlags.OutputStreamProvidesSamples))
{
    var res = mft.ProcessOutput(ProcessOutputFlags.None, 1, ref buffer, out _);
    var sample = buffer.Sample;//IMFSample allocated in IMFTransform.
}

<map method="IMFTransform::ProcessOutput" check="false" return="true"/>

Error checking is now disabled and exceptions can be handled outside of ProcessOutput. This change reduces the amount of error messages displayed in the debug console, and prevents performance degradation due to many error messages during debugging.

Example

while(true)
{
    var res = mft.ProcessOutput(ProcessOutputFlags.None, 1, ref buffer, out _);
    if (res.Success)
        return buffer.Sample;
    else if(res.Code == MF_E_TRANSFORM_NEED_MORE_INPUT)
    {
        //Send more samples to IMFTransform
    }
    else
        throw new SharpGenException(res);
}
amerkoleci commented 2 years ago

Curios what are you working at? :)

manju-summoner commented 2 years ago

I am creating a video editing software specialized with synthetic voice. (not OSS...) https://manjubox.net/ymm4/

amerkoleci commented 2 years ago

Nice! Is it written in C#? Using Vortice.Windows?

manju-summoner commented 2 years ago

Yes. At first I used SharpDX, but now I use Vortice.Windows. I have recently been working on updating the version of Vortice.Windows used in my product from 1.9.143 to 2.1.x.