home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 April / PCWorld_2007-04_cd.bin / audio-video / kmplayer / kmp.exe / SDK / KMPPlgIn.h < prev    next >
C/C++ Source or Header  |  2002-09-02  |  10KB  |  237 lines

  1. #include <windows.h>
  2. #include <objbase.h>
  3. #include <initguid.h>
  4. #if (1100 > _MSC_VER)
  5. #include <olectlid.h>
  6. #else
  7. #include <olectl.h>
  8. #endif
  9. #include <stdio.h>
  10.  
  11.  
  12. /////////////////////////////////////////////////////////////////////////////
  13. //
  14. //          KMP┐δ ┐└╡≡┐└/║±╡≡┐└ ╟├╖»▒╫└╬ └╬┼═╞Σ└╠╜║
  15. //
  16. //  KMP└╟ ╟├╖»▒╫└╬ ╕≡╡Γ└║ └⌐╛┌╟┴└╟ DSP╟├╖»▒╫└╬░·
  17. // ▒╕┴╢░í ░┼└╟ ░░┤┘. ┐└╡≡┐└ ╟├╖»▒╫└╬└╟ ░µ┐∞┤┬ └╚╛┌╟┴┐═ ▒╕┴╢░í
  18. // ░░▒Γ ╢º╣«┐í └⌐╛┌╟┴└╟ DSP╟├╖»▒╫└╬└╗ KMP┐í╝¡ ╗τ┐δ╟╧┤┬ ░═└╠ ░í┤╔╟╧┤┘.
  19. // ║±╡≡┐└ ╟├╖»▒╫└╬└╟ ░µ┐∞╡╡ ░┼└╟ ║±╜┴╟╧╣╟╖╬ ╜▒░╘ └█╝║╟╥╝÷░í └╓└╗░═└╠┤┘.
  20. // ▒╫╕«░φ ╟╘╝÷ ▒╘╛α└╠ cdel└╠┤┘.. ┬ⁿ░φ...
  21. //
  22. // ┐╡╗≤╟├╖»▒╫└╬└╟ ░µ┐∞┤┬ WaSaVi┐═ ┤▐╢≤┴│┤┘... ╢╟╟╤ ┬ⁿ░φ...
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25.  
  26.  
  27. // header version: 0x20 == 0.20 == winamp 2.0
  28. #define DSP_HDRVER 0x20
  29.  
  30.  
  31.  
  32. // DSP plugin interface
  33.  
  34. // notes:
  35. // any window that remains in foreground should optimally pass unused
  36. // keystrokes to the parent (winamp's) window, so that the user
  37. // can still control it. As for storing configuration,
  38. // Configuration data should be stored in <dll directory>\plugin.ini
  39. // (look at the vis plugin for configuration code)
  40.  
  41. typedef struct winampDSPModule {
  42.   char *description;        // description
  43.   HWND hwndParent;            // parent window (filled in by calling app)
  44.   HINSTANCE hDllInstance;    // instance handle to this DLL (filled in by calling app)
  45.  
  46.   void (*Config)(struct winampDSPModule *this_mod);  // configuration dialog (if needed)
  47.   int (*Init)(struct winampDSPModule *this_mod);     // 0 on success, creates window, etc (if needed)
  48.  
  49.   // modify waveform samples: returns number of samples to actually write
  50.   // (typically numsamples, but no more than twice numsamples, and no less than half numsamples)
  51.   // numsamples should always be at least 128. should, but I'm not sure
  52.   int (*ModifySamples)(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate);
  53.    // └⌐╛┌╟┴┐í╝¡ ╗τ┐δ╟╧┤┬ └╜╝║└╗ ║»░µ╟╧┤┬ ╟╘╝÷...
  54.    // samples : ╗∙╟├└╠ ╡Θ╛ε░í └╓┤┬ ╣÷╞█
  55.    // numsamples : ╗∙╟├└╟ ░╣╝÷(╜╟┴·└√└╬ ╣÷╞█└╟ ▒µ└╠░í ╛╞┤╧╢≤ ╗∙╟├└╟ ░╣╝÷└╙...
  56.    // bps : ╗∙╟├┤τ ║±╞«╝÷ 8 or 16
  57.    // nch : ├ñ│╬╝÷ 1 : ╕≡│δ  , 2 : ╜║╞«╖╣┐└
  58.    // srate : ╗∙╟├╕╡ ╖╣└╠╞« 44000╡ε╡ε..
  59.    // └╠╟╘╝÷┐í╝¡ ╕«┼╧░¬└╠ ║»░µ╟╤ ╡Ñ└╠┼╕└╟ ░╣╝÷└╠┤┘. ╢╟╟╤ ╜╟┴·└√└╕╖╬ ├Γ╖┬└╕╖╬
  60.    // │¬░í┤┬ ░╣╝÷└╠▒Γ╡╡ ╟╧┤┘. └⌐╛┌╟┴┐í╝¡ ┼╫╜║╞«╟╤ ░µ┐∞┤┬ └╘╖┬╣▐└║ ╗∙╟├║╕┤┘
  61.    // ╕╣░╘╟╪╡╡ ╡┐└█└╗ ╟╧┐┤┤┘. ╡√╢≤╝¡ KMP┐í╝¡╡╡ └╘╖┬║╕┤┘ 3-4╣Φ┴ñ╡╡└╟
  62.    // ╕▐╕≡╕«╕ª │╗║╬└√└╕╖╬ ╟╥┤τ└╗ ╟╪│⌡╛╥┤┘. ▒╫╖»╣╟╖╬ 3-4╣Φ └╠╗≤└╗ ├│╕«╟╧╕Θ ┐└╖∙░í
  63.    // └╧╛ε│»╝÷╡╡ └╓┤┘...
  64.    //
  65.  
  66.   
  67.   void (*Quit)(struct winampDSPModule *this_mod);    // called when unloading
  68.  
  69.   void *userData; // user data, optional
  70. } winampDSPModule;
  71.  
  72. typedef struct {
  73.   int version;       // DSP_HDRVER
  74.   char *description; // description of library
  75.   winampDSPModule* (*getModule)(int);    // module retrieval function
  76. } winampDSPHeader;
  77.  
  78. // exported symbols
  79. typedef winampDSPHeader* (*winampDSPGetHeaderType)();
  80. // winampDSPHeader *winampDSPGetHeader2()
  81. // └╜╝║ DLL┐í╝¡ Exports╟╪╛▀ ╡╟┤┬ ╟╘╝÷└╟ ╟ⁿ╜─
  82. // ┴∩ └º└╟ ╟╘╝÷╕ª │δ├Γ╜├─╤╛▀ ╟╤┤┘....
  83.  
  84.  
  85.  
  86.  
  87.  
  88. ////////////////////////////////////////////////////////////////////////////
  89. //
  90. // Video PlugIn Type( Modifyed from Winamp DSP Plugin type ...)
  91. //
  92. // └⌐╛┌╟┴└╟ DSP╟├╖»▒╫└╬└╟ ▒╕┴╢╕ª ┴╢▒▌ ║»░µ╟╪╝¡ KMP└╟ ║±╡≡┐└
  93. // ╟├╖»▒╫└╬└╗ ╗τ┐δ╟╤┤┘.
  94. ////////////////////////////////////////////////////////////////////////////
  95.  
  96.  
  97.  
  98.  
  99.  // KMP┐í╝¡ ┴ª░°╡╟┤┬ ╚¡╗≤└╟ ▒╕┴╢
  100.  // KMP┐í╝¡┤┬ ╟├╖╣└╬ YV12└╠╣╠┴÷└╟ ▒╕┴╢╕ª ╗τ┐δ╟╤┤┘.
  101.  // Y└╟ ┼⌐▒Γ┤┬ └╠╣╠┴÷└╟ ┼⌐▒Γ┐═ ░░░φ,
  102.  // U,V└╟ ┼⌐▒Γ┤┬ ░í╖╬░í 2╣Φ└█░φ, ╝╝╖╬░í 2╣Φ└█┤┘.
  103.  // ┴∩ U,V└╟ ┼⌐▒Γ┤┬ Y└╟ ┼⌐▒Γ║╕┤┘ 4╣Φ░í └█┤┘.
  104. typedef struct kmpYV12Image {
  105.    int Width, Height; // ░í╖╬, ╝╝╖╬└╟ ┼⌐▒Γ
  106.    unsigned char *y_plain; // Y╟├╖╣└╬ ╣÷╞█, ┼⌐▒Γ:Width*Height
  107.    unsigned char *u_plain; // U╟├╖╣└╬ ╣÷╞█, ┼⌐▒Γ:Width*Height/4
  108.    unsigned char *v_plain; // V╟├╖╣└╬ ╣÷╞█, ┼⌐▒Γ:Width*Height/4
  109.    unsigned char *Mask;    // ┼⌡╕φ└╗ └º╟╤ ╕╢╜║┼⌐ │╗║╬└√└╕╖╬ ╗τ┐δ
  110. } kmpYV12Image;
  111.  
  112.  
  113. DEFINE_GUID(IID_IYV12ImageProcessor,
  114. 0x249F44BC, 0xB8BF, 0x411F, 0xB0, 0x47, 0xD9, 0xC0, 0x17, 0xDF, 0xEC, 0xF2);
  115.  
  116. DECLARE_INTERFACE_(IkmpYV12ImageProcessor, IUnknown)
  117. {
  118.  // YV12└╠╣╠┴÷╕ª ░ⁿ╕«╟╧░φ ├│╕«╟╧┤┬╡Ñ ╡╡┐≥└╗ ┴╓┤┬ └╬┼═╞Σ└╠╜║
  119.  // ╟÷└τ RGB32,24,565,555└╟ DIB└╠╣╠┴÷╕╕ ┴÷┐°╟╤┤┘.
  120.  // ┐╣┴ª╕ª ┬ⁿ░φ╟╧▒Γ ╣┘╢≈...
  121.    STDMETHOD(kmpAllocYV12Image) (THIS_
  122.         int width,int height,kmpYV12Image **pImage
  123.              ) PURE;
  124.             // width, height└╟ ┼⌐▒Γ╖╬ YV12Image▒╕┴╢├╝╕ª ╕╕╡τ┤┘...
  125.             // 2└╟ ╣Φ╝÷╖╬ ┴ñ╖─└╠ ╡╟╛ε └╓╛ε╛▀ ╡╟░φ,
  126.             // ░í┤╔╟╧╕Θ 16└╟ ╣Φ╝÷░í ╡╟╛ε └╓╛ε╛▀╕╕ ╛╚┴ñ╟╧░╘ ╡┐└█╟╤┤┘.
  127.             // AllocYV12Image╖╬ ╕╕╡τ░═└║ ╛╞╖í└╟ FreeYV12Image╖╬ ╟╪┴ª╕ª ╟╪╛▀ ╡╚┤┘.
  128.    STDMETHOD(kmpFreeYV12Image) (THIS_
  129.         kmpYV12Image **pImage
  130.             ) PURE;
  131.             // AllocYV12Image╖╬ ╕╕╡τ └╠╣╠┴÷╕ª ╟╪┴ª ╟╤┤┘.
  132.    STDMETHOD(kmpCopyYV12Image) (THIS_
  133.         kmpYV12Image *pSrc,kmpYV12Image *pDst
  134.             ) PURE;
  135.             // YV12Image╕ª ║╣╗τ╟╤┤┘.
  136.    STDMETHOD(kmpRGB32ToYV12) (THIS_
  137.         void *DIB32,int Width,int Height,kmpYV12Image *pImage
  138.             ) PURE;
  139.    STDMETHOD(kmpRGB24ToYV12) (THIS_
  140.         void *DIB24,int Width,int Height,kmpYV12Image *pImage
  141.             ) PURE;
  142.    STDMETHOD(kmpRGB565ToYV12) (THIS_
  143.         void *DIB565,int Width,int Height,kmpYV12Image *pImage
  144.             ) PURE;
  145.    STDMETHOD(kmpRGB555ToYV12) (THIS_
  146.         void *DIB555,int Width,int Height,kmpYV12Image *pImage
  147.             ) PURE;
  148.             // RGB╞≈╕Σ(DIB)└╗ YV12└╠╣╠┴÷╖╬ ╣┘▓█┤┘.
  149.    STDMETHOD(kmpYV12ToRGB32) (THIS_
  150.         kmpYV12Image *pImage,void *DIB32,int Width,int Height
  151.             ) PURE;
  152.    STDMETHOD(kmpYV12ToRGB24) (THIS_
  153.         kmpYV12Image *pImage,void *DIB24,int Width,int Height
  154.             ) PURE;
  155.    STDMETHOD(kmpYV12ToRGB565) (THIS_
  156.         kmpYV12Image *pImage,void *DIB565,int Width,int Height
  157.             ) PURE;
  158.    STDMETHOD(kmpYV12ToRGB555) (THIS_
  159.         kmpYV12Image *pImage,void *DIB555,int Width,int Height
  160.             ) PURE;
  161.             // YV12Image└╟ ╟ⁿ╜─└╕╖╬ ╡╚░═└╗ RGB(DIB)└╟ ╟ⁿ╜─└╕╖╬ ╣┘▓█┤┘.
  162.             // └╠╢º Height┐í └╜└╟╝÷╕ª │╓╛ε┴╓╕Θ ╚¡╕Θ└╠ ╡┌┴²╛ε┴«╝¡ │¬┐┬┤┘.
  163.             // Width┤┬ ╛τ╕╕ ┴÷┐°╟╘...
  164.    STDMETHOD(kmpYV12NormalDraw) (THIS_
  165.         kmpYV12Image *Src,kmpYV12Image *Dst,RECT *SRect,int dx,int dy
  166.             ) PURE;
  167.             // ╛╞╣½╖▒ ╚┐░· ╛°└╠ └╠╣╠┴÷╕ª ▒╫╕░┤┘.
  168.    STDMETHOD(kmpYV12BlendDraw) (THIS_
  169.         kmpYV12Image *Src,kmpYV12Image *Dst,RECT *SRect,int dx,int dy,int alpha
  170.             ) PURE;
  171.             // ╣▌┼⌡╕φ╚┐░·╖╬ └╠╣╠┴÷╕ª ▒╫╕░┤┘. 0<=alpha<=255
  172.    STDMETHOD(kmpYV12TransDraw) (THIS_
  173.         kmpYV12Image *Src,kmpYV12Image *Dst,RECT *SRect,int dx,int dy
  174.             ) PURE;
  175.             // ╣Φ░µ╗÷└╗ ┼⌡╕φ└╕╖╬ ▒╫╕░┤┘. ╣Φ░µ╗÷└║ 0╣°┬░ ╗÷└╗ ▒Γ┴╪└╕╖╬ ╟╤┤┘.
  176.    STDMETHOD(kmpYV12BlendTransDraw) (THIS_
  177.         kmpYV12Image *Src,kmpYV12Image *Dst,RECT *SRect,int dx,int dy,int alpha
  178.             ) PURE;
  179.             // ╣Φ░µ╗÷└╗ ┼⌡╕φ└╕╖╬ ▒╫╕«░φ, └ⁿ├╝╕ª ╣▌┼⌡╕φ╚┐░·╖╬ ▒╫╕░┤┘. 0<=alpha<=255
  180. };
  181.  
  182.  
  183.  
  184. typedef struct kmpDSPModule {
  185.   char *description;        // description
  186.   HWND hwndParent;            // parent window (filled in by calling app)
  187.   HINSTANCE hDllInstance;    // instance handle to this DLL (filled in by calling app)
  188.  
  189.   void (*Config)(struct kmpDSPModule *this_mod);  // configuration dialog (if needed)
  190.   int (*Init)(struct kmpDSPModule *this_mod);     // 0 on success, creates window, etc (if needed)
  191.  
  192.   // modify waveform samples: returns number of samples to actually write
  193.   // (typically numsamples, but no more than twice numsamples, and no less than half numsamples)
  194.   // numsamples should always be at least 128. should, but I'm not sure
  195.   int (*BeforeModifySamples)(struct kmpDSPModule *this_mod,struct kmpYV12Image *image,int ewidth); // ╗∙╟├└╗ ║»░µ╟╧┤┬╟╘╝÷
  196.    // kmp┐í╝¡ ╗τ┐δ╟╧┤┬ ┐╡╗≤└╗ ║»░µ╟╧┤┬ ╟╘╝÷...
  197.    // image : └╠╣╠┴÷└╟ ╣÷╞█, └º┐í╝¡ ╝│╕φ
  198.    // ewidth : ╜╟┴·└√└╬ └╠╣╠┴÷└╟ ░í╖╬ ▒µ└╠
  199.    // image└╟ width┤┬ ╟╥┤τ╡╚ └╠╣╠┴÷└╟ ░í╖╬▒µ└╠└╠┤┘.
  200.    // ╜╟┴·└√└╬░═░· ╟╥┤τ└√└╬░═└╠ ┬≈└╠░í │¬┤┬ └╠└»┤┬ ╟╩┼═╡Θ└╠ ┐¼░ß╡╔╢º┐í┤┬
  201.    // ╣÷╞█░í ┴ñ╖─└╠ ╡╟╛ε └╓╛ε╛▀ ╡╩... ╡√╢≤╝¡ ╜╟┴ª╖╬ ┐╡╗≤└╠ ╡Θ╛ε░í └╓┤┬ ▒µ└╠┐═
  202.    // ╟╥┤τ╡╚ ╣÷╞█└╟ ▒µ└╠░í ╞▓╖┴┴÷░╘╡╩...
  203.    // ║╕┼δ ╚¡╗≤└╗ ├│╕«╟╧┤┬ ░µ┐∞┤┬ ║░╖╬ ╜┼░µ└╗ ╛╩╛▓╡╡ ╡╟┴÷╕╕ ┴┬┐∞╕ª ╡┌┴²┤┬ ░µ┐∞┤┬
  204.    // ┐╡╗≤└╟ │í└╗ ╛╦╛╞╛▀╡╟▒Γ ╢º╣«┐í ╞─╢≤╕▐┼═╖╬ │╤░▄┴╪┤┘...
  205.    // ┴∩ image└╟ width=ewidth+?? ┐⌐▒Γ╝¡ ??┤┬ ├▀░í ╣┘└╠╞«╖╬ ┴ñ╖─└╗ └º╟╪╝¡ ├▀░í╡╚ ╣┘└╠╞«└╠┤┘.
  206.    // ╝╝╖╬┐í╝¡┤┬ ┴ñ╖─└╠ ╟╩┐Σ░í ╛°┤┘.
  207.    // ┐╡╗≤└║ ┼⌐▒Γ╕ª ║»░µ╟╥╝÷░í ╛°┤┘.
  208.    // ╕«┼╧░¬└║ └╓┴÷╕╕ ├│╕«╟╧┴÷ ╛╩╛╞╡╡ ╡╚┤┘.
  209.   int (*AfterModifySamples)(struct kmpDSPModule *this_mod,struct kmpYV12Image *image,int ewidth); // ╗∙╟├└╗ ║»░µ╟╧┤┬╟╘╝÷
  210.    // ╞─╢≤╣╠┼═┤┬ └º┐═ ░░└╜.
  211.    // BeforeModifyImage└╟ ░µ┐∞┤┬ ┤⌡║φ╗∙╟├└╠ ╡┐└█╟╥╢º╕╕ ║╥╕«╛ε┴÷░╘ ╡╚┤┘.
  212.    // ╡√╢≤╝¡ ┴╗┤⌡║ⁿ╕Ñ └╠╣╠┴÷ ├│╕«╕ª └º╟╪╝¡┤┬ BeforeModifyImage╕ª
  213.    // ├│╕«╟╧╕Θ ╡╚┤┘.
  214.    // ┴∩ ┤⌡║φ╗∙╟├ ╡┐└█╜├  BeforeModifyImage -> AfterModifyImage
  215.    //             ╛╚╟╧╕Θ        AfterModifyImage
  216.    //  ├│╕«╕ª ╛╚╟╥╖┴╕Θ NULL╖╬ ╝│┴ñ╟╧╕Θ ╡╩....
  217.    //
  218.  
  219.   void (*Quit)(struct kmpDSPModule *this_mod);    // called when unloading
  220.  
  221.   void *userData; // user data, optional
  222.   IkmpYV12ImageProcessor *ImageProcessor; // └╠╣╠┴÷├│╕«╕ª └º╟╤ └╬┼═╞Σ└╠╜║
  223.                                           // └º┐í╝¡ ╝│╕φ  
  224. } kmpDSPModule;
  225.  
  226. typedef struct {
  227.   int version;       // DSP_HDRVER
  228.   char *description; // description of library
  229.   kmpDSPModule* (*getModule)(int);    // module retrieval function
  230. } kmpDSPHeader;
  231.  
  232. // exported symbols
  233. typedef kmpDSPHeader* (*kmpDSPGetHeaderType)();
  234. // kmpDSPHeader *kmpDSPGetHeader2()
  235. // ┐╡╗≤ DLL┐í╝¡ Export╟╪╛▀╡╟┤┬ ╟╘╝÷└╟ ╟ⁿ╜─
  236. // ┴∩ └º└╟ ╟╘╝÷╕ª │δ├Γ╜├─╤╛▀ ╟╤┤┘....
  237.