The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
7.9KB

  1. /********************************************************************
  2. * *
  3. * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
  4. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  5. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  6. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  7. * *
  8. * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
  9. * by the Xiph.Org Foundation http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: toplevel libogg include
  13. last mod: $Id: ogg.h,v 1.1 2007/06/07 17:48:18 jules_rms Exp $
  14. ********************************************************************/
  15. #ifndef _OGG_H
  16. #define _OGG_H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "os_types.h"
  21. typedef struct {
  22. long endbyte;
  23. int endbit;
  24. unsigned char *buffer;
  25. unsigned char *ptr;
  26. long storage;
  27. } oggpack_buffer;
  28. /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
  29. typedef struct {
  30. unsigned char *header;
  31. long header_len;
  32. unsigned char *body;
  33. long body_len;
  34. } ogg_page;
  35. static inline ogg_uint32_t ogg_bitreverse(ogg_uint32_t x){
  36. x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL);
  37. x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL);
  38. x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL);
  39. x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL);
  40. return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL);
  41. }
  42. /* ogg_stream_state contains the current encode/decode state of a logical
  43. Ogg bitstream **********************************************************/
  44. typedef struct {
  45. unsigned char *body_data; /* bytes from packet bodies */
  46. long body_storage; /* storage elements allocated */
  47. long body_fill; /* elements stored; fill mark */
  48. long body_returned; /* elements of fill returned */
  49. int *lacing_vals; /* The values that will go to the segment table */
  50. ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
  51. this way, but it is simple coupled to the
  52. lacing fifo */
  53. long lacing_storage;
  54. long lacing_fill;
  55. long lacing_packet;
  56. long lacing_returned;
  57. unsigned char header[282]; /* working space for header encode */
  58. int header_fill;
  59. int e_o_s; /* set when we have buffered the last packet in the
  60. logical bitstream */
  61. int b_o_s; /* set after we've written the initial page
  62. of a logical bitstream */
  63. long serialno;
  64. long pageno;
  65. ogg_int64_t packetno; /* sequence number for decode; the framing
  66. knows where there's a hole in the data,
  67. but we need coupling so that the codec
  68. (which is in a seperate abstraction
  69. layer) also knows about the gap */
  70. ogg_int64_t granulepos;
  71. } ogg_stream_state;
  72. /* ogg_packet is used to encapsulate the data and metadata belonging
  73. to a single raw Ogg/Vorbis packet *************************************/
  74. typedef struct {
  75. unsigned char *packet;
  76. long bytes;
  77. long b_o_s;
  78. long e_o_s;
  79. ogg_int64_t granulepos;
  80. ogg_int64_t packetno; /* sequence number for decode; the framing
  81. knows where there's a hole in the data,
  82. but we need coupling so that the codec
  83. (which is in a seperate abstraction
  84. layer) also knows about the gap */
  85. } ogg_packet;
  86. typedef struct {
  87. unsigned char *data;
  88. int storage;
  89. int fill;
  90. int returned;
  91. int unsynced;
  92. int headerbytes;
  93. int bodybytes;
  94. } ogg_sync_state;
  95. /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
  96. extern void oggpack_writeinit(oggpack_buffer *b);
  97. extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
  98. extern void oggpack_writealign(oggpack_buffer *b);
  99. extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
  100. extern void oggpack_reset(oggpack_buffer *b);
  101. extern void oggpack_writeclear(oggpack_buffer *b);
  102. extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
  103. extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
  104. extern long oggpack_look(oggpack_buffer *b,int bits);
  105. extern long oggpack_look1(oggpack_buffer *b);
  106. extern void oggpack_adv(oggpack_buffer *b,int bits);
  107. extern void oggpack_adv1(oggpack_buffer *b);
  108. extern long oggpack_read(oggpack_buffer *b,int bits);
  109. extern long oggpack_read1(oggpack_buffer *b);
  110. extern long oggpack_bytes(oggpack_buffer *b);
  111. extern long oggpack_bits(oggpack_buffer *b);
  112. extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
  113. extern void oggpackB_writeinit(oggpack_buffer *b);
  114. extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
  115. extern void oggpackB_writealign(oggpack_buffer *b);
  116. extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
  117. extern void oggpackB_reset(oggpack_buffer *b);
  118. extern void oggpackB_writeclear(oggpack_buffer *b);
  119. extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
  120. extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
  121. extern long oggpackB_look(oggpack_buffer *b,int bits);
  122. extern long oggpackB_look1(oggpack_buffer *b);
  123. extern void oggpackB_adv(oggpack_buffer *b,int bits);
  124. extern void oggpackB_adv1(oggpack_buffer *b);
  125. extern long oggpackB_read(oggpack_buffer *b,int bits);
  126. extern long oggpackB_read1(oggpack_buffer *b);
  127. extern long oggpackB_bytes(oggpack_buffer *b);
  128. extern long oggpackB_bits(oggpack_buffer *b);
  129. extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
  130. /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
  131. extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
  132. extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
  133. extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
  134. /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
  135. extern int ogg_sync_init(ogg_sync_state *oy);
  136. extern int ogg_sync_clear(ogg_sync_state *oy);
  137. extern int ogg_sync_reset(ogg_sync_state *oy);
  138. extern int ogg_sync_destroy(ogg_sync_state *oy);
  139. extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
  140. extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
  141. extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
  142. extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
  143. extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
  144. extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
  145. extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
  146. /* Ogg BITSTREAM PRIMITIVES: general ***************************/
  147. extern int ogg_stream_init(ogg_stream_state *os,int serialno);
  148. extern int ogg_stream_clear(ogg_stream_state *os);
  149. extern int ogg_stream_reset(ogg_stream_state *os);
  150. extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
  151. extern int ogg_stream_destroy(ogg_stream_state *os);
  152. extern int ogg_stream_eos(ogg_stream_state *os);
  153. extern void ogg_page_checksum_set(ogg_page *og);
  154. extern int ogg_page_version(ogg_page *og);
  155. extern int ogg_page_continued(ogg_page *og);
  156. extern int ogg_page_bos(ogg_page *og);
  157. extern int ogg_page_eos(ogg_page *og);
  158. extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
  159. extern int ogg_page_serialno(ogg_page *og);
  160. extern long ogg_page_pageno(ogg_page *og);
  161. extern int ogg_page_packets(ogg_page *og);
  162. extern void ogg_packet_clear(ogg_packet *op);
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /* _OGG_H */