codec_internal.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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: libvorbis codec headers
  13. last mod: $Id$
  14. ********************************************************************/
  15. #ifndef _V_CODECI_H_
  16. #define _V_CODECI_H_
  17. #include "envelope.h"
  18. #include "codebook.h"
  19. #define BLOCKTYPE_IMPULSE 0
  20. #define BLOCKTYPE_PADDING 1
  21. #define BLOCKTYPE_TRANSITION 0
  22. #define BLOCKTYPE_LONG 1
  23. #define PACKETBLOBS 15
  24. typedef struct vorbis_block_internal{
  25. float **pcmdelay; /* this is a pointer into local storage */
  26. float ampmax;
  27. int blocktype;
  28. oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed;
  29. blob [PACKETBLOBS/2] points to
  30. the oggpack_buffer in the
  31. main vorbis_block */
  32. } vorbis_block_internal;
  33. typedef void vorbis_look_floor;
  34. typedef void vorbis_look_residue;
  35. typedef void vorbis_look_transform;
  36. /* mode ************************************************************/
  37. typedef struct {
  38. int blockflag;
  39. int windowtype;
  40. int transformtype;
  41. int mapping;
  42. } vorbis_info_mode;
  43. typedef void vorbis_info_floor;
  44. typedef void vorbis_info_residue;
  45. typedef void vorbis_info_mapping;
  46. #include "psy.h"
  47. #include "bitrate.h"
  48. typedef struct private_state {
  49. /* local lookup storage */
  50. envelope_lookup *ve; /* envelope lookup */
  51. int window[2];
  52. vorbis_look_transform **transform[2]; /* block, type */
  53. drft_lookup fft_look[2];
  54. int modebits;
  55. vorbis_look_floor **flr;
  56. vorbis_look_residue **residue;
  57. vorbis_look_psy *psy;
  58. vorbis_look_psy_global *psy_g_look;
  59. /* local storage, only used on the encoding side. This way the
  60. application does not need to worry about freeing some packets'
  61. memory and not others'; packet storage is always tracked.
  62. Cleared next call to a _dsp_ function */
  63. unsigned char *header;
  64. unsigned char *header1;
  65. unsigned char *header2;
  66. bitrate_manager_state bms;
  67. ogg_int64_t sample_count;
  68. } private_state;
  69. /* codec_setup_info contains all the setup information specific to the
  70. specific compression/decompression mode in progress (eg,
  71. psychoacoustic settings, channel setup, options, codebook
  72. etc).
  73. *********************************************************************/
  74. #include "highlevel.h"
  75. typedef struct codec_setup_info {
  76. /* Vorbis supports only short and long blocks, but allows the
  77. encoder to choose the sizes */
  78. long blocksizes[2];
  79. /* modes are the primary means of supporting on-the-fly different
  80. blocksizes, different channel mappings (LR or M/A),
  81. different residue backends, etc. Each mode consists of a
  82. blocksize flag and a mapping (along with the mapping setup */
  83. int modes;
  84. int maps;
  85. int floors;
  86. int residues;
  87. int books;
  88. int psys; /* encode only */
  89. vorbis_info_mode *mode_param[64];
  90. int map_type[64];
  91. vorbis_info_mapping *map_param[64];
  92. int floor_type[64];
  93. vorbis_info_floor *floor_param[64];
  94. int residue_type[64];
  95. vorbis_info_residue *residue_param[64];
  96. static_codebook *book_param[256];
  97. codebook *fullbooks;
  98. vorbis_info_psy *psy_param[4]; /* encode only */
  99. vorbis_info_psy_global psy_g_param;
  100. bitrate_manager_info bi;
  101. highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a
  102. highly redundant structure, but
  103. improves clarity of program flow. */
  104. int halfrate_flag; /* painless downsample for decode */
  105. } codec_setup_info;
  106. extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
  107. extern void _vp_global_free(vorbis_look_psy_global *look);
  108. typedef struct {
  109. int sorted_index[VIF_POSIT+2];
  110. int forward_index[VIF_POSIT+2];
  111. int reverse_index[VIF_POSIT+2];
  112. int hineighbor[VIF_POSIT];
  113. int loneighbor[VIF_POSIT];
  114. int posts;
  115. int n;
  116. int quant_q;
  117. vorbis_info_floor1 *vi;
  118. long phrasebits;
  119. long postbits;
  120. long frames;
  121. } vorbis_look_floor1;
  122. extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
  123. const float *logmdct, /* in */
  124. const float *logmask);
  125. extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
  126. int *A,int *B,
  127. int del);
  128. extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
  129. vorbis_look_floor1 *look,
  130. int *post,int *ilogmask);
  131. #endif