home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2007 April
/
PCWorld_2007-04_cd.bin
/
audio-video
/
kmplayer
/
kmp.exe
/
SDK
/
KMPPlgIn.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2003-05-13
|
10KB
|
223 lines
/////////////////////////////////////////////////////////////////////////////
//
// KMP┐δ ┐└╡≡┐└/║±╡≡┐└ ╟├╖»▒╫└╬ └╬┼═╞Σ└╠╜║
//
// KMP└╟ ╟├╖»▒╫└╬ ╕≡╡Γ└║ └⌐╛┌╟┴└╟ DSP╟├╖»▒╫└╬░·
// ▒╕┴╢░í ░┼└╟ ░░┤┘. ┐└╡≡┐└ ╟├╖»▒╫└╬└╟ ░µ┐∞┤┬ └╚╛┌╟┴┐═ ▒╕┴╢░í
// ░░▒Γ ╢º╣«┐í └⌐╛┌╟┴└╟ DSP╟├╖»▒╫└╬└╗ KMP┐í╝¡ ╗τ┐δ╟╧┤┬ ░═└╠ ░í┤╔╟╧┤┘.
// ║±╡≡┐└ ╟├╖»▒╫└╬└╟ ░µ┐∞╡╡ ░┼└╟ ║±╜┴╟╧╣╟╖╬ ╜▒░╘ └█╝║╟╥╝÷░í └╓└╗░═└╠┤┘.
// ▒╫╕«░φ ╟╘╝÷ ▒╘╛α└╠ cdel└╠┤┘.. ┬ⁿ░φ...
//
// ┐╡╗≤╟├╖»▒╫└╬└╟ ░µ┐∞┤┬ WaSaVi┐═ ┤▐╢≤┴│┤┘... ╢╟╟╤ ┬ⁿ░φ...
//
/////////////////////////////////////////////////////////////////////////////
unit KMPPlgIn;
interface
uses
Windows;
// header version: 0x20 == 0.20 == winamp 2.0
const
DSP_HDRVER = $20;
// DSP plugin interface
// notes:
// any window that remains in foreground should optimally pass unused
// keystrokes to the parent (winamp's) window, so that the user
// can still control it. As for storing configuration,
// Configuration data should be stored in <dll directory>\plugin.ini
// (look at the vis plugin for configuration code)
type
//////////////////////////////////////////////////////////////////////////////
//
// Audio PlugIn Type...(same as Winamp DSP PlugIn Type...)
//
// └⌐╛┌╟┴└╟ DSP╟┴╖»▒╫└╬░· ▒╕┴╢░í 100%└╧─í╟╤┤┘.
//////////////////////////////////////////////////////////////////////////////
PwinampDSPModule = ^TwinampDSPModule;
TwinampDSPModule = record
description : pchar; // description
hwndParent : HWND; // parent window (filled in by calling app)
hDllInstance : LongWord; // instance handle to this DLL (filled in by calling app)
Config : procedure(this_mod : PwinampDSPModule); cdecl; // configuration dialog (if needed)
Init : function(this_mod : PwinampDSPModule) : integer; cdecl; // 0 on success, creates window, etc (if needed)
// modify waveform samples: returns number of samples to actually write
// (typically numsamples, but no more than twice numsamples, and no less than half numsamples)
// numsamples should always be at least 128. should, but I'm not sure
ModifySamples : function(this_mod : PwinampDSPModule;samples : PByte;
numsamples,bps,nch,srate : integer) : integer; cdecl;
// └⌐╛┌╟┴┐í╝¡ ╗τ┐δ╟╧┤┬ └╜╝║└╗ ║»░µ╟╧┤┬ ╟╘╝÷...
// samples : ╗∙╟├└╠ ╡Θ╛ε░í └╓┤┬ ╣÷╞█
// numsamples : ╗∙╟├└╟ ░╣╝÷(╜╟┴·└√└╬ ╣÷╞█└╟ ▒µ└╠░í ╛╞┤╧╢≤ ╗∙╟├└╟ ░╣╝÷└╙...
// bps : ╗∙╟├┤τ ║±╞«╝÷ 8 or 16
// nch : ├ñ│╬╝÷ 1 : ╕≡│δ , 2 : ╜║╞«╖╣┐└
// srate : ╗∙╟├╕╡ ╖╣└╠╞« 44000╡ε╡ε..
// └╠╟╘╝÷┐í╝¡ ╕«┼╧░¬└╠ ║»░µ╟╤ ╡Ñ└╠┼╕└╟ ░╣╝÷└╠┤┘. ╢╟╟╤ ╜╟┴·└√└╕╖╬ ├Γ╖┬└╕╖╬
// │¬░í┤┬ ░╣╝÷└╠▒Γ╡╡ ╟╧┤┘. └⌐╛┌╟┴┐í╝¡ ┼╫╜║╞«╟╤ ░µ┐∞┤┬ └╘╖┬╣▐└║ ╗∙╟├║╕┤┘
// ╕╣░╘╟╪╡╡ ╡┐└█└╗ ╟╧┐┤┤┘. ╡√╢≤╝¡ KMP┐í╝¡╡╡ └╘╖┬║╕┤┘ 3-4╣Φ┴ñ╡╡└╟
// ╕▐╕≡╕«╕ª │╗║╬└√└╕╖╬ ╟╥┤τ└╗ ╟╪│⌡╛╥┤┘. ▒╫╖»╣╟╖╬ 3-4╣Φ └╠╗≤└╗ ├│╕«╟╧╕Θ ┐└╖∙░í
// └╧╛ε│»╝÷╡╡ └╓┤┘...
//
Quit : procedure(this_mod : PwinampDSPModule); cdecl; // called when unloading
userData : Pointer; // user data, optional
end;
PwinampDSPHeader = ^TwinampDSPHeader;
TwinampDSPHeader = record
version : integer; // DSP_HDRVER
description : pchar; // description of library
winampDSPModule : function(num : integer) : PwinampDSPModule; cdecl; // module retrieval function
end;
////////////////////////////////////
// Audio PlugIn DLL Exports Name...
////////////////////////////////////
//function winampDSPGetHeader2 : PwinampDSPHeader; cdecl;
// └╜╝║ DLL┐í╝¡ Exports╟╪╛▀ ╡╟┤┬ ╟╘╝÷└╟ ╟ⁿ╜─
// ┴∩ └º└╟ ╟╘╝÷╕ª │δ├Γ╜├─╤╛▀ ╟╤┤┘....
////////////////////////////////////////////////////////////////////////////
//
// Video PlugIn Type( Modifyed from Winamp DSP Plugin type ...)
//
// └⌐╛┌╟┴└╟ DSP╟├╖»▒╫└╬└╟ ▒╕┴╢╕ª ┴╢▒▌ ║»░µ╟╪╝¡ KMP└╟ ║±╡≡┐└
// ╟├╖»▒╫└╬└╗ ╗τ┐δ╟╤┤┘.
////////////////////////////////////////////////////////////////////////////
const
IID_IYV12ImageProcessor : TGUID = '{249F44BC-B8BF-411F-B047-D9C017DFECF2}';
type
// KMP┐í╝¡ ┴ª░°╡╟┤┬ ╚¡╗≤└╟ ▒╕┴╢
// KMP┐í╝¡┤┬ ╟├╖╣└╬ YV12└╠╣╠┴÷└╟ ▒╕┴╢╕ª ╗τ┐δ╟╤┤┘.
// Y└╟ ┼⌐▒Γ┤┬ └╠╣╠┴÷└╟ ┼⌐▒Γ┐═ ░░░φ,
// U,V└╟ ┼⌐▒Γ┤┬ ░í╖╬░í 2╣Φ└█░φ, ╝╝╖╬░í 2╣Φ└█┤┘.
// ┴∩ U,V└╟ ┼⌐▒Γ┤┬ Y└╟ ┼⌐▒Γ║╕┤┘ 4╣Φ░í └█┤┘.
PkmpYV12Image = ^TkmpYV12Image;
TkmpYV12Image = record
Width, Height : integer; // ░í╖╬, ╝╝╖╬└╟ ┼⌐▒Γ // ░í╖╬└╟ ░µ┐∞┤┬ 16└╟ ╣Φ╝÷░í ╡╟╛ε╛▀ ╡╩...
y_plain : pChar; // Y╟├╖╣└╬ ╣÷╞█, ┼⌐▒Γ:Width*Height
u_plain : pChar; // U╟├╖╣└╬ ╣÷╞█, ┼⌐▒Γ:Width*Height/4
v_plain : pChar; // V╟├╖╣└╬ ╣÷╞█, ┼⌐▒Γ:Width*Height/4
YMask : pChar; // ┼⌡╕φ└╗ └º╟╤ Y╕╢╜║┼⌐ │╗║╬└√└╕╖╬ ╗τ┐δ
UVMask : pChar; // ┼⌡╕φ└╗ └º╟╤ UV╕╢╜║┼⌐ │╗║╬└√└╕╖╬ ╗τ┐δ
end;
IkmpYV12ImageProcessor = interface
// YV12└╠╣╠┴÷╕ª ░ⁿ╕«╟╧░φ ├│╕«╟╧┤┬╡Ñ ╡╡┐≥└╗ ┴╓┤┬ └╬┼═╞Σ└╠╜║
// ╟÷└τ RGB32,24,565,555└╟ DIB└╠╣╠┴÷╕╕ ┴÷┐°╟╤┤┘.
// ╡¿╞─└╠└╟ ░µ┐∞┤┬ DelphiX└╟ TDIB│¬ TBitmap└╟ DIB╕ª └╠┐δ╟╧╕Θ
// ╜▒░╘ DIB┐═ YV12Image╕ª ├│╕«╟╥╝÷░í └╓┤┘.
// ┐╣┴ª╕ª ┬ⁿ░φ╟╧▒Γ ╣┘╢≈...
['{249F44BC-B8BF-411F-B047-D9C017DFECF2}']
function kmpAllocYV12Image(width,height : integer;out pImage : PkmpYV12Image) : HResult; stdcall;
// width, height└╟ ┼⌐▒Γ╖╬ YV12Image▒╕┴╢├╝╕ª ╕╕╡τ┤┘...
// 2└╟ ╣Φ╝÷╖╬ ┴ñ╖─└╠ ╡╟╛ε └╓╛ε╛▀ ╡╟░φ,
// ░í┤╔╟╧╕Θ 16└╟ ╣Φ╝÷░í ╡╟╛ε └╓╛ε╛▀╕╕ ╛╚┴ñ╟╧░╘ ╡┐└█╟╤┤┘.
// AllocYV12Image╖╬ ╕╕╡τ░═└║ ╛╞╖í└╟ FreeYV12Image╖╬ ╟╪┴ª╕ª ╟╪╛▀ ╡╚┤┘.
function kmpFreeYV12Image(var pImage : PkmpYV12Image) : HResult; stdcall;
// AllocYV12Image╖╬ ╕╕╡τ └╠╣╠┴÷╕ª ╟╪┴ª ╟╤┤┘.
function kmpCopyYV12Image(pSrc,pDst : PkmpYV12Image) : HResult; stdcall;
// YV12Image╕ª ║╣╗τ╟╤┤┘.
function kmpRGB32ToYV12(DIB32 : pByte; Width, Height : integer;pImage : PkmpYV12Image) : HResult; stdcall;
function kmpRGB24ToYV12(DIB24 : pByte; Width, Height : integer;pImage : PkmpYV12Image) : HResult; stdcall;
function kmpRGB565ToYV12(DIB565 : pByte; Width, Height : integer;pImage : PkmpYV12Image) : HResult; stdcall;
function kmpRGB555ToYV12(DIB555 : pByte; Width, Height : integer;pImage : PkmpYV12Image) : HResult; stdcall;
// RGB╞≈╕Σ(DIB)└╗ YV12└╠╣╠┴÷╖╬ ╣┘▓█┤┘.
function kmpYV12ToRGB32(pImage : PkmpYV12Image; DIB32 : pByte; Width, Height : integer) : HResult; stdcall;
function kmpYV12ToRGB24(pImage : PkmpYV12Image; DIB24 : pByte; Width, Height : integer) : HResult; stdcall;
function kmpYV12ToRGB565(pImage : PkmpYV12Image; DIB565 : pByte; Width, Height : integer) : HResult; stdcall;
function kmpYV12ToRGB555(pImage : PkmpYV12Image; DIB555 : pByte; Width, Height : integer) : HResult; stdcall;
// YV12Image└╟ ╟ⁿ╜─└╕╖╬ ╡╚░═└╗ RGB(DIB)└╟ ╟ⁿ╜─└╕╖╬ ╣┘▓█┤┘.
// └╠╢º Height┐í └╜└╟╝÷╕ª │╓╛ε┴╓╕Θ ╚¡╕Θ└╠ ╡┌┴²╛ε┴«╝¡ │¬┐┬┤┘.
// Width┤┬ ╛τ╕╕ ┴÷┐°╟╘...
function kmpYV12NormalDraw(Src,Dst : PkmpYV12Image;SRect : PRect;dx,dy : integer) : HResult; stdcall;
// ╛╞╣½╖▒ ╚┐░· ╛°└╠ └╠╣╠┴÷╕ª ▒╫╕░┤┘.
function kmpYV12BlendDraw(Src,Dst : PkmpYV12Image;SRect : PRect;dx,dy : integer;alpha : integer) : HResult; stdcall;
// ╣▌┼⌡╕φ╚┐░·╖╬ └╠╣╠┴÷╕ª ▒╫╕░┤┘. 0<=alpha<=255
function kmpYV12TransDraw(Src,Dst : PkmpYV12Image;SRect : PRect;dx,dy : integer) : HResult; stdcall;
// ╣Φ░µ╗÷└╗ ┼⌡╕φ└╕╖╬ ▒╫╕░┤┘. ╣Φ░µ╗÷└║ 0╣°┬░ ╗÷└╗ ▒Γ┴╪└╕╖╬ ╟╤┤┘.
function kmpYV12BlendTransDraw(Src,Dst : PkmpYV12Image;SRect : PRect;dx,dy : integer;alpha : integer) : HResult; stdcall;
// ╣Φ░µ╗÷└╗ ┼⌡╕φ└╕╖╬ ▒╫╕«░φ ╣▌┼⌡╕φ╚┐░·╖╬ ▒╫╕░┤┘. 0<=alpha<=255
end;
PkmpDSPModule = ^TkmpDSPModule;
TkmpDSPModule = record
description : pchar; // description
hwndParent : HWND; // parent window (filled in by calling app)
hDllInstance : LongWord; // instance handle to this DLL (filled in by calling app)
Config : procedure(this_mod : PkmpDSPModule); cdecl; // configuration dialog (if needed)
Init : function(this_mod : PkmpDSPModule) : integer; cdecl; // 0 on success, creates window, etc (if needed)
BeforeModifyImage : function(this_mod : PkmpDSPModule;image : PkmpYV12Image;
ewidth : integer) : integer; cdecl; // ┤⌡║φ╗∙╟├└ⁿ┐í ║╥╕«┤┬ ╟╘╝÷
// kmp┐í╝¡ ╗τ┐δ╟╧┤┬ ┐╡╗≤└╗ ║»░µ╟╧┤┬ ╟╘╝÷...
// image : └╠╣╠┴÷└╟ ╣÷╞█, └º┐í╝¡ ╝│╕φ
// ewidth : ╜╟┴·└√└╬ └╠╣╠┴÷└╟ ░í╖╬ ▒µ└╠
// image└╟ width┤┬ ╟╥┤τ╡╚ └╠╣╠┴÷└╟ ░í╖╬▒µ└╠└╠┤┘.
// ╜╟┴·└√└╬░═░· ╟╥┤τ└√└╬░═└╠ ┬≈└╠░í │¬┤┬ └╠└»┤┬ ╟╩┼═╡Θ└╠ ┐¼░ß╡╔╢º┐í┤┬
// ╣÷╞█░í ┴ñ╖─└╠ ╡╟╛ε └╓╛ε╛▀ ╡╩... ╡√╢≤╝¡ ╜╟┴ª╖╬ ┐╡╗≤└╠ ╡Θ╛ε░í └╓┤┬ ▒µ└╠┐═
// ╟╥┤τ╡╚ ╣÷╞█└╟ ▒µ└╠░í ╞▓╖┴┴÷░╘╡╩...
// ║╕┼δ ╚¡╗≤└╗ ├│╕«╟╧┤┬ ░µ┐∞┤┬ ║░╖╬ ╜┼░µ└╗ ╛╩╛▓╡╡ ╡╟┴÷╕╕ ┴┬┐∞╕ª ╡┌┴²┤┬ ░µ┐∞┤┬
// ┐╡╗≤└╟ │í└╗ ╛╦╛╞╛▀╡╟▒Γ ╢º╣«┐í ╞─╢≤╕▐┼═╖╬ │╤░▄┴╪┤┘...
// ┴∩ image└╟ width=ewidth+?? ┐⌐▒Γ╝¡ ??┤┬ ├▀░í ╣┘└╠╞«╖╬ ┴ñ╖─└╗ └º╟╪╝¡ ├▀░í╡╚ ╣┘└╠╞«└╠┤┘.
// ╝╝╖╬┐í╝¡┤┬ ┴ñ╖─└╠ ╟╩┐Σ░í ╛°┤┘.
// ┐╡╗≤└║ ┼⌐▒Γ╕ª ║»░µ╟╥╝÷░í ╛°┤┘.
// ╕«┼╧░¬└║ └╓┴÷╕╕ ├│╕«╟╧┴÷ ╛╩╛╞╡╡ ╡╚┤┘.
AfterModifyImage : function(this_mod : PkmpDSPModule;image : PkmpYV12Image;
ewidth : integer) : integer; cdecl; // ┤⌡║φ╗∙╟├╚─┐í ║╥╕«┤┬ ╟╘╝÷
// ╞─╢≤╣╠┼═┤┬ └º┐═ ░░└╜.
// BeforeModifyImage└╟ ░µ┐∞┤┬ ┤⌡║φ╗∙╟├└╠ ╡┐└█╟╥╢º╕╕ ║╥╕«╛ε┴÷░╘ ╡╚┤┘.
// ╡√╢≤╝¡ ┴╗┤⌡║ⁿ╕Ñ └╠╣╠┴÷ ├│╕«╕ª └º╟╪╝¡┤┬ BeforeModifyImage╕ª
// ├│╕«╟╧╕Θ ╡╚┤┘.
// ┴∩ ┤⌡║φ╗∙╟├ ╡┐└█╜├ BeforeModifyImage -> AfterModifyImage
// ╛╚╟╧╕Θ AfterModifyImage
// ├│╕«╕ª ╛╚╟╥╖┴╕Θ nil╖╬ ╝│┴ñ╟╧╕Θ ╡╩....
//
Quit : procedure(this_mod : PkmpDSPModule); cdecl; // called when unloading
userData : Pointer; // user data, optional
ImageProcessor : IkmpYV12ImageProcessor; // └╠╣╠┴÷ ├│╕«╕ª └º╟╤ └╬┼═╞Σ└╠╜║
// └º┐í╝¡ ╝│╕φ
end;
PkmpDSPHeader = ^TkmpDSPHeader;
TkmpDSPHeader = record
version : integer; // DSP_HDRVER
description : pchar; // description of library
kmpDSPModule : function(num : integer) : PkmpDSPModule; cdecl; // module retrieval function
end;
///////////////////////////////////////
// Video PlugIn DLL Exports...
///////////////////////////////////////
//function kmpDSPGetHeader2 : PkmpDSPHeader; cdecl;
// ┐╡╗≤ DLL┐í╝¡ Export╟╪╛▀╡╟┤┬ ╟╘╝÷└╟ ╟ⁿ╜─
// ┴∩ └º└╟ ╟╘╝÷╕ª │δ├Γ╜├─╤╛▀ ╟╤┤┘....
implementation
end.