2
0

mp3common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: RCSL 1.0/RPSL 1.0
  3. *
  4. * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
  5. *
  6. * The contents of this file, and the files included with this file, are
  7. * subject to the current version of the RealNetworks Public Source License
  8. * Version 1.0 (the "RPSL") available at
  9. * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10. * the file under the RealNetworks Community Source License Version 1.0
  11. * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
  12. * in which case the RCSL will apply. You may also obtain the license terms
  13. * directly from RealNetworks. You may not use this file except in
  14. * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
  15. * applicable to this file, the RCSL. Please see the applicable RPSL or
  16. * RCSL for the rights, obligations and limitations governing use of the
  17. * contents of the file.
  18. *
  19. * This file is part of the Helix DNA Technology. RealNetworks is the
  20. * developer of the Original Code and owns the copyrights in the portions
  21. * it created.
  22. *
  23. * This file, and the files included with this file, is distributed and made
  24. * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  25. * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  26. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
  27. * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  28. *
  29. * Technology Compatibility Kit Test Suite(s) Location:
  30. * http://www.helixcommunity.org/content/tck
  31. *
  32. * Contributor(s):
  33. *
  34. * ***** END LICENSE BLOCK ***** */
  35. /**************************************************************************************
  36. * Fixed-point MP3 decoder
  37. * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
  38. * June 2003
  39. *
  40. * mp3common.h - implementation-independent API's, datatypes, and definitions
  41. **************************************************************************************/
  42. #ifndef _MP3COMMON_H
  43. #define _MP3COMMON_H
  44. #include "mp3dec.h"
  45. #include "statname.h" /* do name-mangling for static linking */
  46. #define MAX_SCFBD 4 /* max scalefactor bands per channel */
  47. #define NGRANS_MPEG1 2
  48. #define NGRANS_MPEG2 1
  49. /* 11-bit syncword if MPEG 2.5 extensions are enabled */
  50. /*
  51. #define SYNCWORDH 0xff
  52. #define SYNCWORDL 0xe0
  53. */
  54. /* 12-bit syncword if MPEG 1,2 only are supported */
  55. #define SYNCWORDH 0xff
  56. #define SYNCWORDL 0xf0
  57. typedef struct _MP3DecInfo {
  58. /* pointers to platform-specific data structures */
  59. void *FrameHeaderPS;
  60. void *SideInfoPS;
  61. void *ScaleFactorInfoPS;
  62. void *HuffmanInfoPS;
  63. void *DequantInfoPS;
  64. void *IMDCTInfoPS;
  65. void *SubbandInfoPS;
  66. /* buffer which must be large enough to hold largest possible main_data section */
  67. unsigned char mainBuf[MAINBUF_SIZE];
  68. /* special info for "free" bitrate files */
  69. int freeBitrateFlag;
  70. int freeBitrateSlots;
  71. /* user-accessible info */
  72. int bitrate;
  73. int nChans;
  74. int samprate;
  75. int nGrans; /* granules per frame */
  76. int nGranSamps; /* samples per granule */
  77. int nSlots;
  78. int layer;
  79. MPEGVersion version;
  80. int mainDataBegin;
  81. int mainDataBytes;
  82. int part23Length[MAX_NGRAN][MAX_NCHAN];
  83. } MP3DecInfo;
  84. typedef struct _SFBandTable {
  85. int/*short*/ l[23];
  86. int/*short*/ s[14];
  87. } SFBandTable;
  88. /* decoder functions which must be implemented for each platform */
  89. MP3DecInfo *AllocateBuffers(void);
  90. void FreeBuffers(MP3DecInfo *mp3DecInfo);
  91. int CheckPadBit(MP3DecInfo *mp3DecInfo);
  92. int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf);
  93. int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf);
  94. int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch);
  95. int Dequantize(MP3DecInfo *mp3DecInfo, int gr);
  96. int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch);
  97. int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch);
  98. int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf);
  99. /* mp3tabs.c - global ROM tables */
  100. extern const int samplerateTab[3][3];
  101. extern const int/*short*/ bitrateTab[3][3][15];
  102. extern const int/*short*/ samplesPerFrameTab[3][3];
  103. extern const short bitsPerSlotTab[3];
  104. extern const int/*short*/ sideBytesTab[3][2];
  105. extern const int/*short*/ slotTab[3][3][15];
  106. extern const SFBandTable sfBandTable[3][3];
  107. #endif /* _MP3COMMON_H */