codec_internal.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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: libvorbis codec headers
  14. ********************************************************************/
  15. #ifndef _V_CODECI_H_
  16. #define _V_CODECI_H_
  17. #define CHUNKSIZE 1024
  18. #include "codebook.h"
  19. #include "ivorbiscodec.h"
  20. #define VI_TRANSFORMB 1
  21. #define VI_WINDOWB 1
  22. #define VI_TIMEB 1
  23. #define VI_FLOORB 2
  24. #define VI_RESB 3
  25. #define VI_MAPB 1
  26. typedef void vorbis_info_floor;
  27. /* vorbis_dsp_state buffers the current vorbis audio
  28. analysis/synthesis state. The DSP state belongs to a specific
  29. logical bitstream ****************************************************/
  30. struct vorbis_dsp_state{
  31. vorbis_info *vi;
  32. oggpack_buffer opb;
  33. ogg_int32_t **work;
  34. ogg_int32_t **mdctright;
  35. int out_begin;
  36. int out_end;
  37. long lW;
  38. long W;
  39. ogg_int64_t granulepos;
  40. ogg_int64_t sequence;
  41. ogg_int64_t sample_count;
  42. };
  43. /* Floor backend generic *****************************************/
  44. extern vorbis_info_floor *floor0_info_unpack(vorbis_info *,oggpack_buffer *);
  45. extern void floor0_free_info(vorbis_info_floor *);
  46. extern int floor0_memosize(vorbis_info_floor *);
  47. extern ogg_int32_t *floor0_inverse1(struct vorbis_dsp_state *,
  48. vorbis_info_floor *,ogg_int32_t *);
  49. extern int floor0_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
  50. ogg_int32_t *buffer,ogg_int32_t *);
  51. extern vorbis_info_floor *floor1_info_unpack(vorbis_info *,oggpack_buffer *);
  52. extern void floor1_free_info(vorbis_info_floor *);
  53. extern int floor1_memosize(vorbis_info_floor *);
  54. extern ogg_int32_t *floor1_inverse1(struct vorbis_dsp_state *,
  55. vorbis_info_floor *,ogg_int32_t *);
  56. extern int floor1_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
  57. ogg_int32_t *buffer,ogg_int32_t *);
  58. typedef struct{
  59. int order;
  60. long rate;
  61. long barkmap;
  62. int ampbits;
  63. int ampdB;
  64. int numbooks; /* <= 16 */
  65. char books[16];
  66. } vorbis_info_floor0;
  67. typedef struct{
  68. char class_dim; /* 1 to 8 */
  69. char class_subs; /* 0,1,2,3 (bits: 1<<n poss) */
  70. unsigned char class_book; /* subs ^ dim entries */
  71. unsigned char class_subbook[8]; /* [VIF_CLASS][subs] */
  72. } floor1class;
  73. typedef struct{
  74. floor1class *class; /* [VIF_CLASS] */
  75. char *partitionclass; /* [VIF_PARTS]; 0 to 15 */
  76. ogg_uint16_t *postlist; /* [VIF_POSIT+2]; first two implicit */
  77. char *forward_index; /* [VIF_POSIT+2]; */
  78. char *hineighbor; /* [VIF_POSIT]; */
  79. char *loneighbor; /* [VIF_POSIT]; */
  80. int partitions; /* 0 to 31 */
  81. int posts;
  82. int mult; /* 1 2 3 or 4 */
  83. } vorbis_info_floor1;
  84. /* Residue backend generic *****************************************/
  85. typedef struct vorbis_info_residue{
  86. int type;
  87. unsigned char *stagemasks;
  88. unsigned char *stagebooks;
  89. /* block-partitioned VQ coded straight residue */
  90. long begin;
  91. long end;
  92. /* first stage (lossless partitioning) */
  93. int grouping; /* group n vectors per partition */
  94. char partitions; /* possible codebooks for a partition */
  95. unsigned char groupbook; /* huffbook for partitioning */
  96. char stages;
  97. } vorbis_info_residue;
  98. extern void res_clear_info(vorbis_info_residue *info);
  99. extern int res_unpack(vorbis_info_residue *info,
  100. vorbis_info *vi,oggpack_buffer *opb);
  101. extern int res_inverse(vorbis_dsp_state *,vorbis_info_residue *info,
  102. ogg_int32_t **in,int *nonzero,int ch);
  103. /* mode ************************************************************/
  104. typedef struct {
  105. unsigned char blockflag;
  106. unsigned char mapping;
  107. } vorbis_info_mode;
  108. /* Mapping backend generic *****************************************/
  109. typedef struct coupling_step{
  110. unsigned char mag;
  111. unsigned char ang;
  112. } coupling_step;
  113. typedef struct submap{
  114. char floor;
  115. char residue;
  116. } submap;
  117. typedef struct vorbis_info_mapping{
  118. int submaps;
  119. unsigned char *chmuxlist;
  120. submap *submaplist;
  121. int coupling_steps;
  122. coupling_step *coupling;
  123. } vorbis_info_mapping;
  124. extern int mapping_info_unpack(vorbis_info_mapping *,vorbis_info *,
  125. oggpack_buffer *);
  126. extern void mapping_clear_info(vorbis_info_mapping *);
  127. extern int mapping_inverse(struct vorbis_dsp_state *,vorbis_info_mapping *);
  128. /* codec_setup_info contains all the setup information specific to the
  129. specific compression/decompression mode in progress (eg,
  130. psychoacoustic settings, channel setup, options, codebook
  131. etc).
  132. *********************************************************************/
  133. typedef struct codec_setup_info {
  134. /* Vorbis supports only short and long blocks, but allows the
  135. encoder to choose the sizes */
  136. long blocksizes[2];
  137. /* modes are the primary means of supporting on-the-fly different
  138. blocksizes, different channel mappings (LR or M/A),
  139. different residue backends, etc. Each mode consists of a
  140. blocksize flag and a mapping (along with the mapping setup */
  141. int modes;
  142. int maps;
  143. int floors;
  144. int residues;
  145. int books;
  146. vorbis_info_mode *mode_param;
  147. vorbis_info_mapping *map_param;
  148. char *floor_type;
  149. vorbis_info_floor **floor_param;
  150. vorbis_info_residue *residue_param;
  151. codebook *book_param;
  152. } codec_setup_info;
  153. extern vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi);
  154. extern void vorbis_dsp_destroy(vorbis_dsp_state *v);
  155. extern int vorbis_dsp_headerin(vorbis_info *vi,vorbis_comment *vc,
  156. ogg_packet *op);
  157. extern int vorbis_dsp_restart(vorbis_dsp_state *v);
  158. extern int vorbis_dsp_synthesis(vorbis_dsp_state *vd,
  159. ogg_packet *op,int decodep);
  160. extern int vorbis_dsp_pcmout(vorbis_dsp_state *v,
  161. ogg_int16_t *pcm,int samples);
  162. extern int vorbis_dsp_read(vorbis_dsp_state *v,int samples);
  163. extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
  164. #endif