avs_ape.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // AVS APE (Plug-in Effect) header
  2. // base class to derive from
  3. class C_RBASE {
  4. public:
  5. C_RBASE() { }
  6. virtual ~C_RBASE() { };
  7. virtual int render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)=0; // returns 1 if fbout has dest, 0 if framebuffer has dest
  8. virtual HWND conf(HINSTANCE hInstance, HWND hwndParent){return 0;};
  9. virtual char *get_desc()=0;
  10. virtual void load_config(unsigned char *data, int len) { }
  11. virtual int save_config(unsigned char *data) { return 0; }
  12. };
  13. // if you want to support SMP rendering, you can derive from this class instead,
  14. // and expose the creator via: _AVS_APE_RetrFuncEXT2
  15. // (in general, exposing both for compatibility is a good idea)
  16. class C_RBASE2 : public C_RBASE {
  17. public:
  18. C_RBASE2() { }
  19. virtual ~C_RBASE2() { };
  20. int getRenderVer2() { return 2; }
  21. virtual int smp_getflags() { return 0; } // return 1 to enable smp support
  22. // returns # of threads you desire, <= max_threads, or 0 to not do anything
  23. // default should return max_threads if you are flexible
  24. virtual int smp_begin(int max_threads, char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h) { return 0; }
  25. virtual void smp_render(int this_thread, int max_threads, char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h) { };
  26. virtual int smp_finish(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h) { return 0; }; // return value is that of render() for fbstuff etc
  27. };
  28. // lovely helper functions for blending
  29. static unsigned int __inline BLEND(unsigned int a, unsigned int b)
  30. {
  31. register unsigned int r,t;
  32. r=(a&255)+((b)&255);
  33. t=min(r,255);
  34. r=((a>>8)&255)+((b>>8)&255);
  35. t|=min(r,255)<<8;
  36. r=((a>>16)&255)+((b>>16)&255);
  37. return t|min(r,255)<<16;
  38. }
  39. static unsigned int __inline BLEND_AVG(unsigned int a, unsigned int b)
  40. {
  41. return ((a>>1)&~((1<<7)|(1<<15)|(1<<23)))+((b>>1)&~((1<<7)|(1<<15)|(1<<23)));
  42. }
  43. //extended APE stuff
  44. // to use this, you should have:
  45. // APEinfo *g_extinfo;
  46. // void __declspec(dllexport) AVS_APE_SetExtInfo(HINSTANCE hDllInstance, APEinfo *ptr)
  47. // {
  48. // g_extinfo = ptr;
  49. // }
  50. typedef void *VM_CONTEXT;
  51. typedef void *VM_CODEHANDLE;
  52. typedef struct
  53. {
  54. int ver; // ver=1 to start
  55. double *global_registers; // 100 of these
  56. // lineblendmode: 0xbbccdd
  57. // bb is line width (minimum 1)
  58. // dd is blend mode:
  59. // 0=replace
  60. // 1=add
  61. // 2=max
  62. // 3=avg
  63. // 4=subtractive (1-2)
  64. // 5=subtractive (2-1)
  65. // 6=multiplicative
  66. // 7=adjustable (cc=blend ratio)
  67. // 8=xor
  68. // 9=minimum
  69. int *lineblendmode;
  70. //evallib interface
  71. VM_CONTEXT (*allocVM)(); // return a handle
  72. void (*freeVM)(VM_CONTEXT); // free when done with a VM and ALL of its code have been freed, as well
  73. // you should only use these when no code handles are around (i.e. it's okay to use these before
  74. // compiling code, or right before you are going to recompile your code.
  75. void (*resetVM)(VM_CONTEXT);
  76. double * (*regVMvariable)(VM_CONTEXT, char *name);
  77. // compile code to a handle
  78. VM_CODEHANDLE (*compileVMcode)(VM_CONTEXT, char *code);
  79. // execute code from a handle
  80. void (*executeCode)(VM_CODEHANDLE, char visdata[2][2][576]);
  81. // free a code block
  82. void (*freeCode)(VM_CODEHANDLE);
  83. // requires ver >= 2
  84. void (*doscripthelp)(HWND hwndDlg,char *mytext); // mytext can be NULL for no custom page
  85. /// requires ver >= 3
  86. void *(*getNbuffer)(int w, int h, int n, int do_alloc); // do_alloc should be 0 if you dont want it to allocate if empty
  87. // w and h should be the current width and height
  88. // n should be 0-7
  89. } APEinfo;