Directshow变换滤波器将拜耳8位转换为YUY2

时间:2014-08-04 10:56:09

标签: directshow

我正在开发自定义变换滤镜,它将RAW Bayer帧从相机转换为RGB24帧。我已经在GetMediaType()函数中正确修改了输出引脚(RGB24)的MediaType属性。我仍然修改输出引脚,例如biBitCount,biCompression,biSizeImage未反映在PIN的属性窗口中。当我渲染输出PIN并运行图表时,它显示参数不正确的错误。 我的流程有什么问题,或者任何人都可以解释一下我需要为我的过滤器实现的步骤。

这是我的GetMediaType()函数,我在其中修改输出引脚的属性。

HRESULT CYuvGray::GetMediaType(int iPosition, CMediaType *pMediaType)
{




    ASSERT(m_pInput->IsConnected());

    if (iPosition < 0)
    {
        return E_INVALIDARG;
    }
    else if (iPosition == 0)
    {  


        HRESULT hr =  m_pInput->ConnectionMediaType(pMediaType);

        const GUID* rgb = &MEDIASUBTYPE_YUY2;


        //pMediaType->SetTemporalCompression(FALSE);
        //pMediaType->SetType();

         /*VIDEOINFOHEADER *pVih =
            reinterpret_cast<VIDEOINFOHEADER*>(pMediaType->pbFormat);*/

        VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER *)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));

        pVih->bmiHeader.biBitCount = 16;
        pVih->bmiHeader.biCompression = mmioFOURCC('Y', 'U', 'Y', '2');//BI_RGB;//mmioFOURCC('Y', 'U', 'Y', '2');
        //pVih->bmiHeader.biSizeImage = pVih->bmiHeader.biHeight * pVih->bmiHeader.biWidth * 2;


        pVih->bmiHeader.biSize       = sizeof(BITMAPINFOHEADER);
        pVih->bmiHeader.biPlanes     = 1;
        pVih->bmiHeader.biSizeImage  = GetBitmapSize(&pVih->bmiHeader);
        pVih->bmiHeader.biClrImportant   = 0;

        SetRectEmpty(&(pVih->rcSource)); // we want the whole image area rendered.
        SetRectEmpty(&(pVih->rcTarget)); // no particular destination rectangle

        pMediaType->SetType(&MEDIATYPE_Video);
        pMediaType->SetFormatType(&FORMAT_VideoInfo);
        pMediaType->SetTemporalCompression(FALSE);
        pMediaType->SetSampleSize(pVih->bmiHeader.biSizeImage);   


        pMediaType->SetSubtype(rgb);             //Set output type to RGB24
        //pMediaType->SetSampleSize(pMediaType->GetSampleSize() * 2);

        //pMediaType->SetFormat(PBYTE(pVih), sizeof(VIDEOINFOHEADER));   
        //pVih->dwBitRate = pVih->dwBitRate * 3 ;
        //m_pOutput->SetMediaType(pMediaType);
        return S_OK;
    }
    return VFW_S_NO_MORE_ITEMS;
}

0 个答案:

没有答案
相关问题