backends.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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-2009 *
  9. * by the Xiph.Org Foundation http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: libvorbis backend and mapping structures; needed for
  13. static mode headers
  14. last mod: $Id: backends.h 16962 2010-03-11 07:30:34Z xiphmont $
  15. ********************************************************************/
  16. /* this is exposed up here because we need it for static modes.
  17. Lookups for each backend aren't exposed because there's no reason
  18. to do so */
  19. #ifndef _vorbis_backend_h_
  20. #define _vorbis_backend_h_
  21. #include "codec_internal.h"
  22. /* this would all be simpler/shorter with templates, but.... */
  23. /* Floor backend generic *****************************************/
  24. typedef struct{
  25. void (*pack) (vorbis_info_floor *,oggpack_buffer *);
  26. vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
  27. vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_floor *);
  28. void (*free_info) (vorbis_info_floor *);
  29. void (*free_look) (vorbis_look_floor *);
  30. void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
  31. int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
  32. void *buffer,float *);
  33. } vorbis_func_floor;
  34. typedef struct{
  35. int order;
  36. long rate;
  37. long barkmap;
  38. int ampbits;
  39. int ampdB;
  40. int numbooks; /* <= 16 */
  41. int books[16];
  42. float lessthan; /* encode-only config setting hacks for libvorbis */
  43. float greaterthan; /* encode-only config setting hacks for libvorbis */
  44. } vorbis_info_floor0;
  45. #define VIF_POSIT 63
  46. #define VIF_CLASS 16
  47. #define VIF_PARTS 31
  48. typedef struct{
  49. int partitions; /* 0 to 31 */
  50. int partitionclass[VIF_PARTS]; /* 0 to 15 */
  51. int class_dim[VIF_CLASS]; /* 1 to 8 */
  52. int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */
  53. int class_book[VIF_CLASS]; /* subs ^ dim entries */
  54. int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
  55. int mult; /* 1 2 3 or 4 */
  56. int postlist[VIF_POSIT+2]; /* first two implicit */
  57. /* encode side analysis parameters */
  58. float maxover;
  59. float maxunder;
  60. float maxerr;
  61. float twofitweight;
  62. float twofitatten;
  63. int n;
  64. } vorbis_info_floor1;
  65. /* Residue backend generic *****************************************/
  66. typedef struct{
  67. void (*pack) (vorbis_info_residue *,oggpack_buffer *);
  68. vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
  69. vorbis_look_residue *(*look) (vorbis_dsp_state *,
  70. vorbis_info_residue *);
  71. void (*free_info) (vorbis_info_residue *);
  72. void (*free_look) (vorbis_look_residue *);
  73. long **(*class) (struct vorbis_block *,vorbis_look_residue *,
  74. int **,int *,int);
  75. int (*forward) (oggpack_buffer *,struct vorbis_block *,
  76. vorbis_look_residue *,
  77. int **,int *,int,long **,int);
  78. int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
  79. float **,int *,int);
  80. } vorbis_func_residue;
  81. typedef struct vorbis_info_residue0{
  82. /* block-partitioned VQ coded straight residue */
  83. long begin;
  84. long end;
  85. /* first stage (lossless partitioning) */
  86. int grouping; /* group n vectors per partition */
  87. int partitions; /* possible codebooks for a partition */
  88. int partvals; /* partitions ^ groupbook dim */
  89. int groupbook; /* huffbook for partitioning */
  90. int secondstages[64]; /* expanded out to pointers in lookup */
  91. int booklist[512]; /* list of second stage books */
  92. const int classmetric1[64];
  93. const int classmetric2[64];
  94. } vorbis_info_residue0;
  95. /* Mapping backend generic *****************************************/
  96. typedef struct{
  97. void (*pack) (vorbis_info *,vorbis_info_mapping *,
  98. oggpack_buffer *);
  99. vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
  100. void (*free_info) (vorbis_info_mapping *);
  101. int (*forward) (struct vorbis_block *vb);
  102. int (*inverse) (struct vorbis_block *vb,vorbis_info_mapping *);
  103. } vorbis_func_mapping;
  104. typedef struct vorbis_info_mapping0{
  105. int submaps; /* <= 16 */
  106. int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */
  107. int floorsubmap[16]; /* [mux] submap to floors */
  108. int residuesubmap[16]; /* [mux] submap to residue */
  109. int coupling_steps;
  110. int coupling_mag[256];
  111. int coupling_ang[256];
  112. } vorbis_info_mapping0;
  113. #endif