ogg.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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-2007 *
  9. * by the Xiph.Org Foundation http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: toplevel libogg include
  13. last mod: $Id: ogg.h 18044 2011-08-01 17:55:20Z gmaxwell $
  14. ********************************************************************/
  15. #ifndef _OGG_H
  16. #define _OGG_H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include <stddef.h>
  21. #include <ogg/os_types.h>
  22. typedef struct {
  23. void *iov_base;
  24. size_t iov_len;
  25. } ogg_iovec_t;
  26. typedef struct {
  27. long endbyte;
  28. int endbit;
  29. unsigned char *buffer;
  30. unsigned char *ptr;
  31. long storage;
  32. } oggpack_buffer;
  33. /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
  34. typedef struct {
  35. unsigned char *header;
  36. long header_len;
  37. unsigned char *body;
  38. long body_len;
  39. } ogg_page;
  40. /* ogg_stream_state contains the current encode/decode state of a logical
  41. Ogg bitstream **********************************************************/
  42. typedef struct {
  43. unsigned char *body_data; /* bytes from packet bodies */
  44. long body_storage; /* storage elements allocated */
  45. long body_fill; /* elements stored; fill mark */
  46. long body_returned; /* elements of fill returned */
  47. int *lacing_vals; /* The values that will go to the segment table */
  48. ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
  49. this way, but it is simple coupled to the
  50. lacing fifo */
  51. long lacing_storage;
  52. long lacing_fill;
  53. long lacing_packet;
  54. long lacing_returned;
  55. unsigned char header[282]; /* working space for header encode */
  56. int header_fill;
  57. int e_o_s; /* set when we have buffered the last packet in the
  58. logical bitstream */
  59. int b_o_s; /* set after we've written the initial page
  60. of a logical bitstream */
  61. long serialno;
  62. long pageno;
  63. ogg_int64_t packetno; /* sequence number for decode; the framing
  64. knows where there's a hole in the data,
  65. but we need coupling so that the codec
  66. (which is in a separate abstraction
  67. layer) also knows about the gap */
  68. ogg_int64_t granulepos;
  69. } ogg_stream_state;
  70. /* ogg_packet is used to encapsulate the data and metadata belonging
  71. to a single raw Ogg/Vorbis packet *************************************/
  72. typedef struct {
  73. unsigned char *packet;
  74. long bytes;
  75. long b_o_s;
  76. long e_o_s;
  77. ogg_int64_t granulepos;
  78. ogg_int64_t packetno; /* sequence number for decode; the framing
  79. knows where there's a hole in the data,
  80. but we need coupling so that the codec
  81. (which is in a separate abstraction
  82. layer) also knows about the gap */
  83. } ogg_packet;
  84. typedef struct {
  85. unsigned char *data;
  86. int storage;
  87. int fill;
  88. int returned;
  89. int unsynced;
  90. int headerbytes;
  91. int bodybytes;
  92. } ogg_sync_state;
  93. /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
  94. extern void oggpack_writeinit(oggpack_buffer *b);
  95. extern int oggpack_writecheck(oggpack_buffer *b);
  96. extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
  97. extern void oggpack_writealign(oggpack_buffer *b);
  98. extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
  99. extern void oggpack_reset(oggpack_buffer *b);
  100. extern void oggpack_writeclear(oggpack_buffer *b);
  101. extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
  102. extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
  103. extern long oggpack_look(oggpack_buffer *b,int bits);
  104. extern long oggpack_look1(oggpack_buffer *b);
  105. extern void oggpack_adv(oggpack_buffer *b,int bits);
  106. extern void oggpack_adv1(oggpack_buffer *b);
  107. extern long oggpack_read(oggpack_buffer *b,int bits);
  108. extern long oggpack_read1(oggpack_buffer *b);
  109. extern long oggpack_bytes(oggpack_buffer *b);
  110. extern long oggpack_bits(oggpack_buffer *b);
  111. extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
  112. extern void oggpackB_writeinit(oggpack_buffer *b);
  113. extern int oggpackB_writecheck(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_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
  133. int count, long e_o_s, ogg_int64_t granulepos);
  134. extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
  135. extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
  136. extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
  137. extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill);
  138. /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
  139. extern int ogg_sync_init(ogg_sync_state *oy);
  140. extern int ogg_sync_clear(ogg_sync_state *oy);
  141. extern int ogg_sync_reset(ogg_sync_state *oy);
  142. extern int ogg_sync_destroy(ogg_sync_state *oy);
  143. extern int ogg_sync_check(ogg_sync_state *oy);
  144. extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
  145. extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
  146. extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
  147. extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
  148. extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
  149. extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
  150. extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
  151. /* Ogg BITSTREAM PRIMITIVES: general ***************************/
  152. extern int ogg_stream_init(ogg_stream_state *os,int serialno);
  153. extern int ogg_stream_clear(ogg_stream_state *os);
  154. extern int ogg_stream_reset(ogg_stream_state *os);
  155. extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
  156. extern int ogg_stream_destroy(ogg_stream_state *os);
  157. extern int ogg_stream_check(ogg_stream_state *os);
  158. extern int ogg_stream_eos(ogg_stream_state *os);
  159. extern void ogg_page_checksum_set(ogg_page *og);
  160. extern int ogg_page_version(const ogg_page *og);
  161. extern int ogg_page_continued(const ogg_page *og);
  162. extern int ogg_page_bos(const ogg_page *og);
  163. extern int ogg_page_eos(const ogg_page *og);
  164. extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
  165. extern int ogg_page_serialno(const ogg_page *og);
  166. extern long ogg_page_pageno(const ogg_page *og);
  167. extern int ogg_page_packets(const ogg_page *og);
  168. extern void ogg_packet_clear(ogg_packet *op);
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif /* _OGG_H */