backends.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 backend and mapping structures; needed for
  13. static mode headers
  14. last mod: $Id$
  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. float **,int *,int);
  75. int (*forward) (oggpack_buffer *,struct vorbis_block *,
  76. vorbis_look_residue *,
  77. float **,float **,int *,int,long **);
  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 groupbook; /* huffbook for partitioning */
  89. int secondstages[64]; /* expanded out to pointers in lookup */
  90. int booklist[256]; /* list of second stage books */
  91. const float classmetric1[64];
  92. const float 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