2
0

ogg.h 8.2 KB

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