【问题标题】:measuring performance of directshow filter测量directshow过滤器的性能
【发布时间】:2016-02-17 19:38:05
【问题描述】:

我已经为 win CE 构建了一个 mp3 解码器 directshow 过滤器,我想测量解码器的性能。我从 msdn 站点找到了两个宏,https://msdn.microsoft.com/en-IN/library/ms932254.aspx,它们在基类的 measure.h 头文件中声明。 measure.h 文件中解释说,除非定义了宏 PERF,否则这些宏将扩展为空。但是一旦启用宏,就会出现链接错误

“LNK2019:未解析的外部符号 Msr_Start() 在 函数函数“公共:虚拟long_cdecl CMP3Decoder::Recieve(Struct IMediaSample *)"(?Recieve@CMP3Decoder@@UAAJPAUIMediaSample@@@Z)

我试图转储 strmbase.lib 中的符号,但在其中找不到任何符号名称 Msr_Start。我还搜索了整个基类文件夹源代码。

在哪里可以找到这些函数的定义?

或者有没有其他方法可以衡量过滤器的性能?

CMP3Decoder::recieve()函数如下

HRESULT CMP3Decoder::Receive(IMediaSample *pSample) {

HRESULT hr;
ASSERT(pSample);
if(pSample == NULL || m_MP3DecHandle == NULL)
{
    return E_FAIL;
}

ASSERT (m_pOutput != NULL) ;

// Start timing the transform (if PERF is defined)
MSR_START(m_idTransform);

// have the derived class transform the data

hr = MP3StartDecode(pSample);//, pOutSample);

// Stop the clock and log it (if PERF is defined)
MSR_STOP(m_idTransform);

if (FAILED(hr)) {
    //DbgLog((LOG_TRACE,1,TEXT("Error from transform")));
} else {
    // the Transform() function can return S_FALSE to indicate that the
    // sample should not be delivered; we only deliver the sample if it's
    // really S_OK (same as NOERROR, of course.)
    if (hr == NOERROR) {
        //hr = m_pOutput->Deliver(pOutSample);
        m_bSampleSkipped = FALSE;   // last thing no longer dropped
    } else {
        // S_FALSE returned from Transform is a PRIVATE agreement
        // We should return NOERROR from Receive() in this cause because returning S_FALSE
        // from Receive() means that this is the end of the stream and no more data should
        // be sent.
        if (S_FALSE == hr) {

            //  Release the sample before calling notify to avoid
            //  deadlocks if the sample holds a lock on the system
            //  such as DirectDraw buffers do
            //pOutSample->Release();
            m_bSampleSkipped = TRUE;
            if (!m_bQualityChanged) {
                NotifyEvent(EC_QUALITY_CHANGE,0,0);
                m_bQualityChanged = TRUE;
            }
            return NOERROR;
        }
    }
}
// release the output buffer. If the connected pin still needs it,
// it will have addrefed it itself.
//pOutSample->Release();

return hr;

}

【问题讨论】:

    标签: c++ performance windows-ce directshow


    【解决方案1】:

    根据MSDN,需要链接到Strmiids.lib。

    或者有没有其他方法可以衡量过滤器的性能?

    为了测量过滤器的性能,我通常会在要测量的过滤器之前和之后插入一个自定义的就地转换过滤器。 Trans-in-place 过滤器以高分辨率将采样时间和当前时间输出到日志文件。您可以通过从之后减去之前的当前时间并对这些时间进行平均等来计算过滤器处理时间。此外,文件 io 仅应在停止图形后完成,因为您不想干扰测量本身。

    更新: 转储 Strmiids.lib 中的符号似乎可以确认 Msr_xxx 函数未在 Strmiids.lib 中定义。看起来 MSDN 文章不正确。

    【讨论】:

    • 根据msdn,目前我已链接到 strmbase.lib、Strmiids.lib、Ole32.lib、Ole32auth.lib、Uuid.lib 库。 strmiids.lib 给出了我认为的标准组件的 CLSID 和 IID
    • 我找到了一种解决方法,根据msdn,使用 QueryPerformanceCounter()。但是,如果我能得到有关 MSR_START 和 MSR_STOP 的详细信息,那就太好了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多