DirectX transform filter :
2 In 1 Out ( 2 Inputs and 1 Output )
accepts two inputs and gives one output.
Both the inputs must be the same size ?....
For 2 input directx transform filter,
Both the input surfaces must be the same size.
I tested it with XTL file with XTLTest sample application.
I have given two input video file.
One video file's resolution is 720 * 480 and another one video file's resolution is 320 * 240.
I used my two input directx transform filter.
video filenames and directx transform filter is specified in XTL file.
I run this .XTL file and generated the graph edit file (.grf). I learnt one thing from that Graphedit file.
if the video which is having large size is resized ( using resize filter ) to the another video file's size.
Then both video resolution is same size and then it is passed to the Transition DirectX transform filter (Wipe, DyadicArithmetic)
Showing posts with label DirectX Transform. Show all posts
Showing posts with label DirectX Transform. Show all posts
Wednesday, June 20, 2007
Saturday, June 16, 2007
DirectX transform is also a BHO ( Browser helper Object)
DirectX transform Filters implement the IObjectwithSite interface So it is called as Browser Helper Object.
Browser Helper Object (BHO) is a DLL module designed as a plugin for Microsoft's Internet Explorer web browser to provide added functionality. BHOs were introduced in October 1997 with the release of version 4 of Internet Explorer. Most BHOs are loaded once by each new instance of Internet Explorer. However, in the case of the Windows File Explorer, a new instance is launched for each window.
Some modules enable the display of different file formats not ordinarily interpretable by the browser. The Adobe Acrobat plugin that allows Internet Explorer users to read PDF files within their browser is a BHO.
Other modules add toolbars to Internet Explorer, such as the Alexa Toolbar that provides a list of web sites related to the one you are currently browsing, or the Google Toolbar that adds a toolbar with a Google search box to the browser user interface.
Browser Helper Object (BHO) is a DLL module designed as a plugin for Microsoft's Internet Explorer web browser to provide added functionality. BHOs were introduced in October 1997 with the release of version 4 of Internet Explorer. Most BHOs are loaded once by each new instance of Internet Explorer. However, in the case of the Windows File Explorer, a new instance is launched for each window.
Some modules enable the display of different file formats not ordinarily interpretable by the browser. The Adobe Acrobat plugin that allows Internet Explorer users to read PDF files within their browser is a BHO.
Other modules add toolbars to Internet Explorer, such as the Alexa Toolbar that provides a list of web sites related to the one you are currently browsing, or the Google Toolbar that adds a toolbar with a Google search box to the browser user interface.
Wednesday, June 06, 2007
DirectX transform filters working mechanism
How the DirectX transform filters work ?
1.using XTL Test we can create the .grf file(graphedit)
2. From that .grf file, what I learned ?...
The Source is decompressed and then given to the DEX Filter( XML Rendering engine or DirectXEditing Filter) .
3.DirectX transform wrapper acts like a callback (sample grabber filter). DEX filter samples the frames and passed it
to the DirectX transform wrapper. This Directx transform wrapper( it can be any effect filter) processes and modifies the frame.
Next the Processed frame is passed to the DEX Filter and DEX filter renders the frames using video renderer.
The users specify the output width and height in the .XTL file. based on it the resizer filter is added. if the output video width and height is not
specified, the input video width and height is taken as an output video width and height.( Both the cases the resizer will be added to the graph)
Through XTL file, we can change the frame rate of the video
highway.avi -> AVI Splitter -> AVI Decompressor ->Resizer-> Frame Rate converter -> DEX Filter 000A---Out0--> DEXER queue -> DEX video renderer
Frame rate Converter --------> In 2 of DEX Filter --Out 0--> DEXER queue
DXT Wrapper ---->In 3 of DEX filter ...
Out 0 of DEX Filter -> Input of DXT wrapper
Out 0 of DEX filter is connected to the input pin of the DXT wrapper.
1.using XTL Test we can create the .grf file(graphedit)
2. From that .grf file, what I learned ?...
The Source is decompressed and then given to the DEX Filter( XML Rendering engine or DirectXEditing Filter) .
3.DirectX transform wrapper acts like a callback (sample grabber filter). DEX filter samples the frames and passed it
to the DirectX transform wrapper. This Directx transform wrapper( it can be any effect filter) processes and modifies the frame.
Next the Processed frame is passed to the DEX Filter and DEX filter renders the frames using video renderer.
The users specify the output width and height in the .XTL file. based on it the resizer filter is added. if the output video width and height is not
specified, the input video width and height is taken as an output video width and height.( Both the cases the resizer will be added to the graph)
Through XTL file, we can change the frame rate of the video
highway.avi -> AVI Splitter -> AVI Decompressor ->Resizer-> Frame Rate converter -> DEX Filter 000A---Out0--> DEXER queue -> DEX video renderer
Frame rate Converter --------> In 2 of DEX Filter --Out 0--> DEXER queue
DXT Wrapper ---->In 3 of DEX filter ...
Out 0 of DEX Filter -> Input of DXT wrapper
Out 0 of DEX filter is connected to the input pin of the DXT wrapper.
Wednesday, May 30, 2007
Directx transform built-in classes and interfaces list
http://msdn2.microsoft.com/en-us/library/aa752194.aspx
DirectX transform filter classes and interfaces list :
----------------------------------------------------------------------
Interfaces
CDXBaseARGBPtr
CDXBaseNTo1
CDXBaseSurface
CDXBnds
CDXMMXInfo
CDXScale
CDXTWorkInfoNTo1
CDXVec
DXBASESAMPLE
DXPMSAMPLE
DXSAMPLE
ICSSFilterDispatch
IDXARGBReadPtr
IDXARGBReadWritePtr
IDXARGBSurfaceInit
IDXBaseObject
IDXBasicImage
IDXDCLock
IDXDLUTBuilder
IDXEffect
IDXGradient
IDXLookupTable
IDXLUTBuilder
IDXRawSurface
IDXSurface
IDXSurfaceFactory
IDXSurfaceInit
IDXSurfaceModifier
IDXSurfacePick
IDXTaskManager
IDXTBindHost
IDXTConvolution
IDXTransform
IDXTransformFactory
IDXTScale
IDXTScaleOutput
IHTMLDXTransform
IObjectWithBehaviorSite
DirectX transform filter classes and interfaces list :
----------------------------------------------------------------------
Interfaces
CDXBaseARGBPtr
CDXBaseNTo1
CDXBaseSurface
CDXBnds
CDXMMXInfo
CDXScale
CDXTWorkInfoNTo1
CDXVec
DXBASESAMPLE
DXPMSAMPLE
DXSAMPLE
ICSSFilterDispatch
IDXARGBReadPtr
IDXARGBReadWritePtr
IDXARGBSurfaceInit
IDXBaseObject
IDXBasicImage
IDXDCLock
IDXDLUTBuilder
IDXEffect
IDXGradient
IDXLookupTable
IDXLUTBuilder
IDXRawSurface
IDXSurface
IDXSurfaceFactory
IDXSurfaceInit
IDXSurfaceModifier
IDXSurfacePick
IDXTaskManager
IDXTBindHost
IDXTConvolution
IDXTransform
IDXTransformFactory
IDXTScale
IDXTScaleOutput
IHTMLDXTransform
IObjectWithBehaviorSite
Monday, May 28, 2007
Mirror Filter
I completed the OpenCV Mirror class...
But it is not good to use OpenCV instead of it we can use the Gdi+ based rotation.
So I converted the OpenCV class developement to the Gdi+ class.
Gdi+ supports the PARGB format whereas openCV doesnt support this support.
Mirror Operations and its Gdi+ equaivalent RotateFlipType :
------------------------------------------------------------------
None - RotateNoneFlipNone
MirrorX - Rotate180FlipX
MirrorY - Rotate180FlipY
MirrorXY - RotateNoneFlipXY
But it is not good to use OpenCV instead of it we can use the Gdi+ based rotation.
So I converted the OpenCV class developement to the Gdi+ class.
Gdi+ supports the PARGB format whereas openCV doesnt support this support.
Mirror Operations and its Gdi+ equaivalent RotateFlipType :
------------------------------------------------------------------
None - RotateNoneFlipNone
MirrorX - Rotate180FlipX
MirrorY - Rotate180FlipY
MirrorXY - RotateNoneFlipXY
Thursday, May 24, 2007
DirectX input surface may have different size output surface
Some Times the input surface may have different size output surface.
How can we make perfectly work with any type of Output ?
Solution :
1.Copy the input surface image to the the output surface image (with input surface image width and height alone)
2. Stretch the input surface image to the output surface image
Do the following steps for stretching :
1.Read data from input Surface
2.Perform operation on raw image data
3.Set the processed data to the input Surface.
4.Using IDXTScale resize the inputSurface image and copy it to the output surface.
How can we make perfectly work with any type of Output ?
Solution :
1.Copy the input surface image to the the output surface image (with input surface image width and height alone)
2. Stretch the input surface image to the output surface image
Do the following steps for stretching :
1.Read data from input Surface
2.Perform operation on raw image data
3.Set the processed data to the input Surface.
4.Using IDXTScale resize the inputSurface image and copy it to the output surface.
Thursday, May 10, 2007
Only one Custom DirectX transform is working others are not working
I am implementing the sepia filter because RGB to Gray effect is already available in basic effects in DirectX transform.
Next I faced the problem in the DirectX transform filter.
I copied the Wipe transform filter and devleoped the simple DirectX transform filter. it works well.
I copied the same wipe transform filter and developed the Sepia transform filter and after the compilation, it is not working.
Even though this filter has differnt GUID in an .idl file, the first DirectX transform filter which is not working well after the compilation of the
second directX transform filter .
Solution :
The DirectX transform filter is not registered in the registry.
I just copied the DirectX transform filter.
It has ".rgs" files which is used to register the filter's Guid on the registry.
we must manually write this ".rgs" file. Depends upon the GUID of a transform filter, I changed the ".rgs" file.
Now it is working fine.
Next I faced the problem in the DirectX transform filter.
I copied the Wipe transform filter and devleoped the simple DirectX transform filter. it works well.
I copied the same wipe transform filter and developed the Sepia transform filter and after the compilation, it is not working.
Even though this filter has differnt GUID in an .idl file, the first DirectX transform filter which is not working well after the compilation of the
second directX transform filter .
Solution :
The DirectX transform filter is not registered in the registry.
I just copied the DirectX transform filter.
It has ".rgs" files which is used to register the filter's Guid on the registry.
we must manually write this ".rgs" file. Depends upon the GUID of a transform filter, I changed the ".rgs" file.
Now it is working fine.
Some useful fns in DirectX transform
DetertmineBnds() to determine the output width and height.
DXBitBlt() fn used to copy the image.
DXBitBlt() fn used to copy the image.
Simple DirectX transform filter completed
I refered the AMGetErrorText() fn in DirectX transform filter.
To refer this function, we have to include
Quartz.lib and dshow.h files
00000000 8:58:52.593 AM [3244]
00000001 8:58:52.593 AM [3244] CDXTWipe::OnSetup() fn
00000002 8:58:52.593 AM [3244]
00000003 8:58:52.593 AM [3244] CDXTWipe::OnInitInstData() fn
00000004 8:58:52.593 AM [3244]
00000005 8:58:52.593 AM [3244] InputSurface(0)->GetDirectDrawSurface() failed
00000006 8:58:52.609 AM [3244] Unknown Error: 0x887a0001
00000007 8:58:52.609 AM [3244] Clip's mediatimes are invalid, or DibSeq too short, or a previous error caused this
00000008 8:58:52.609 AM [3244]
I added my filter as effect in Slomo.xtl file and put the debug string in my programme.
within my filter I get the DirectDraw surface from the IDXSurface interface.
if the filter is called by using XTLTest sample application (simply adding the filter's CLASSID in an Effect option).
The GetDirectDrawSurface() fn is failed with unknown error. so I has to change the program.
Instead of using DirectDrawSurface () directly use IDXARGBReadPtr interface to get the
surface data.
//One more thing we have to register all our filters in the registry under the category
// of CLSID_VIdeoEffects1category (for one input DirectX transform filter)
// and CLSID_VideoEffects2Category (for two input DirectX transform filter).
So I have to change it and use IDXARGBPtr for reading data from the IDXSurface.
Next to be Done :
--------------------------
1.Text overlay filter - use IDXARGBReadPtr interface.
2.Merge Filter
I found the reason for this error...
DXSurface does not have an underlying IDXSurface::GetDirectDrawSurface.
This is the case for some surfaces, such as procedural surfaces.
DirectX transform filter is made up of Procedural surfaces.
About the DC:
----------------------
IDXDCLock Interface
--------------------------------------------------------------------------------
The IDXDCLock interface is used to lock a surface and to obtain a device context (DC) that can be used with Microsoft® Windows® Graphics Device Interface (GDI) calls.
IDXDCLock Members
GetDC Retrieves the current DC.
Remarks
You can use IDXDCLock by calling the IDXSurface::LockSurface method and by specifying IID_IDXDCLock as the desired interface, or by calling the IDXSurface::LockSurfaceDC method. When the IDXDCLock interface is finally released, the underlying GDI DC is released.
IDXDCLock can be used by any transform that enables you to specify the desired output bounds.
Interface Information
I found out another way to get the DC of an IDXSurface interface :
IDXDCLock* pDCInputLock = NULL;
IDXDCLock* pDCOutputLock = NULL;
HDC hdcInput;
HDC hdcOutput;
OutputDebugString("\n CDXTWipe::WorkProc() fn");
InputSurface(0)->LockSurfaceDC(NULL,INFINITE,DXLOCKF_READ, &pDCInputLock);
OutputSurface()->LockSurfaceDC(NULL,INFINITE,DXLOCKF_READWRITE, &pDCOutputLock);
hdcInput = pDCInputLock->GetDC();
hdcOutput = pDCOutputLock->GetDC();
BitBlt(hdcOutput,0,0,m_OutputSize.cx,m_OutputSize.cy,hdcInput,0,0,SRCCOPY);
TextOut(hdcOutput,10,10,"sundar",6);
if(pDCInputLock)
{
pDCInputLock->Release();
pDCInputLock = NULL;
}
if(pDCOutputLock)
{
pDCOutputLock->Release();
pDCOutputLock = NULL;
}
return hr;
Next I used the LockSurfaceDC() fn of an IDXSurface it is also failed with error...
instead of adding text over it use RGB to Gray functionality using IDXARGBReadPtr interface.
IDXARGBReadPtr
To Be done :
--------------------
1.Add the Effect filter functionality to convert from RGB to Gray.
using IDXARGBReadWritePtr interface.
The following code simply copy the input surface to the output surface :
---------------------------------------------------------------------------------------------------
CDXDBnds srcBnds(InputSurface(),hr);
if(FAILED(hr))
{
OutputDebugString("\n failed in getting InputSurface()'s Bounds fn");
return E_FAIL;
}
CDXDBnds destBnds(OutputSurface(),hr);
if(FAILED(hr))
{
OutputDebugString("\n failed in getting OutputSurface()'s Bounds fn");
return E_FAIL;
}
hr = DXBitBlt(OutputSurface(),destBnds,InputSurface(),srcBnds,DXBOF_DO_OVER ,m_ulLockTimeOut);
return hr;
I tested the filter by simlply adding a color rectangle to my source image..
Thru XTL test it is now working...
For color rectangle, I did the following :
this will display the blue color rectangle in an image...
RECT rect;
rect.left = 0;
rect.top = 0;
rect.bottom = 50;
rect.right = 50;
hr = DXFillSurfaceRect(OutputSurface(),rect,0xff,FALSE,m_ulLockTimeOut);
I completed the testing of my filter with simple color rectangle effect and
added it with SlomoEffect.bat in XTLTest application.
So Next I will convert my Directshow baseclasses filters to Directx transform filters.
I Tested the filter with the graph.
How can we change the DirectXTransform filter's output size :
we can determine the output surface's bounds using CDXBaseNTo1::DetermineBnds() Method
if we override the base class method then we will get desired output.
we can build the merge filter in an easy manner in DirectX transform filter.
To Be done next :
--------------------------------
1. After lunch work with WMCSApp and Windows services application : - completed
2. Work with Merge filter -...
3.How can we pass two surfaces and create the output surface...
To refer this function, we have to include
Quartz.lib and dshow.h files
00000000 8:58:52.593 AM [3244]
00000001 8:58:52.593 AM [3244] CDXTWipe::OnSetup() fn
00000002 8:58:52.593 AM [3244]
00000003 8:58:52.593 AM [3244] CDXTWipe::OnInitInstData() fn
00000004 8:58:52.593 AM [3244]
00000005 8:58:52.593 AM [3244] InputSurface(0)->GetDirectDrawSurface() failed
00000006 8:58:52.609 AM [3244] Unknown Error: 0x887a0001
00000007 8:58:52.609 AM [3244] Clip's mediatimes are invalid, or DibSeq too short, or a previous error caused this
00000008 8:58:52.609 AM [3244]
I added my filter as effect in Slomo.xtl file and put the debug string in my programme.
within my filter I get the DirectDraw surface from the IDXSurface interface.
if the filter is called by using XTLTest sample application (simply adding the filter's CLASSID in an Effect option).
The GetDirectDrawSurface() fn is failed with unknown error. so I has to change the program.
Instead of using DirectDrawSurface () directly use IDXARGBReadPtr interface to get the
surface data.
//One more thing we have to register all our filters in the registry under the category
// of CLSID_VIdeoEffects1category (for one input DirectX transform filter)
// and CLSID_VideoEffects2Category (for two input DirectX transform filter).
So I have to change it and use IDXARGBPtr for reading data from the IDXSurface.
Next to be Done :
--------------------------
1.Text overlay filter - use IDXARGBReadPtr interface.
2.Merge Filter
I found the reason for this error...
DXSurface does not have an underlying IDXSurface::GetDirectDrawSurface.
This is the case for some surfaces, such as procedural surfaces.
DirectX transform filter is made up of Procedural surfaces.
About the DC:
----------------------
IDXDCLock Interface
--------------------------------------------------------------------------------
The IDXDCLock interface is used to lock a surface and to obtain a device context (DC) that can be used with Microsoft® Windows® Graphics Device Interface (GDI) calls.
IDXDCLock Members
GetDC Retrieves the current DC.
Remarks
You can use IDXDCLock by calling the IDXSurface::LockSurface method and by specifying IID_IDXDCLock as the desired interface, or by calling the IDXSurface::LockSurfaceDC method. When the IDXDCLock interface is finally released, the underlying GDI DC is released.
IDXDCLock can be used by any transform that enables you to specify the desired output bounds.
Interface Information
I found out another way to get the DC of an IDXSurface interface :
IDXDCLock* pDCInputLock = NULL;
IDXDCLock* pDCOutputLock = NULL;
HDC hdcInput;
HDC hdcOutput;
OutputDebugString("\n CDXTWipe::WorkProc() fn");
InputSurface(0)->LockSurfaceDC(NULL,INFINITE,DXLOCKF_READ, &pDCInputLock);
OutputSurface()->LockSurfaceDC(NULL,INFINITE,DXLOCKF_READWRITE, &pDCOutputLock);
hdcInput = pDCInputLock->GetDC();
hdcOutput = pDCOutputLock->GetDC();
BitBlt(hdcOutput,0,0,m_OutputSize.cx,m_OutputSize.cy,hdcInput,0,0,SRCCOPY);
TextOut(hdcOutput,10,10,"sundar",6);
if(pDCInputLock)
{
pDCInputLock->Release();
pDCInputLock = NULL;
}
if(pDCOutputLock)
{
pDCOutputLock->Release();
pDCOutputLock = NULL;
}
return hr;
Next I used the LockSurfaceDC() fn of an IDXSurface it is also failed with error...
instead of adding text over it use RGB to Gray functionality using IDXARGBReadPtr interface.
IDXARGBReadPtr
To Be done :
--------------------
1.Add the Effect filter functionality to convert from RGB to Gray.
using IDXARGBReadWritePtr interface.
The following code simply copy the input surface to the output surface :
---------------------------------------------------------------------------------------------------
CDXDBnds srcBnds(InputSurface(),hr);
if(FAILED(hr))
{
OutputDebugString("\n failed in getting InputSurface()'s Bounds fn");
return E_FAIL;
}
CDXDBnds destBnds(OutputSurface(),hr);
if(FAILED(hr))
{
OutputDebugString("\n failed in getting OutputSurface()'s Bounds fn");
return E_FAIL;
}
hr = DXBitBlt(OutputSurface(),destBnds,InputSurface(),srcBnds,DXBOF_DO_OVER ,m_ulLockTimeOut);
return hr;
I tested the filter by simlply adding a color rectangle to my source image..
Thru XTL test it is now working...
For color rectangle, I did the following :
this will display the blue color rectangle in an image...
RECT rect;
rect.left = 0;
rect.top = 0;
rect.bottom = 50;
rect.right = 50;
hr = DXFillSurfaceRect(OutputSurface(),rect,0xff,FALSE,m_ulLockTimeOut);
I completed the testing of my filter with simple color rectangle effect and
added it with SlomoEffect.bat in XTLTest application.
So Next I will convert my Directshow baseclasses filters to Directx transform filters.
I Tested the filter with the graph.
How can we change the DirectXTransform filter's output size :
we can determine the output surface's bounds using CDXBaseNTo1::DetermineBnds() Method
if we override the base class method then we will get desired output.
we can build the merge filter in an easy manner in DirectX transform filter.
To Be done next :
--------------------------------
1. After lunch work with WMCSApp and Windows services application : - completed
2. Work with Merge filter -...
3.How can we pass two surfaces and create the output surface...
Subscribe to:
Posts (Atom)