Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: DirectX directshow 3D
I'm trying to make a Transform filter dll witch gets parallel video frames and displays it in fullscreen mode as NVidia 3D stereo mode. I use graphedit to show the results but, when i conect It to a video render filter, It shows me the "Hard coded break point" error:

"CTransformFilter::Transform() should never be called"
At line 67 of x:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclases\transfrm.cpp

Continue? (Cancel to debug)


I'm not sure what to do now.

i index the files of my project:

Filter.h
/** 
 *  Filter DirectShow Interface 
 *  andresin87@gmail.com 
 *  All rights reserved. 
 */  
 
<h1>ifndef TFILTER_H</h1>
 
<h1>define TFILTER_H</h1>
 
<h1>pragma once</h1>
 
<h1>include <windows.h></h1>
 
<h1>include <initguid.h></h1>
 
<h1>include <streams.h></h1>
 
<h1>include <d3d9.h></h1>
 
<h1>include <d3dx9.h></h1>
 
<h1>define TFILTER_NAME L"tFilter (auto-loading version)"</h1>
 
// {C50020E3-71AC-48F1-AC40-9ADA98BDBE9D}
DEFINE_GUID(CLSID_TFilter, 
0xc50020e3, 0x71ac, 0x48f1, 0xac, 0x40, 0x9a, 0xda, 0x98, 0xbd, 0xbe, 0x9d);
 
class TFilter : public CTransformFilter {  
public:  
    DECLARE_IUNKNOWN;
    static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *phr); 
 
<pre>
// -- CTransformFilter overrides --
HRESULT CheckInputType(const CMediaType *mtIn);
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);
HRESULT DecideBufferSize(IMemAllocator *pAllocator, ALLOCATOR_PROPERTIES *pProp);
HRESULT Transform(IMediaSample *pSample, AM_MEDIA_TYPE* media_type, LPDIRECT3DDEVICE9 direct_3D_device);
 
TFilter(LPUNKNOWN pUnk, HRESULT *phr);

};
 

endif TFILTER_H


Filter.cpp
/** 
 *  Filter DirectShow Interface 
 *  andresin87@gmail.com 
 *  All rights reserved. 
 */
 
<h1>include "Filter.h"</h1>
 
int buffers_size;
RGBTRIPLE *member_cash_buffer;
RGBTRIPLE *member_buffer;
RGBTRIPLE *local_member_buffer_1;
RGBTRIPLE *local_member_buffer_2;
RGBTRIPLE *local_member_entered_buffer;
int member_valid_cash;
 
TFilter::TFilter(LPUNKNOWN pUnk, HRESULT *phr)
 
    : CTransformFilter(TEXT("TFilter"), pUnk, CLSID_TFilter){
}
 
CUnknown *TFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *phr) {
    TFilter *pNewObject = new TFilter(pUnk, phr);
    if (NULL == pNewObject)
    {
        if (phr)
            *phr = E_OUTOFMEMORY;
    }
    return pNewObject;
 
}  
 
HRESULT TFilter::CheckInputType(const CMediaType *mtIn) {
 
    if ((mtIn->

}

HRESULT TFilter::GetMediaType(int iPosition, CMediaType *pMediaType)
{
ASSERT(m_pInput->IsConnected());
if (iPosition < 0)
{
return E_INVALIDARG;
}
if (iPosition == 0)
{
HRESULT hr = m_pInput->ConnectionMediaType(pMediaType);
if (FAILED(hr))
{
return hr;
}
FOURCCMap fccMap = FOURCCMap('MRLE');
pMediaType->subtype = static_cast(fccMap);
pMediaType->SetVariableSize();
pMediaType->SetTemporalCompression(FALSE);
 
    ASSERT(pMediaType-&gt;formattype == FORMAT_VideoInfo);
    VIDEOINFOHEADER *pVih =
        reinterpret_cast&lt;videoinfoheader*&gt;(pMediaType-&gt;pbFormat);
    pVih-&gt;bmiHeader.biCompression = BI_RLE8;
    pVih-&gt;bmiHeader.biSizeImage = DIBSIZE(pVih-&gt;bmiHeader); 
    return S_OK;
}
// else
return VFW_S_NO_MORE_ITEMS;

}

HRESULT TFilter::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut)
{
// Check the major type.
if (mtOut->majortype != MEDIATYPE_Video)
{
return VFW_E_TYPE_NOT_ACCEPTED;
}
 
// Check the subtype and format type.
FOURCCMap fccMap = FOURCCMap('MRLE'); 
if (mtOut-&gt;subtype != static_cast<guid>(fccMap))
{
    return VFW_E_TYPE_NOT_ACCEPTED;
}
if ((mtOut-&gt;formattype != FORMAT_VideoInfo) || 
    (mtOut-&gt;cbFormat &lt; sizeof(VIDEOINFOHEADER)))
{
    return VFW_E_TYPE_NOT_ACCEPTED;
}
 
// Compare the bitmap information against the input type.
ASSERT(mtIn-&gt;formattype == FORMAT_VideoInfo);
BITMAPINFOHEADER *pBmiOut = HEADER(mtOut-&gt;pbFormat);
BITMAPINFOHEADER *pBmiIn = HEADER(mtIn-&gt;pbFormat);
if ((pBmiOut-&gt;biPlanes != 1) ||
    (pBmiOut-&gt;biBitCount != 8) ||
    (pBmiOut-&gt;biCompression != BI_RLE8) ||
    (pBmiOut-&gt;biWidth != pBmiIn-&gt;biWidth) ||
    (pBmiOut-&gt;biHeight != pBmiIn-&gt;biHeight))
{
    return VFW_E_TYPE_NOT_ACCEPTED;
}
 
// Compare source and target rectangles.
RECT rcImg;
SetRect(&rcImg, 0, 0, pBmiIn-&gt;biWidth, pBmiIn-&gt;biHeight);
RECT *prcSrc = &((VIDEOINFOHEADER*)(mtIn-&gt;pbFormat))-&gt;rcSource;
RECT *prcTarget = &((VIDEOINFOHEADER*)(mtOut-&gt;pbFormat))-&gt;rcTarget;
if (!IsRectEmpty(prcSrc) && !EqualRect(prcSrc, &rcImg))
{
    return VFW_E_INVALIDMEDIATYPE;
}
if (!IsRectEmpty(prcTarget) && !EqualRect(prcTarget, &rcImg))
{
    return VFW_E_INVALIDMEDIATYPE;
}
 
// Check the palette table.
if (pBmiOut-&gt;biClrUsed != pBmiIn-&gt;biClrUsed)
{
    return VFW_E_TYPE_NOT_ACCEPTED;
}
DWORD cbPalette = pBmiOut-&gt;biClrUsed * sizeof(RGBQUAD);
if (mtOut-&gt;cbFormat &lt; sizeof(VIDEOINFOHEADER) + cbPalette)
{
    return VFW_E_TYPE_NOT_ACCEPTED;
}
if (0 != memcmp(pBmiOut + 1, pBmiIn + 1, cbPalette))
{
    return VFW_E_TYPE_NOT_ACCEPTED;
}
 
// Everything is good.
return S_OK;

}

HRESULT TFilter::DecideBufferSize(IMemAllocator *pAllocator, ALLOCATOR_PROPERTIES *pProp)
{
if (!m_pInput->IsConnected() || !m_pOutput->IsConnected())
return E_UNEXPECTED;
 
ASSERT(m_pOutput-&gt;CurrentMediaType().formattype == FORMAT_VideoInfo);
 
VIDEOINFOHEADER *pVihOut = 
    reinterpret_cast&lt;videoinfoheader*&gt;(m_pOutput-&gt;CurrentMediaType().Format());
CheckPointer(pVihOut, E_UNEXPECTED);
 
pProp-&gt;cBuffers = 1;
pProp-&gt;cbBuffer = GetBitmapSize(&(pVihOut-&gt;bmiHeader));
pProp-&gt;cbAlign = 1;
pProp-&gt;cbPrefix = 0;
 
ALLOCATOR_PROPERTIES actProp;
HRESULT hr = pAllocator-&gt;SetProperties(pProp, &actProp);
if (FAILED(hr))
    return hr;
if (pProp-&gt;cBuffers &gt; actProp.cBuffers || pProp-&gt;cbBuffer &gt; actProp.cbBuffer)
    return E_FAIL;
return S_OK;

}

HRESULT TFilter::Transform(IMediaSample pSample, AM_MEDIA_TYPE media_type, LPDIRECT3DDEVICE9 direct_3D_device)
{

//CAutoLock lock(m_pLock);

//CheckPointer(pSample, E_POINTER);

// do some transformation

//return S_OK;
// Transform code here
if (
pSample==NULL || media_type==NULL || direct_3D_device == NULL
)
{
return E_POINTER;
}
AM_MEDIA_TYPE* pType = media_type;
VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pType->pbFormat;
BYTE *pData; // Pointer to the actual image buffer
long lDataLen; // Holds length of any given sample
RGBTRIPLE *prgb; // Holds a pointer to the current pixel
 
pSample-&gt;GetPointer(&pData);
lDataLen = pSample-&gt;GetSize();
// Get the image properties from the BITMAPINFOHEADER

int iPixelSize = pvi-&gt;bmiHeader.biBitCount / 8;
int cxImage    = pvi-&gt;bmiHeader.biWidth;
int cyImage    = pvi-&gt;bmiHeader.biHeight;
int cbImage    = cyImage * cxImage * iPixelSize;
int numPixels  = cxImage * cyImage;
iPixelSize = pvi-&gt;bmiHeader.biBitCount / 8;
cxImage    = pvi-&gt;bmiHeader.biWidth;
cyImage    = pvi-&gt;bmiHeader.biHeight;
cbImage    = cyImage * cxImage * iPixelSize;
numPixels  = cxImage * cyImage;
 
prgb = (RGBTRIPLE*) pData;
int pixels_shift = 2*cxImage/100;
REFERENCE_TIME rtStart, rtEnd;
pSample-&gt;GetTime(&rtStart, &rtEnd);
{
    if(buffers_size!=cxImage*cyImage)
    {
        buffers_size = cxImage*cyImage;
        delete []member_cash_buffer;
        delete []member_buffer;
        delete []local_member_buffer_1;
        delete []local_member_buffer_2;
        delete []local_member_entered_buffer;
        member_cash_buffer = new RGBTRIPLE[buffers_size];
        member_buffer = new RGBTRIPLE[buffers_size];
        local_member_buffer_1 = new RGBTRIPLE[buffers_size];
        local_member_buffer_2 = new RGBTRIPLE[buffers_size];
        local_member_entered_buffer = new RGBTRIPLE[buffers_size];
        member_valid_cash = 0;
    }
}
 

define RGB_BYTE_ORDER(r, g ,b) ((DWORD) (((BYTE) (b) | ((WORD) (g) << 8)) | (((DWORD) (BYTE) (r)) << 16)))

 
HRESULT local_handle_result = S_OK;
{
    IDirect3DSurface9* gImageSrc = NULL;
 
    {
        local_handle_result = direct_3D_device-&gt;CreateOffscreenPlainSurface(
            cxImage,
            cyImage+1,
            D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, // Surface is in video memory
            &gImageSrc, NULL);
        if(local_handle_result!=S_OK)
        {
            return local_handle_result;
        }
        if(gImageSrc==NULL)
        {
            return local_handle_result;
        }
        {
            DWORD *local_bit_map_buffer;
            local_bit_map_buffer = new DWORD[cxImage*cyImage];              
 
            for(int local_counter_width=0;local_counter_width&lt;cximage;local_counter_width++)&gt;
            {
                for(int local_counter_height=0;local_counter_height&lt;cyimage;local_counter_height++)&gt;
                {
                    int local_couter = local_counter_width+local_counter_height*cxImage;
                    int local_bit_map_couter = local_counter_width+(cyImage-(local_counter_height+1))*cxImage;
                    local_bit_map_buffer[local_bit_map_couter] = RGB_BYTE_ORDER(prgb[local_couter].rgbtRed,prgb[local_couter].rgbtGreen,prgb[local_couter].rgbtBlue);
                }
            }
 
            HBITMAP handle_bit_map = NULL;
 
            handle_bit_map = CreateBitmap(
                cxImage, 
                cyImage, 
                1,
                32, 
                local_bit_map_buffer);
 
            delete []local_bit_map_buffer;
 
            HRESULT local_handle_result;
 
            HDC hdc; 
            gImageSrc-&gt;GetDC(&hdc);
 
            HDC hdc_compatible = CreateCompatibleDC(hdc);
 
            SelectObject(hdc_compatible,handle_bit_map);
            BitBlt(hdc, 0  ,0 ,cxImage  , cyImage  , hdc_compatible, 0, 0, SRCCOPY);
            gImageSrc-&gt;ReleaseDC(hdc);
            DeleteDC(hdc_compatible);
 
            bool local_result = DeleteObject(handle_bit_map);
        }
 
        int gImageWidth= cxImage; // Source image width
        int gImageHeight= cyImage;// Source image height

        RECT srcRect= { 0, 0, gImageWidth, gImageHeight+1};
        RECT dstRect= { 0, 0, gImageWidth, gImageHeight};
 
        // Stereo Blitdefines
 

define NVSTEREO_IMAGE_SIGNATURE 0x4433564e //NV3D

 
        typedef struct _Nv_Stereo_Image_Header
        {
            unsigned int dwSignature;
            unsigned int dwWidth;
            unsigned int dwHeight;
            unsigned int dwBPP;
            unsigned int dwFlags;
        } NVSTEREOIMAGEHEADER, *LPNVSTEREOIMAGEHEADER;
        // ORedflags in the dwFlagsfielsof the _Nv_Stereo_Image_Headerstructure above
 

define SIH_SWAP_EYES 0x00000001

 

define SIH_SCALE_TO_FIT 0x00000002

 
        // Lock the stereo image
        D3DLOCKED_RECT lr;
        gImageSrc-&gt;LockRect(&lr,NULL,0);
        // write stereo signature in the last raw of the stereo image
        LPNVSTEREOIMAGEHEADER pSIH=
            (LPNVSTEREOIMAGEHEADER)(((unsigned char *) lr.pBits) + (lr.Pitch* gImageHeight));
        // Update the signature header values
        pSIH-&gt;dwSignature= NVSTEREO_IMAGE_SIGNATURE;
        pSIH-&gt;dwBPP= 32;
        pSIH-&gt;dwFlags= SIH_SWAP_EYES; // Src image has left on left and right on right
        pSIH-&gt;dwWidth= gImageWidth;
        pSIH-&gt;dwHeight= gImageHeight;
        // Unlock surface
        gImageSrc-&gt;UnlockRect();
 
        D3DVIEWPORT9 local_view_port;
        direct_3D_device-&gt;GetViewport(&local_view_port);
        RECT local_view_port_rect = {0,0,local_view_port.Width,local_view_port.Height};
 
        {
            direct_3D_device-&gt;Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB (0, 0, 0), 0.0f, 0);
            direct_3D_device-&gt;BeginScene ();
 
            IDirect3DSurface9* pDestSurface = NULL;
            direct_3D_device-&gt;GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pDestSurface);
 
            if(pDestSurface)
            {
                direct_3D_device-&gt;StretchRect(gImageSrc, &srcRect, pDestSurface, &local_view_port_rect, D3DTEXF_LINEAR);
            }
            direct_3D_device-&gt;EndScene ();

// direct_3D_device->Present (NULL, NULL, NULL, NULL);
if(pDestSurface)
{
pDestSurface->Release();
}
 
            if(gImageSrc)
            {
                gImageSrc-&gt;Release();
            }
        }
    }
}
return S_OK;

}

// COM things

const AMOVIESETUP_MEDIATYPE sudPinTypes[] = {

{

&MEDIATYPE_Video, // Major type

&MEDIASUBTYPE_NULL // Minor type

}

};

const AMOVIESETUP_PIN sudpPins [] = {
L"Input", // Pins string name

FALSE, // Is it rendered

FALSE, // Is it an output

FALSE, // Are we allowed none

FALSE, // And allowed many

&CLSID_NULL, // Connects to filter

NULL, // Connects to pin

1, // Number of types

sudPinTypes // Pin information

,

{

L"Output", // Pins string name

FALSE, // Is it rendered

TRUE, // Is it an output

FALSE, // Are we allowed none

FALSE, // And allowed many

&CLSID_NULL, // Connects to filter

NULL, // Connects to pin

1, // Number of types

sudPinTypes // Pin information

}

};

const AMOVIESETUP_FILTER sudTcasFilter = {

&CLSID_TFilter, // Filter CLSID

TFILTER_NAME, // String name

MERIT_DO_NOT_USE, // Filter merit

2, // Number of pins

sudpPins // Pin information

};

CFactoryTemplate g_Templates[] = {

{ TFILTER_NAME,

&CLSID_TFilter,

TFilter::CreateInstance,

NULL,

&sudTcasFilter

}

};

int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);

STDAPI DllRegisterServer() {

return AMovieDllRegisterServer2(TRUE);

}

STDAPI DllUnregisterServer() {

return AMovieDllRegisterServer2(FALSE);

}

extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);

BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) {
return DllEntryPoint((HINSTANCE)hModule, dwReason, lpReserved);
}

please reply me..

Thanks in advance..
Posted 19-Oct-11 2:01am
Edited 19-Oct-11 2:14am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 475
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 290
3 ProgramFOX 265
4 CHill60 200
0 OriginalGriff 550
1 Sergey Alexandrovich Kryukov 470
2 Maciej Los 310
3 ProgramFOX 275
4 Peter Leow 250


Advertise | Privacy | Mobile
Web03 | 2.8.150331.1 | Last Updated 19 Oct 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100