duck_dxa.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #ifndef _duck_dxa_h
  2. #define _duck_dxa_h
  3. #include "duck_wav.h"
  4. #if defined(__cplusplus)
  5. extern "C" {
  6. #endif
  7. typedef struct tXAudioSource* DXL_XAUDIOSRC_HANDLE; /* forward looking ! */
  8. #define MAX_AUDIO_REGISTRATIONS 20
  9. /* Structure used to register DXA plugins with dxa by formatTag. */
  10. /*-------------------------------------------------------------------------*/
  11. typedef struct tXAudioRegistration {
  12. unsigned short formatTag;
  13. int (*audio_dxer_init)(DXL_XAUDIOSRC_HANDLE src);
  14. int (*audio_dxer_dx)(DXL_XAUDIOSRC_HANDLE src, void *left, void *right, int nSamples);
  15. int (*audio_dxer_exit)(DXL_XAUDIOSRC_HANDLE src);
  16. int (*audio_dxer_clear)(DXL_XAUDIOSRC_HANDLE src);
  17. } DXL_AUDIO_REGISTRATION;
  18. /* If it's not documented here, if it's only defined here ... then it's probably not needed by most codec plugins */
  19. /* It may only be used internally to dxa . */
  20. /*----------------------------------------------------------------------------------------------------------------*/
  21. typedef struct tXAudioSource
  22. {
  23. unsigned char *addr; /* address from which to read compressed audio bytes */
  24. int totalPos;
  25. int length; /* length of compressed audio bytes to read from buffer */
  26. int interleave;
  27. short aiSamp[2],aiStepIndex[2];
  28. int blockFinished; /* flags audio system that new data in buffer */
  29. int samplesRead;
  30. UINT64 profileStartTime;
  31. UINT64 profileEndTime;
  32. UINT64 dxClocks;
  33. UINT64 samplesDXed;
  34. short iFirstNibble;
  35. short iNextInput;
  36. short sum,diff,nudiff;
  37. DKWAVEFORM wv; /* details of the compressed audio data */
  38. DXL_AUDIO_REGISTRATION registration;
  39. void* more; /* user data ... plugin data */
  40. } DXL_XAUDIOSRC;
  41. typedef struct tAudioBuff *DXL_AUDIODST_HANDLE;
  42. /* audio function prototypes */
  43. /*@
  44. @Name DXL_InitAudio
  45. @Description Initialize audio decompression services. This function allocates memory for requested object pools.
  46. @Return value DXL_OK on success, or negative error code.
  47. @*/
  48. int DXL_InitAudio(
  49. int srcs, /* max number of audio sources to be created. */
  50. int dsts /* max number of audio destinations to be created. */
  51. );
  52. /*@
  53. @Name DXL_ExitAudio
  54. @Description Shutdown audio decompression services, freeing allocated objects.
  55. @Return value none.
  56. @*/
  57. void DXL_ExitAudio(void);
  58. typedef struct tDKWAVEFORM *DKWAVEFORMPTR; /* place holder pointer */
  59. /*@
  60. @Name DXL_CreateXAudioSrc
  61. @Description Create a compressed audio source (decompressor)
  62. @Return value returns an DXL_XAUDIOSRC_HANDLE or null unable to create audio source object.
  63. @*/
  64. DXL_XAUDIOSRC_HANDLE DXL_CreateXAudioSrc(
  65. DKWAVEFORMPTR wv, /* pointer to compressed waveform struct describing the audio input. */
  66. unsigned char *addr, /* address of compressed data */
  67. int length /* length of compressed data in bytes. */
  68. );
  69. /*@
  70. @Name DXL_AlterXAudioData
  71. @Description Link an audio decompressor to the next unit of compressed data.
  72. This function cannot change the type of xSource on the fly. That must remain consistent.
  73. Setting the address of the audio data to null causes the xSource to generate an infinate number of "zero" value samples.
  74. @Return value void
  75. @*/
  76. void DXL_AlterXAudioData(
  77. DXL_XAUDIOSRC_HANDLE xSource, /* handle to compressed audio source */
  78. unsigned char *addr, /* pointer to new compressed audio data */
  79. int length /* length of compressed data in bytes. */
  80. );
  81. /*@
  82. @Name DXL_DestroyXAudioSrc
  83. @Description clears an audio decompressor and returns it to the pool.
  84. @Return value void
  85. @*/
  86. void DXL_DestroyXAudioSrc(
  87. DXL_XAUDIOSRC_HANDLE xSource /* compressed audio source */
  88. );
  89. /*@
  90. @Name DXL_CreateAudioDst
  91. @Description Create a audio destination description. When numChannel equals 2 but addrR is null, it
  92. is assumed that multi-channel samples should be interleaved within the dest buffer pointed to by addrL.
  93. @Return value returns an object of type DXL_AUDIODST_HANDLE, and audio destination.
  94. @*/
  95. DXL_AUDIODST_HANDLE DXL_CreateAudioDst(
  96. void *addrL, /* pointer to left audio destination channel */
  97. void *addrR, /* pointer to right audio destination channel */
  98. int length, /* audio buffer size in bytes. */
  99. int bitDepth, /* bits per sample */
  100. int numChannels, /* number of audio channels */
  101. int sampleRate /* samples per second */
  102. );
  103. /*@
  104. @Name DXL_AlterAudioDst
  105. @Description Change characteristics of audio destination.
  106. Specify 0 or null values for no change.
  107. @Return value void
  108. @*/
  109. void DXL_AlterAudioDst(
  110. DXL_AUDIODST_HANDLE dst, /* handle to audio destionation */
  111. void *addrL, /* pointer to left audio destination channel */
  112. void *addrR, /* pointer to right audio destination channel */
  113. int length, /* audio buffer size in bytes. */
  114. int bitDepth, /* bits per sample (8 or 16) */
  115. int numChannels, /* number of audio channels (1 or 2) */
  116. int sampleRate /* samples per second */
  117. );
  118. /*@
  119. @Name DXL_DestroyAudioDst
  120. @Description clears and audio destination object and returns it to the pool.
  121. @Return value none.
  122. @*/
  123. void DXL_DestroyAudioDst(
  124. DXL_AUDIODST_HANDLE dst /* handle to audio destination */
  125. );
  126. /*@
  127. @Name DXL_dxAudio
  128. @Description decompress up to maxSamplesToDecompress. The number of samples transferred is controlled by two factors.
  129. One factor is the limit parameter. The other factor is the number of remaining samples in the src (internal buffer).
  130. If the function returns less that the desired number of samples, get another audio record (via HFB_GetStreamingData()) for source data and try again.
  131. @Return value returns the actual number of samples decompressed
  132. @*/
  133. int DXL_dxAudio(
  134. DXL_XAUDIOSRC_HANDLE src, /* handle to compressed audio source. */
  135. DXL_AUDIODST_HANDLE dst, /* handle to uncompressed audio destination */
  136. int maxSamplesToDecompress /* Try to decompress up to this many samples to the destination */
  137. );
  138. /*@
  139. @Name DXL_ClearAudio
  140. @Description Clears any internal audio buffers compressed and/or decompressed data so that playback may start from a new point.
  141. @Return value
  142. @*/
  143. int DXL_ClearAudio(DXL_XAUDIOSRC_HANDLE xSourcePublic);
  144. int DXL_RegisteredAudioDXerGet(DXL_AUDIO_REGISTRATION *oneRegistration);
  145. int DXL_RegisteredAudioDXerSet(
  146. unsigned short formatTag,
  147. int (*audio_dxer_init) (DXL_XAUDIOSRC_HANDLE src),
  148. int (*audio_dxer_dx) (DXL_XAUDIOSRC_HANDLE src, void *left, void *right, int nSamples),
  149. int (*audio_dxer_exit) (DXL_XAUDIOSRC_HANDLE src),
  150. int (*audio_dxer_clear) (DXL_XAUDIOSRC_HANDLE src)
  151. );
  152. void DXL_AudioAccurateTime(UINT64* temp);
  153. /* Register one of the On2 dxa plugins */
  154. /*-------------------------------------*/
  155. int DXL_RegisterAVC(void);
  156. int DXL_RegisterAC3(void);
  157. int DXL_RegisterQDesign(void);
  158. int DXL_RegisterACM(unsigned short formatTag);
  159. int DXL_RegisterDK4(void);
  160. int DXL_RegisterMP3(void);
  161. #if defined(__cplusplus)
  162. }
  163. #endif
  164. #endif /* include guards */