2
0

ogg.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /********************************************************************
  2. * *
  3. * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
  4. * *
  5. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  6. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  7. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  8. * *
  9. * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
  10. * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
  11. * *
  12. ********************************************************************
  13. function: subsumed libogg includes
  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 ogg_buffer_state{
  22. struct ogg_buffer *unused_buffers;
  23. struct ogg_reference *unused_references;
  24. int outstanding;
  25. int shutdown;
  26. } ogg_buffer_state;
  27. typedef struct ogg_buffer {
  28. unsigned char *data;
  29. long size;
  30. int refcount;
  31. union {
  32. ogg_buffer_state *owner;
  33. struct ogg_buffer *next;
  34. } ptr;
  35. } ogg_buffer;
  36. typedef struct ogg_reference {
  37. ogg_buffer *buffer;
  38. long begin;
  39. long length;
  40. struct ogg_reference *next;
  41. } ogg_reference;
  42. typedef struct oggpack_buffer {
  43. int headbit;
  44. unsigned char *headptr;
  45. long headend;
  46. /* memory management */
  47. ogg_reference *head;
  48. ogg_reference *tail;
  49. /* render the byte/bit counter API constant time */
  50. long count; /* doesn't count the tail */
  51. } oggpack_buffer;
  52. typedef struct oggbyte_buffer {
  53. ogg_reference *baseref;
  54. ogg_reference *ref;
  55. unsigned char *ptr;
  56. long pos;
  57. long end;
  58. } oggbyte_buffer;
  59. typedef struct ogg_sync_state {
  60. /* decode memory management pool */
  61. ogg_buffer_state *bufferpool;
  62. /* stream buffers */
  63. ogg_reference *fifo_head;
  64. ogg_reference *fifo_tail;
  65. long fifo_fill;
  66. /* stream sync management */
  67. int unsynced;
  68. int headerbytes;
  69. int bodybytes;
  70. } ogg_sync_state;
  71. typedef struct ogg_stream_state {
  72. ogg_reference *header_head;
  73. ogg_reference *header_tail;
  74. ogg_reference *body_head;
  75. ogg_reference *body_tail;
  76. int e_o_s; /* set when we have buffered the last
  77. packet in the logical bitstream */
  78. int b_o_s; /* set after we've written the initial page
  79. of a logical bitstream */
  80. long serialno;
  81. long pageno;
  82. ogg_int64_t packetno; /* sequence number for decode; the framing
  83. knows where there's a hole in the data,
  84. but we need coupling so that the codec
  85. (which is in a seperate abstraction
  86. layer) also knows about the gap */
  87. ogg_int64_t granulepos;
  88. int lacing_fill;
  89. ogg_uint32_t body_fill;
  90. /* decode-side state data */
  91. int holeflag;
  92. int spanflag;
  93. int clearflag;
  94. int laceptr;
  95. ogg_uint32_t body_fill_next;
  96. } ogg_stream_state;
  97. typedef struct {
  98. ogg_reference *packet;
  99. long bytes;
  100. long b_o_s;
  101. long e_o_s;
  102. ogg_int64_t granulepos;
  103. ogg_int64_t packetno; /* sequence number for decode; the framing
  104. knows where there's a hole in the data,
  105. but we need coupling so that the codec
  106. (which is in a seperate abstraction
  107. layer) also knows about the gap */
  108. } ogg_packet;
  109. typedef struct {
  110. ogg_reference *header;
  111. int header_len;
  112. ogg_reference *body;
  113. long body_len;
  114. } ogg_page;
  115. /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
  116. extern void oggpack_readinit(oggpack_buffer *b,ogg_reference *r);
  117. extern long oggpack_look(oggpack_buffer *b,int bits);
  118. extern void oggpack_adv(oggpack_buffer *b,int bits);
  119. extern long oggpack_read(oggpack_buffer *b,int bits);
  120. extern long oggpack_bytes(oggpack_buffer *b);
  121. extern long oggpack_bits(oggpack_buffer *b);
  122. extern int oggpack_eop(oggpack_buffer *b);
  123. /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
  124. extern ogg_sync_state *ogg_sync_create(void);
  125. extern int ogg_sync_destroy(ogg_sync_state *oy);
  126. extern int ogg_sync_reset(ogg_sync_state *oy);
  127. extern unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size);
  128. extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
  129. extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
  130. extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
  131. extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
  132. extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
  133. extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
  134. /* Ogg BITSTREAM PRIMITIVES: general ***************************/
  135. extern ogg_stream_state *ogg_stream_create(int serialno);
  136. extern int ogg_stream_destroy(ogg_stream_state *os);
  137. extern int ogg_stream_reset(ogg_stream_state *os);
  138. extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
  139. extern int ogg_stream_eos(ogg_stream_state *os);
  140. extern int ogg_page_checksum_set(ogg_page *og);
  141. extern int ogg_page_version(ogg_page *og);
  142. extern int ogg_page_continued(ogg_page *og);
  143. extern int ogg_page_bos(ogg_page *og);
  144. extern int ogg_page_eos(ogg_page *og);
  145. extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
  146. extern ogg_uint32_t ogg_page_serialno(ogg_page *og);
  147. extern ogg_uint32_t ogg_page_pageno(ogg_page *og);
  148. extern int ogg_page_packets(ogg_page *og);
  149. extern int ogg_page_getbuffer(ogg_page *og, unsigned char **buffer);
  150. extern int ogg_packet_release(ogg_packet *op);
  151. extern int ogg_page_release(ogg_page *og);
  152. extern void ogg_page_dup(ogg_page *d, ogg_page *s);
  153. /* Ogg BITSTREAM PRIMITIVES: return codes ***************************/
  154. #define OGG_SUCCESS 0
  155. #define OGG_HOLE -10
  156. #define OGG_SPAN -11
  157. #define OGG_EVERSION -12
  158. #define OGG_ESERIAL -13
  159. #define OGG_EINVAL -14
  160. #define OGG_EEOS -15
  161. #ifdef __cplusplus
  162. }
  163. #endif
  164. #endif /* _OGG_H */