1.å¦ä½è®¾è®¡èªå®ä¹çDIrectShow transform filter
2.DirectShow开发指南内容简介
å¦ä½è®¾è®¡èªå®ä¹çDIrectShow transform filter
对äºDIrectShowçåå¦è èè¨ï¼æ大çå°é¾è«è¿äºå°è¯è®¾è®¡èªå®ä¹çfilterã
设计èªå®ä¹çtransform filteræ¯å°é¾ç
å 为 é¦å filteræ¯ä¸ç§dll ï¼åç¼å为.axï¼èç¼ådllå·¥ç¨éè¦ä¸å®çVCåºç¡ æ以建议å è¡¥å ä¸ç¹dllçç¥è¯
å ¶æ¬¡ dllç注åï¼GUIDççæåå·¥ç¨çé ç½®é½å¾éº»ç¦ã
å次 ç½ä¸ç¼ºä¹ç°æçtransform filterçä¾åãDirectShowç»çæºç æ¯å¦NULLINPLACE åCONTRASTé½å¤ªå¤æï¼é½å¸¦æ对è¯æ¡åå±æ§é¡µï¼ä¸éååå¦è ï¼èä¸è¿äºä¾å 没æä¸ä¸ªæ¶åå°å¾åæ ¼å¼ç转æ¢ï¼ètransform filteræ大çå ¬ç¨å°±æ¯åªä½ç±»åç转æ¢ï¼å æ¤è¿äºä¾åä¸éç¨
ä½ä¸ºä¸ä¸ªåå¦è ï¼æ深深åå°è¿äºé®é¢çå°æ°ï¼ç»è¿å»è¦é»ç ç»äºèµ°åºäºè¿ä¸ªæ³¥æ½ï¼è±ç¶å¼æãäºæ¯æå®è®°å½ä¸æ¥ï¼å¸æå¯ä»¥å¯¹å ¶ä»äººæ帮å©ï¼ä¹ä½ä¸ºå¯¹å¹´çä¸ä¸ªå°ç»ã
æçä¾åæ¯ è®¾è®¡ä¸ä¸ª transform filter æ YUY2 bit çåªä½è½¬å为RGB bitçç±»åã
åå æ¯æçæå头åªæ¯æYUY2 bitè¿ç§æ ¼å¼ï¼ ææ³å¾å°ä½å¾ãã顺便å¦ä¹ ä¸ä¸Filterç设计
以ä¸ä¸ºå ·ä½æ¥éª¤ï¼
ä¸ é ç½®å¼åç¯å¢
1. VCä¸å¨Tools->Options->Directories 设置好DirectX SDKç头æ件ååºæ件路å¾
2. ç¼è¯äºåºç±»æºç ,源码çæstrmbasd.lib (debugç), strmbase.lib(releaseç)
3. VCå导æ°å»ºä¸ä¸ªwin DLLï¼emptyï¼å·¥ç¨
4. Setting->Link->Output file name: YUV2RGBfilter.ax
5. Setting->Linkå å ¥strmbasd.lib winmm.lib quartz.lib vfw.lib (注æè·¯å¾)
6. å®ä¹ä¸ä¸ªåå.defæ件ï¼å å ¥å°å·¥ç¨ï¼å 容å¦ä¸ï¼
LIBRARY YUV2RGBfilter.ax
EXPORTS
DllMain PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
7.建ç«ä¸ä¸ªç±» YUV2RGBfilter 建ç«ä»çcppæ件åhæ件
8. å¨YUV2RGBfilter.cppä¸å®ä¹DLLçå ¥å£å½æ°å注å æ¾å¨cppæ件çæå
//
// DllEntryPoint
//
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD dwReason,
LPVOID lpReserved)
{
return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
}
////////////////////////////////////////////////////////////////////////
//
// Exported entry points for registration and unregistration
// (in this case they only call through to default implementations).
//
////////////////////////////////////////////////////////////////////////
STDAPI DllRegisterServer()
{
return AMovieDllRegisterServer2( TRUE );
}
STDAPI DllUnregisterServer()
{
return AMovieDllRegisterServer2( FALSE );
}
9. cppæ件ä¸è¦å å«ç头æ件
#include <streams.h>
#include <windows.h>
#include <initguid.h>
#include <olectl.h>
#if ( > _MSC_VER)
#include <olectlid.h>
#endif
#include "Y2Ruids.h" // our own public guids
#include "YUV2RGBfilter.h"
äº å¼åFilter
1. çæGUID( å½ä»¤è¡æ¨¡å¼ä¸è¿è¡guidgenå·¥å ·) 为ä»å»ºç«ä¸ä¸ªæ件Y2Ruids.h åç¬å¼ç¨
#include <initguid.h>
// YUV2toRGB Filter Object
// { FFC8FD-B1A6-b0-A-D6EDEAFDA}
DEFINE_GUID(CLSID_YUV2toRGB,
0xffc8fd, 0xb1a6, 0xb0, 0xa3, 0x8, 0xd6, 0xed, 0xea, 0xf4, 0x5, 0xda);
2. æé CYUV2RGBfilterç±» 继æ¿èªCTransformFilter åå¨TransformFilter.hä¸
// ----------------------------------------------------------------------------
// Class definitions of CYUV2RGBfilter
// ----------------------------------------------------------------------------
//
//
class CYUV2RGBfilter : public CTransformFilter
{
public:
static CUnknown * WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr);
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
DECLARE_IUNKNOWN;
// override pure virtual function
HRESULT CheckInputType(const CMediaType *mtIn);
HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);
HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProp);
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut);
private:
//Constructor
CYUV2RGBfilter(TCHAR *tszName, LPUNKNOWN punk, HRESULT *phr);
// member function
VOID ChangeFormat(AM_MEDIA_TYPE* pAdjustedType);
DWORD ConvertYUV2toRGB(BYTE* yuv, BYTE* rgb, DWORD dsize);
// member variable
const long m_lBufferRequest;
CCritSec m_Y2RLock; // To serialise access.
};
3. ææ ¼å¼æ¹åæé å½æ°
//
// CNullInPlace::Constructor
//
CYUV2RGBfilter::CYUV2RGBfilter(TCHAR *tszName,LPUNKNOWN punk,HRESULT *phr) :
CTransformFilter(tszName, punk, CLSID_YUV2toRGB),
m_lBufferRequest(1)
{
ASSERT(tszName);
ASSERT(phr);
} // CYUV2RGBfilter
4. æ¹åCTransformFilteräºä¸ªçº¯èå½æ°ï¼æéè¦çå°æ¹ï¼
HRESULT CheckInputType(const CMediaType *mtIn);
HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);
HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProp);
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut);
5. 设计èªå·±çç§æå½æ° å®æä¸å®çåè½
6. 注åFilterä¿¡æ¯
// 注åä¿¡æ¯
//setup data
const AMOVIESETUP_MEDIATYPE
sudPinTypes = { &MEDIATYPE_Video // clsMajorType
, &MEDIASUBTYPE_NULL } ; // clsMinorType
const AMOVIESETUP_PIN
psudPins[] = { { L"Input" // strName
, FALSE // bRendered
, FALSE // bOutput
, FALSE // bZero
, FALSE // bMany
, &CLSID_NULL // clsConnectsToFilter
, L"Output" // strConnectsToPin
, 1 // nTypes
, &sudPinTypes } // lpTypes
, { L"Output" // strName
, FALSE // bRendered
, TRUE // bOutput
, FALSE // bZero
, FALSE // bMany
, &CLSID_NULL // clsConnectsToFilter
, L"Input" // strConnectsToPin
, 1 // nTypes
, &sudPinTypes } }; // lpTypes
DirectShow开发指南内容简介
本书专为想要在Windows平台上利用DirectShow进行C++编程的开发者精心编写,其内容丰富,源码主要依据DirectX SDK 9.0版本展开。源码全书分为四个章节,源码博士源码旨在全面引导读者理解和应用DirectShow技术。源码
首章作为入门,源码目标遮挡跟踪 源码详尽阐述了DirectShow的源码基础知识,为后续学习奠定了坚实的源码基础。第二章则是源码核心部分,深入探讨了Filter的源码开发以及DirectShow应用程序的构建,特别关注了音视频采集、源码数码摄像机的源码支持以及非线性编辑等实际应用场景,这些是源码appinfo管理系统源码当前开发中备受关注的技术热点。
在第三部分,源码作者对DirectShow SDK提供的源码部分典型源代码进行了深入剖析,让读者能够理解其内部工作机制,勇士拯救计划源码对技术细节有更深入的掌握。这部分内容对于技术研究者来说尤其有价值。
最后,mpg是源码么第四章以作者的开发经验为背景,通过实例和开源代码的分析,讲解了DirectShow在实际项目中的应用技巧和策略,帮助读者更好地将理论知识转化为实践能力。
2024-11-27 01:09
2024-11-27 00:43
2024-11-27 00:12
2024-11-27 00:02
2024-11-26 23:36
2024-11-26 23:00
2024-11-26 22:50
2024-11-26 22:39