ogg.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 2008-04-10 22:50:38 adrian_henke Exp $
  14. ********************************************************************/
  15. #ifndef _OGG_H
  16. #define _OGG_H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include <ogg/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. /* ogg_stream_state contains the current encode/decode state of a logical
  36. Ogg bitstream **********************************************************/
  37. typedef struct {
  38. unsigned char *body_data; /* bytes from packet bodies */
  39. long body_storage; /* storage elements allocated */
  40. long body_fill; /* elements stored; fill mark */
  41. long body_returned; /* elements of fill returned */
  42. int *lacing_vals; /* The values that will go to the segment table */
  43. ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
  44. this way, but it is simple coupled to the
  45. lacing fifo */
  46. long lacing_storage;
  47. long lacing_fill;
  48. long lacing_packet;
  49. long lacing_returned;
  50. unsigned char header[282]; /* working space for header encode */
  51. int header_fill;
  52. int e_o_s; /* set when we have buffered the last packet in the
  53. logical bitstream */
  54. int b_o_s; /* set after we've written the initial page
  55. of a logical bitstream */
  56. long serialno;
  57. long pageno;
  58. ogg_int64_t packetno; /* sequence number for decode; the framing
  59. knows where there's a hole in the data,
  60. but we need coupling so that the codec
  61. (which is in a seperate abstraction
  62. layer) also knows about the gap */
  63. ogg_int64_t granulepos;
  64. } ogg_stream_state;
  65. /* ogg_packet is used to encapsulate the data and metadata belonging
  66. to a single raw Ogg/Vorbis packet *************************************/
  67. typedef struct {
  68. unsigned char *packet;
  69. long bytes;
  70. long b_o_s;
  71. long e_o_s;
  72. ogg_int64_t granulepos;
  73. ogg_int64_t packetno; /* sequence number for decode; the framing
  74. knows where there's a hole in the data,
  75. but we need coupling so that the codec
  76. (which is in a seperate abstraction
  77. layer) also knows about the gap */
  78. } ogg_packet;
  79. typedef struct {
  80. unsigned char *data;
  81. int storage;
  82. int fill;
  83. int returned;
  84. int unsynced;
  85. int headerbytes;
  86. int bodybytes;
  87. } ogg_sync_state;
  88. /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
  89. extern void oggpack_writeinit(oggpack_buffer *b);
  90. extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
  91. extern void oggpack_writealign(oggpack_buffer *b);
  92. extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
  93. extern void oggpack_reset(oggpack_buffer *b);
  94. extern void oggpack_writeclear(oggpack_buffer *b);
  95. extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
  96. extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
  97. extern long oggpack_look(oggpack_buffer *b,int bits);
  98. extern long oggpack_look1(oggpack_buffer *b);
  99. extern void oggpack_adv(oggpack_buffer *b,int bits);
  100. extern void oggpack_adv1(oggpack_buffer *b);
  101. extern long oggpack_read(oggpack_buffer *b,int bits);
  102. extern long oggpack_read1(oggpack_buffer *b);
  103. extern long oggpack_bytes(oggpack_buffer *b);
  104. extern long oggpack_bits(oggpack_buffer *b);
  105. extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
  106. extern void oggpackB_writeinit(oggpack_buffer *b);
  107. extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
  108. extern void oggpackB_writealign(oggpack_buffer *b);
  109. extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
  110. extern void oggpackB_reset(oggpack_buffer *b);
  111. extern void oggpackB_writeclear(oggpack_buffer *b);
  112. extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
  113. extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
  114. extern long oggpackB_look(oggpack_buffer *b,int bits);
  115. extern long oggpackB_look1(oggpack_buffer *b);
  116. extern void oggpackB_adv(oggpack_buffer *b,int bits);
  117. extern void oggpackB_adv1(oggpack_buffer *b);
  118. extern long oggpackB_read(oggpack_buffer *b,int bits);
  119. extern long oggpackB_read1(oggpack_buffer *b);
  120. extern long oggpackB_bytes(oggpack_buffer *b);
  121. extern long oggpackB_bits(oggpack_buffer *b);
  122. extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
  123. /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
  124. extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
  125. extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
  126. extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
  127. /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
  128. extern int ogg_sync_init(ogg_sync_state *oy);
  129. extern int ogg_sync_clear(ogg_sync_state *oy);
  130. extern int ogg_sync_reset(ogg_sync_state *oy);
  131. extern int ogg_sync_destroy(ogg_sync_state *oy);
  132. extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
  133. extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
  134. extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
  135. extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
  136. extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
  137. extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
  138. extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
  139. /* Ogg BITSTREAM PRIMITIVES: general ***************************/
  140. extern int ogg_stream_init(ogg_stream_state *os,int serialno);
  141. extern int ogg_stream_clear(ogg_stream_state *os);
  142. extern int ogg_stream_reset(ogg_stream_state *os);
  143. extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
  144. extern int ogg_stream_destroy(ogg_stream_state *os);
  145. extern int ogg_stream_eos(ogg_stream_state *os);
  146. extern void ogg_page_checksum_set(ogg_page *og);
  147. extern int ogg_page_version(ogg_page *og);
  148. extern int ogg_page_continued(ogg_page *og);
  149. extern int ogg_page_bos(ogg_page *og);
  150. extern int ogg_page_eos(ogg_page *og);
  151. extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
  152. extern int ogg_page_serialno(ogg_page *og);
  153. extern long ogg_page_pageno(ogg_page *og);
  154. extern int ogg_page_packets(ogg_page *og);
  155. extern void ogg_packet_clear(ogg_packet *op);
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* _OGG_H */