backends.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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-2001 *
  9. * by the XIPHOPHORUS Company http://www.xiph.org/ *
  10. ********************************************************************
  11. function: libvorbis backend and mapping structures; needed for
  12. static mode headers
  13. last mod: $Id: backends.h,v 1.9.2.4 2001/08/07 03:47:22 xiphmont Exp $
  14. ********************************************************************/
  15. /* this is exposed up here because we need it for static modes.
  16. Lookups for each backend aren't exposed because there's no reason
  17. to do so */
  18. #ifndef _vorbis_backend_h_
  19. #define _vorbis_backend_h_
  20. #include "codec_internal.h"
  21. /* this would all be simpler/shorter with templates, but.... */
  22. /* Transform backend generic *************************************/
  23. /* only mdct right now. Flesh it out more if we ever transcend mdct
  24. in the transform domain */
  25. /* Time backend generic ******************************************/
  26. typedef struct{
  27. void (*pack) (vorbis_info_time *,oggpack_buffer *);
  28. vorbis_info_time *(*unpack)(vorbis_info *,oggpack_buffer *);
  29. vorbis_look_time *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
  30. vorbis_info_time *);
  31. vorbis_info_time *(*copy_info)(vorbis_info_time *);
  32. void (*free_info) (vorbis_info_time *);
  33. void (*free_look) (vorbis_look_time *);
  34. int (*forward) (struct vorbis_block *,vorbis_look_time *,
  35. float *,float *);
  36. int (*inverse) (struct vorbis_block *,vorbis_look_time *,
  37. float *,float *);
  38. } vorbis_func_time;
  39. typedef struct{
  40. int dummy;
  41. } vorbis_info_time0;
  42. /* Floor backend generic *****************************************/
  43. typedef struct{
  44. void (*pack) (vorbis_info_floor *,oggpack_buffer *);
  45. vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
  46. vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
  47. vorbis_info_floor *);
  48. vorbis_info_floor *(*copy_info)(vorbis_info_floor *);
  49. void (*free_info) (vorbis_info_floor *);
  50. void (*free_look) (vorbis_look_floor *);
  51. int (*forward) (struct vorbis_block *,vorbis_look_floor *,
  52. float *, const float *, /* in */
  53. const float *, const float *, /* in */
  54. float *); /* out */
  55. void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
  56. int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
  57. void *buffer,float *);
  58. } vorbis_func_floor;
  59. typedef struct{
  60. int order;
  61. long rate;
  62. long barkmap;
  63. int ampbits;
  64. int ampdB;
  65. int numbooks; /* <= 16 */
  66. int books[16];
  67. float lessthan; /* encode-only config setting hacks for libvorbis */
  68. float greaterthan; /* encode-only config setting hacks for libvorbis */
  69. } vorbis_info_floor0;
  70. #define VIF_POSIT 63
  71. #define VIF_CLASS 16
  72. #define VIF_PARTS 31
  73. typedef struct{
  74. int partitions; /* 0 to 31 */
  75. int partitionclass[VIF_PARTS]; /* 0 to 15 */
  76. int class_dim[VIF_CLASS]; /* 1 to 8 */
  77. int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */
  78. int class_book[VIF_CLASS]; /* subs ^ dim entries */
  79. int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
  80. int mult; /* 1 2 3 or 4 */
  81. int postlist[VIF_POSIT+2]; /* first two implicit */
  82. /* encode side analysis parameters */
  83. float maxover;
  84. float maxunder;
  85. float maxerr;
  86. int twofitminsize;
  87. int twofitminused;
  88. int twofitweight;
  89. float twofitatten;
  90. int unusedminsize;
  91. int unusedmin_n;
  92. int n;
  93. } vorbis_info_floor1;
  94. /* Residue backend generic *****************************************/
  95. typedef struct{
  96. void (*pack) (vorbis_info_residue *,oggpack_buffer *);
  97. vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
  98. vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
  99. vorbis_info_residue *);
  100. vorbis_info_residue *(*copy_info)(vorbis_info_residue *);
  101. void (*free_info) (vorbis_info_residue *);
  102. void (*free_look) (vorbis_look_residue *);
  103. long **(*class) (struct vorbis_block *,vorbis_look_residue *,
  104. float **,int *,int);
  105. int (*forward) (struct vorbis_block *,vorbis_look_residue *,
  106. float **,float **,int *,int,int,long **);
  107. int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
  108. float **,int *,int);
  109. } vorbis_func_residue;
  110. typedef struct vorbis_info_residue0{
  111. /* block-partitioned VQ coded straight residue */
  112. long begin;
  113. long end;
  114. /* first stage (lossless partitioning) */
  115. int grouping; /* group n vectors per partition */
  116. int partitions; /* possible codebooks for a partition */
  117. int groupbook; /* huffbook for partitioning */
  118. int secondstages[64]; /* expanded out to pointers in lookup */
  119. int booklist[256]; /* list of second stage books */
  120. /* encode-only heuristic settings */
  121. float entmax[64]; /* book entropy threshholds*/
  122. float ampmax[64]; /* book amp threshholds*/
  123. int subgrp[64]; /* book heuristic subgroup size */
  124. int blimit[64]; /* subgroup position limits */
  125. int passlimit[32]; /* iteration limit per couple/quant pass */
  126. } vorbis_info_residue0;
  127. /* Mapping backend generic *****************************************/
  128. typedef struct{
  129. void (*pack) (vorbis_info *,vorbis_info_mapping *,
  130. oggpack_buffer *);
  131. vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
  132. vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
  133. vorbis_info_mapping *);
  134. vorbis_info_mapping *(*copy_info)(vorbis_info_mapping *);
  135. void (*free_info) (vorbis_info_mapping *);
  136. void (*free_look) (vorbis_look_mapping *);
  137. int (*forward) (struct vorbis_block *vb,vorbis_look_mapping *);
  138. int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);
  139. } vorbis_func_mapping;
  140. typedef struct vorbis_info_mapping0{
  141. int submaps; /* <= 16 */
  142. int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */
  143. int timesubmap[16]; /* [mux] */
  144. int floorsubmap[16]; /* [mux] submap to floors */
  145. int residuesubmap[16]; /* [mux] submap to residue */
  146. int psy[2]; /* by blocktype; impulse/padding for short,
  147. transition/normal for long */
  148. int coupling_steps;
  149. int coupling_mag[256];
  150. int coupling_ang[256];
  151. } vorbis_info_mapping0;
  152. #endif