VSFilterMod是一款特效插件,可以给播放器配置,也可以用来压制特效字幕视频。它能提供比一般字幕所依赖的外部库libass更丰富的效果,如渐变、抖动等,一半压制默认就是用这款滤镜插件做。滤镜据说来源于英文单词filter,所以与征文好像有一点关系,试着投了一下。年轻人要多学习。
本文先看一个简短的源代码,加入一点注释。语言:C++
文件(视频滤镜基类):vsfiltermod/BaseVideoFilter.h at master · MewX/vsfiltermod · GitHub
#pragma once
//定义视频输出类型的结构体
typedef struct
{
const GUID* subtype;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
} VIDEO_OUTPUT_FORMATS;
//父类 :CTransformFilter
class CBaseVideoFilter : public CTransformFilter
{
private:
HRESULT Receive(IMediaSample* pIn);
// 原注释:由于某种原因设置为私有成员,不能修改,是什么原因?
DWORD m_win, m_hin, m_arxin, m_aryin;
DWORD m_wout, m_hout, m_arxout, m_aryout;
long m_cBuffers;
protected:
CCritSec m_csReceive;
int m_w, m_h, m_arx, m_ary;
//获取输出的方法
HRESULT GetDeliveryBuffer(int w, int h, IMediaSample** ppOut);
//复制缓冲区,具有两种形式
HRESULT CopyBuffer(BYTE* pOut, BYTE* pIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced = false);
HRESULT CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced = false);
//虚拟方法,获取输出大小
virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight) {}
virtual HRESULT Transform(IMediaSample* pIn) = 0;
virtual bool IsVideoInterlaced()
{
return false;
}
virtual void GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
public:
CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers = 1);
virtual ~CBaseVideoFilter();
HRESULT ReconnectOutput(int w, int h, bool bSendSample = true, int realWidth = -1, int realHeight = -1);
int GetPinCount();
CBasePin* GetPin(int n);
HRESULT CheckInputType(const CMediaType* mtIn);
HRESULT CheckOutputType(const CMediaType& mtOut);
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
void SetAspect(CSize aspect);
};
//视频输入分配基类
class CBaseVideoInputAllocator : public CMemAllocator
{
CMediaType m_mt;
public:
CBaseVideoInputAllocator(HRESULT* phr);
void SetMediaType(const CMediaType& mt);
STDMETHODIMP GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
};
//定义视频输入标记基类
class CBaseVideoInputPin : public CTransformInputPin
{
CBaseVideoInputAllocator* m_pAllocator;
public:
CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
~CBaseVideoInputPin();
STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator);
STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
};
//定义视频输出标记基类
class CBaseVideoOutputPin : public CTransformOutputPin
{
public:
CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
HRESULT CheckMediaType(const CMediaType* mtOut);
};
完。代码作者MewX,整个project似乎是vs stutio开发,C++实在是太过于笨重了。
「艾尔登法环」梅琳娜手办开订 立体手办▪
万代「艾尔登法环」白狼战鬼手办开订 立体手办▪
「夏目友人帐」猫咪老师粘土人开订 立体手办▪
「五等分的新娘∬」中野三玖·白无垢版手办开订 立体手办▪
「海贼王」乌索普Q版手办开订 立体手办▪
良笑社「初音未来」新手办开订 立体手办▪
「黑岩射手DAWN FALL」死亡主宰手办开订 立体手办▪
「盾之勇者成名录」菲洛手办登场 立体手办▪
「魔法少女小圆」美树沙耶香手办开订 立体手办▪
「咒术回战」七海建人粘土人登场 立体手办▪
「五等分的新娘」中野二乃白无垢手办开订 立体手办▪
「为美好的世界献上祝福!」芸芸粘土人开订 立体手办▪
「公主连结 与你重逢」六星可可萝手办开订 立体手办▪
「女神异闻录5」Joker雨宫莲手办开订 立体手办▪
「间谍过家家」约尔・福杰粘土人登场 立体手办▪
「街角魔族 2丁目」吉田优子手办开订 立体手办▪
「火影忍者 疾风传」旗木卡卡西·暗部版粘土人登场 立体手办▪
「佐佐木与宫野」宫野由美粘土人开订 立体手办▪
「盾之勇者成名录」第2季拉芙塔莉雅手办开订 立体手办▪
「咒术回战」两面宿傩Q版坐姿手办开订 立体手办▪
「DATE·A·BULLET」时崎狂三手办开订 立体手办▪
「狂赌之渊××」早乙女芽亚里粘土人开订 立体手办▪
「魔道祖师」魏无羨粘土人开订 立体手办▪
「新·奥特曼」奥特曼手办现已开订 立体手办▪