1
0

dec_if.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. ** dec_if.h - common decoder interface for nsvplay/nsvplayx
  3. **
  4. ** Copyright (C) 2001-2003 Nullsoft, Inc.
  5. **
  6. ** This software is provided 'as-is', without any express or implied warranty.
  7. ** In no event will the authors be held liable for any damages arising from the use of this software.
  8. **
  9. ** Permission is granted to anyone to use this software for any purpose, including commercial
  10. ** applications, and to alter it and redistribute it freely, subject to the following restrictions:
  11. ** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
  12. ** original software. If you use this software in a product, an acknowledgment in the product
  13. ** documentation would be appreciated but is not required.
  14. ** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
  15. ** being the original software.
  16. ** 3. This notice may not be removed or altered from any source distribution.
  17. **
  18. */
  19. #ifndef _NSV_DEC_IF_H_
  20. #define _NSV_DEC_IF_H_
  21. #ifndef _WA_IPC_H_ // these are also defined in Winamp/wa_ipc.h
  22. struct YV12_PLANE {
  23. unsigned char* baseAddr;
  24. long rowBytes;
  25. } ;
  26. struct YV12_PLANES {
  27. YV12_PLANE y;
  28. YV12_PLANE u;
  29. YV12_PLANE v;
  30. } ;
  31. #endif
  32. class IVideoDecoder
  33. {
  34. public:
  35. virtual ~IVideoDecoder() { }
  36. // decode returns 0 on success
  37. // but *out can be NULL, meaning no new frame is available,
  38. // but all is well
  39. virtual int decode(int need_kf,
  40. void *in, int in_len,
  41. void **out, // out is set to a pointer to data
  42. unsigned int *out_type, // 'Y','V','1','2' is currently defined
  43. int *is_kf)=0;
  44. virtual void flush()=0;
  45. };
  46. class IAudioDecoder
  47. {
  48. public:
  49. virtual ~IAudioDecoder() { }
  50. // returns -1 on error, 0 on success (done with data in 'in'), 1 on success
  51. // but to pass 'in' again next time around.
  52. virtual int decode(void *in, int in_len,
  53. void *out, int *out_len, // out_len is read and written to
  54. unsigned int out_fmt[8])=0; // out_fmt is written to
  55. // ex: 'PCM ', srate, nch, bps
  56. // or 'NONE' :)
  57. virtual void flush()=0;
  58. };
  59. class IAudioOutput
  60. {
  61. public:
  62. virtual ~IAudioOutput() { }
  63. virtual int canwrite()=0; // returns bytes writeable
  64. virtual void write(void *buf, int len)=0;
  65. virtual unsigned long long getpos()=0;
  66. virtual unsigned long long getwritepos()=0;
  67. virtual void flush(unsigned int newtime)=0;
  68. virtual int isplaying(void) { return 1; }
  69. virtual void pause(int pause) { }
  70. virtual void setvolume(int volume) { }
  71. virtual void setpan(int pan) { }
  72. virtual void getdescstr(char *buf) { *buf=0; }
  73. };
  74. /*
  75. ** The DLL must export one of these symbols (unmangled, i.e. using extern "C).
  76. **
  77. ** IAudioDecoder *CreateAudioDecoder(unsigned int type, IAudioOutput **output);
  78. ** IVideoDecoder *CreateVideoDecoder(int w, int h, double framerate, unsigned int type, int *flip);
  79. **
  80. ** the functions should return NULL if the conversion is not possible (or
  81. ** is not the correct format)
  82. **
  83. ** The DLL must be in <program files>\common files\nsv, and must be named
  84. ** nsvdec_*.dll.
  85. **
  86. */
  87. #endif//_NSV_DEC_IF_H_