backends.h 5.0 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. ********************************************************************/
  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. /* Floor backend generic *****************************************/
  23. typedef struct{
  24. void (*pack) (vorbis_info_floor *,oggpack_buffer *);
  25. vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
  26. vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_floor *);
  27. void (*free_info) (vorbis_info_floor *);
  28. void (*free_look) (vorbis_look_floor *);
  29. void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
  30. int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
  31. void *buffer,float *);
  32. } vorbis_func_floor;
  33. typedef struct{
  34. int order;
  35. long rate;
  36. long barkmap;
  37. int ampbits;
  38. int ampdB;
  39. int numbooks; /* <= 16 */
  40. int books[16];
  41. float lessthan; /* encode-only config setting hacks for libvorbis */
  42. float greaterthan; /* encode-only config setting hacks for libvorbis */
  43. } vorbis_info_floor0;
  44. #define VIF_POSIT 63
  45. #define VIF_CLASS 16
  46. #define VIF_PARTS 31
  47. typedef struct{
  48. int partitions; /* 0 to 31 */
  49. int partitionclass[VIF_PARTS]; /* 0 to 15 */
  50. int class_dim[VIF_CLASS]; /* 1 to 8 */
  51. int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */
  52. int class_book[VIF_CLASS]; /* subs ^ dim entries */
  53. int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
  54. int mult; /* 1 2 3 or 4 */
  55. int postlist[VIF_POSIT+2]; /* first two implicit */
  56. /* encode side analysis parameters */
  57. float maxover;
  58. float maxunder;
  59. float maxerr;
  60. float twofitweight;
  61. float twofitatten;
  62. int n;
  63. } vorbis_info_floor1;
  64. /* Residue backend generic *****************************************/
  65. typedef struct{
  66. void (*pack) (vorbis_info_residue *,oggpack_buffer *);
  67. vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
  68. vorbis_look_residue *(*look) (vorbis_dsp_state *,
  69. vorbis_info_residue *);
  70. void (*free_info) (vorbis_info_residue *);
  71. void (*free_look) (vorbis_look_residue *);
  72. long **(*class) (struct vorbis_block *,vorbis_look_residue *,
  73. int **,int *,int);
  74. int (*forward) (oggpack_buffer *,struct vorbis_block *,
  75. vorbis_look_residue *,
  76. int **,int *,int,long **,int);
  77. int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
  78. float **,int *,int);
  79. } vorbis_func_residue;
  80. typedef struct vorbis_info_residue0{
  81. /* block-partitioned VQ coded straight residue */
  82. long begin;
  83. long end;
  84. /* first stage (lossless partitioning) */
  85. int grouping; /* group n vectors per partition */
  86. int partitions; /* possible codebooks for a partition */
  87. int partvals; /* partitions ^ groupbook dim */
  88. int groupbook; /* huffbook for partitioning */
  89. int secondstages[64]; /* expanded out to pointers in lookup */
  90. int booklist[512]; /* list of second stage books */
  91. const int classmetric1[64];
  92. const int classmetric2[64];
  93. } vorbis_info_residue0;
  94. /* Mapping backend generic *****************************************/
  95. typedef struct{
  96. void (*pack) (vorbis_info *,vorbis_info_mapping *,
  97. oggpack_buffer *);
  98. vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
  99. void (*free_info) (vorbis_info_mapping *);
  100. int (*forward) (struct vorbis_block *vb);
  101. int (*inverse) (struct vorbis_block *vb,vorbis_info_mapping *);
  102. } vorbis_func_mapping;
  103. typedef struct vorbis_info_mapping0{
  104. int submaps; /* <= 16 */
  105. int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */
  106. int floorsubmap[16]; /* [mux] submap to floors */
  107. int residuesubmap[16]; /* [mux] submap to residue */
  108. int coupling_steps;
  109. int coupling_mag[256];
  110. int coupling_ang[256];
  111. } vorbis_info_mapping0;
  112. #endif