当前位置: 代码迷 >> 多媒体/流媒体开发 >> 写了一个mpeg4的解码的filter,注册后,render一个文件时“cannot render this pin”,为什么?该如何处理
  详细解决方案

写了一个mpeg4的解码的filter,注册后,render一个文件时“cannot render this pin”,为什么?该如何处理

热度:6718   发布时间:2013-02-26 00:00:00.0
写了一个mpeg4的解码的filter,注册后,render一个文件时“cannot render this pin”,为什么?
CheckInputType中判断成功:return   S_OK;
CheckTransform中也判断成功。
里面也有颜色空间转换,而且保证是正确的。

我看了一下我的decoder   filter的outpin(graph中没有render   filter):
Major   Type:     Video   -   Sub   Type:     RGB24   -   Format:       RGB   0x0,   0   bits
rcSrc=(0,0,720,576)
rcDst=(0,0,0,0)
但是一旦加上最后的render,就提示cannot   render   this   pin。

用网上下的一个可以解码mpeg4的filter看了一下,是:
Major   Type:     Video   -   Sub   Type:     RGB24   -   Format:       RGB   720x576,   24   bits,
Aspect   Ratio:   4x3,
Interlace   format:   Frames
rcSrc=(0,0,720,576)
rcDst=(0,0,720,576)

为什么呢????

------解决方案--------------------------------------------------------
首先肯定一点,不要怀疑别的,要怀疑你的Decoder某些地方写对不对。
关键是看你的解码器中GetMediaType函数是怎么实现的。看你给出的信息,我猜多半是你的OutputPin上的VIDEOINFOHEADER媒体信息给的不正确了。
------解决方案--------------------------------------------------------
Major Type: Video - Sub Type: RGB24 - Format: RGB 0x0, 0 bits

很明显是format格式不对.
即,有没有调用类似以下的语句:
BOOL bPass = mPreferredMt.SetFormat((BYTE *)inFormat, inLength);
其中inFormat是avi或mepg4的VIDEOINFOHEADER
------解决方案--------------------------------------------------------
最为关键的pMediaType-> SetFormat函数没有调用!!!!!
------解决方案--------------------------------------------------------
这样做:
VIDEOINFOHEADER * vih =(VIDEOINFOHEADER *) pMediaType-> pbFormat;
if (vih == NULL)
{
return E_OUTOFMEMORY;
}

ZeroMemory(vih, sizeof(VIDEOINFOHEADER));

vih-> rcSource.right = m_width;
vih-> rcSource.bottom = abs(m_height);
vih-> rcTarget.right = m_width;
vih-> rcTarget.bottom = abs(m_height);
vih-> bmiHeader.biWidth = m_width;
vih-> bmiHeader.biHeight = abs(m_height);
vih-> bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
vih-> bmiHeader.biPlanes = 1;
vih-> AvgTimePerFrame = m_AvgTimePerFrame;

... ...
  相关解决方案