w5s.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #define WIN32_LEAN_AND_MEAN
  2. #include <windows.h>
  3. #include "api__jpeg.h"
  4. #include "main.h"
  5. #include "w5s.h"
  6. #include "writer_jpg.h"
  7. #include "loader_jpg.h"
  8. #include "mp4_jpeg_decoder.h"
  9. #include "avi_mjpg_decoder.h"
  10. #include "../nu/Singleton.h"
  11. #include "../nu/factoryt.h"
  12. #include "amg.h"
  13. /*
  14. void MMXInit()
  15. {
  16. DWORD retval1, retval2;
  17. __try {
  18. _asm {
  19. mov eax, 1 // set up CPUID to return processor version and features
  20. // 0 = vendor string, 1 = version info, 2 = cache info
  21. _emit 0x0f // code bytes = 0fh, 0a2h
  22. _emit 0xa2
  23. mov retval1, eax
  24. mov retval2, edx
  25. }
  26. } __except(EXCEPTION_EXECUTE_HANDLER) { retval1 = retval2 = 0;}
  27. isMMX = retval1 && (retval2 & 0x800000);
  28. }
  29. */
  30. static ServiceFactoryT<MP4VideoDecoder, MP4JPEGDecoder> mp4Factory;
  31. static ServiceFactoryT<svc_imageWriter, JpgWrite> jpegWriterFactory;
  32. static ServiceFactoryT<svc_imageLoader, JpgLoad> jpegLoaderFactory;
  33. static WA5_JPEG wa5_jpeg;
  34. static AMGSucks amgSucks;
  35. static SingletonServiceFactory<api_amgsucks, AMGSucks> amgSucksFactory;
  36. static AVIDecoderCreator aviCreator;
  37. static SingletonServiceFactory<svc_avidecoder, AVIDecoderCreator> aviFactory;
  38. //bool isMMX=false;
  39. api_service *serviceManager=0;
  40. api_memmgr *memoryManager=0;
  41. void WA5_JPEG::RegisterServices(api_service *service)
  42. {
  43. //MMXInit();
  44. WASABI_API_SVC = service;
  45. // get memory manager
  46. waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(memMgrApiServiceGuid);
  47. if (sf) memoryManager = reinterpret_cast<api_memmgr *>(sf->getInterface());
  48. WASABI_API_SVC->service_register(&jpegLoaderFactory);
  49. WASABI_API_SVC->service_register(&jpegWriterFactory);
  50. WASABI_API_SVC->service_register(&mp4Factory);
  51. amgSucksFactory.Register(WASABI_API_SVC, &amgSucks);
  52. aviFactory.Register(WASABI_API_SVC, &aviCreator);
  53. }
  54. int WA5_JPEG::RegisterServicesSafeModeOk()
  55. {
  56. return 1;
  57. }
  58. void WA5_JPEG::DeregisterServices(api_service *service)
  59. {
  60. service->service_deregister(&jpegWriterFactory);
  61. service->service_deregister(&jpegLoaderFactory);
  62. service->service_deregister(&mp4Factory);
  63. amgSucksFactory.Deregister(service);
  64. aviFactory.Deregister(WASABI_API_SVC);
  65. waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(memMgrApiServiceGuid);
  66. if (sf) sf->releaseInterface(memoryManager);
  67. }
  68. extern "C" __declspec(dllexport) ifc_wa5component *GetWinamp5SystemComponent()
  69. {
  70. return &wa5_jpeg;
  71. }
  72. #ifdef CBCLASS
  73. #undef CBCLASS
  74. #endif
  75. #define CBCLASS WA5_JPEG
  76. START_DISPATCH;
  77. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  78. CB(15, RegisterServicesSafeModeOk)
  79. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  80. END_DISPATCH;