c++ - 使用 transinplacefilter 决定分配器

标签 c++ directshow

CTransInPlaceFilter 似乎没有在其输入引脚中实现 GetAllocatorRequirements。因为尝试在上游过滤器上调用此方法时出现 E_NOTIMPL 错误。

我知道 CTransInPlace Filter 只有一个缓冲区,而不是输入和输出缓冲区。

但是我该如何在我的上游过滤器中处理这个问题呢?

如何实现 DecideAllocator 以支持 CTransInPlaceFilters? 这是我在上游过滤器中的 DecideAllocator 函数:

HRESULT MCMyOutputPin::DecideAllocator(IMemInputPin *pPin, IMemAllocator **ppAlloc)
{
    ALLOCATOR_PROPERTIES *pprops = new ALLOCATOR_PROPERTIES;
    HRESULT hr = pPin->GetAllocatorRequirements(pprops); //returns E_NOTIMPL
    if (FAILED(hr))
        return hr;
     hr = pPin->GetAllocator(ppAlloc);
    if (hr == VFW_E_NO_ALLOCATOR)
    {
        hr = InitAllocator(ppAlloc);
        if (FAILED(hr))
            return hr;
    }
    hr = DecideBufferSize(*ppAlloc, pprops);
    if (FAILED(hr))
        return hr;

     hr = pPin->NotifyAllocator(*ppAlloc, TRUE);

    if (FAILED(hr))
    {
        return hr;
    }

    *ppAlloc = m_pAllocator;
    //m_pAllocator = *ppAlloc;

    m_pAllocator->Commit();
    m_pAllocator->AddRef();
    return hr;

}

还是我错过了什么,错误的原因不同?

最佳答案

关于就地转换的部分与问题无关并且是多余的。您在询问如何处理未实现 IMemInputPin::GetAllocatorRequirements 的对等过滤器/pin .来自 MSDN:

The input pin is not required to implement this method. If the filter has specific alignment or prefix requirements, it should implement this method.

此方法的实现不是强制性的。这意味着在您的输出引脚上,您可以自行决定配置内存分配器,无需考虑对分配器属性的同行引脚意见。

关于c++ - 使用 transinplacefilter 决定分配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22958655/

相关文章:

c++ - 多次加载 DLL?

c++ - 静态cpp中的非静态成员

c++ - 如何找出文件夹是否需要管理权限才能修改其内容?

c++ - IGraphBuilder::RenderFile() 因 VFW_E_BAD_KEY 失败 - 0x800403f2

delphi - 是否有一个简单的 DirectShow 过滤器可以将完全相同格式的音频混合在一起?

c++ - 在 OSX 10.10 上打开菜单时 Qt 系统托盘图标消失

从捕获设备 Osprey 450e 流式传输 Ffmpeg 失败

delphi - 如何在 EXE 中直接嵌入 DirectShow Push Source 过滤器?

ffmpeg - NVEnc Directshow 过滤器 [NVIDIA 视频编码器过滤器]

c++ - 为什么 Microsoft 仍会支持 nothrownew.obj?