encoder.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * encoder.h include file
  3. *
  4. * Copyright (c) 2000 Mark Taylor
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef LAME_ENCODER_H
  22. #define LAME_ENCODER_H
  23. /***********************************************************************
  24. *
  25. * encoder and decoder delays
  26. *
  27. ***********************************************************************/
  28. /*
  29. * layer III enc->dec delay: 1056 (1057?) (observed)
  30. * layer II enc->dec delay: 480 (481?) (observed)
  31. *
  32. * polyphase 256-16 (dec or enc) = 240
  33. * mdct 256+32 (9*32) (dec or enc) = 288
  34. * total: 512+16
  35. *
  36. * My guess is that delay of polyphase filterbank is actualy 240.5
  37. * (there are technical reasons for this, see postings in mp3encoder).
  38. * So total Encode+Decode delay = ENCDELAY + 528 + 1
  39. */
  40. /*
  41. * ENCDELAY The encoder delay.
  42. *
  43. * Minimum allowed is MDCTDELAY (see below)
  44. *
  45. * The first 96 samples will be attenuated, so using a value less than 96
  46. * will result in corrupt data for the first 96-ENCDELAY samples.
  47. *
  48. * suggested: 576
  49. * set to 1160 to sync with FhG.
  50. */
  51. #define ENCDELAY 576
  52. /*
  53. * make sure there is at least one complete frame after the
  54. * last frame containing real data
  55. *
  56. * Using a value of 288 would be sufficient for a
  57. * a very sophisticated decoder that can decode granule-by-granule instead
  58. * of frame by frame. But lets not assume this, and assume the decoder
  59. * will not decode frame N unless it also has data for frame N+1
  60. *
  61. */
  62. /*#define POSTDELAY 288*/
  63. #define POSTDELAY 1152
  64. /*
  65. * delay of the MDCT used in mdct.c
  66. * original ISO routines had a delay of 528!
  67. * Takehiro's routines:
  68. */
  69. #define MDCTDELAY 48
  70. #define FFTOFFSET (224+MDCTDELAY)
  71. /*
  72. * Most decoders, including the one we use, have a delay of 528 samples.
  73. */
  74. #define DECDELAY 528
  75. /* number of subbands */
  76. #define SBLIMIT 32
  77. /* parition bands bands */
  78. #define CBANDS 64
  79. /* number of critical bands/scale factor bands where masking is computed*/
  80. #define SBPSY_l 21
  81. #define SBPSY_s 12
  82. /* total number of scalefactor bands encoded */
  83. #define SBMAX_l 22
  84. #define SBMAX_s 13
  85. #define PSFB21 6
  86. #define PSFB12 6
  87. /* FFT sizes */
  88. #define BLKSIZE 1024
  89. #define HBLKSIZE (BLKSIZE/2 + 1)
  90. #define BLKSIZE_s 256
  91. #define HBLKSIZE_s (BLKSIZE_s/2 + 1)
  92. /* #define switch_pe 1800 */
  93. #define NORM_TYPE 0
  94. #define START_TYPE 1
  95. #define SHORT_TYPE 2
  96. #define STOP_TYPE 3
  97. /*
  98. * Mode Extention:
  99. * When we are in stereo mode, there are 4 possible methods to store these
  100. * two channels. The stereo modes -m? are using a subset of them.
  101. *
  102. * -ms: MPG_MD_LR_LR
  103. * -mj: MPG_MD_LR_LR and MPG_MD_MS_LR
  104. * -mf: MPG_MD_MS_LR
  105. * -mi: all
  106. */
  107. #if 0
  108. #define MPG_MD_LR_LR 0
  109. #define MPG_MD_LR_I 1
  110. #define MPG_MD_MS_LR 2
  111. #define MPG_MD_MS_I 3
  112. #endif
  113. enum MPEGChannelMode
  114. { MPG_MD_LR_LR = 0
  115. , MPG_MD_LR_I = 1
  116. , MPG_MD_MS_LR = 2
  117. , MPG_MD_MS_I = 3
  118. };
  119. #ifndef lame_internal_flags_defined
  120. #define lame_internal_flags_defined
  121. struct lame_internal_flags;
  122. typedef struct lame_internal_flags lame_internal_flags;
  123. #endif
  124. int lame_encode_mp3_frame(lame_internal_flags * gfc,
  125. sample_t const *inbuf_l,
  126. sample_t const *inbuf_r, unsigned char *mp3buf, int mp3buf_size);
  127. #endif /* LAME_ENCODER_H */