version.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*
  2. * Version numbering for LAME.
  3. *
  4. * Copyright (c) 1999 A.L. Faber
  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. /*!
  22. \file version.c
  23. \brief Version numbering for LAME.
  24. Contains functions which describe the version of LAME.
  25. \author A.L. Faber
  26. \version \$Id: version.c,v 1.34 2011/11/18 09:51:02 robert Exp $
  27. \ingroup libmp3lame
  28. */
  29. #ifdef HAVE_CONFIG_H
  30. # include <config.h>
  31. #endif
  32. #include "lame.h"
  33. #include "machine.h"
  34. #include "version.h" /* macros of version numbers */
  35. /*! Get the LAME version string. */
  36. /*!
  37. \param void
  38. \return a pointer to a string which describes the version of LAME.
  39. */
  40. const char *
  41. get_lame_version(void)
  42. { /* primary to write screen reports */
  43. /* Here we can also add informations about compile time configurations */
  44. #if LAME_ALPHA_VERSION
  45. static /*@observer@ */ const char *const str =
  46. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
  47. "(alpha " STR(LAME_PATCH_VERSION) ", " __DATE__ " " __TIME__ ")";
  48. #elif LAME_BETA_VERSION
  49. static /*@observer@ */ const char *const str =
  50. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
  51. "(beta " STR(LAME_PATCH_VERSION) ", " __DATE__ ")";
  52. #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
  53. static /*@observer@ */ const char *const str =
  54. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
  55. #else
  56. static /*@observer@ */ const char *const str =
  57. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
  58. #endif
  59. return str;
  60. }
  61. /*! Get the short LAME version string. */
  62. /*!
  63. It's mainly for inclusion into the MP3 stream.
  64. \param void
  65. \return a pointer to the short version of the LAME version string.
  66. */
  67. const char *
  68. get_lame_short_version(void)
  69. {
  70. /* adding date and time to version string makes it harder for output
  71. validation */
  72. #if LAME_ALPHA_VERSION
  73. static /*@observer@ */ const char *const str =
  74. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (alpha " STR(LAME_PATCH_VERSION) ")";
  75. #elif LAME_BETA_VERSION
  76. static /*@observer@ */ const char *const str =
  77. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (beta " STR(LAME_PATCH_VERSION) ")";
  78. #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
  79. static /*@observer@ */ const char *const str =
  80. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
  81. #else
  82. static /*@observer@ */ const char *const str =
  83. STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
  84. #endif
  85. return str;
  86. }
  87. /*! Get the _very_ short LAME version string. */
  88. /*!
  89. It's used in the LAME VBR tag only.
  90. \param void
  91. \return a pointer to the short version of the LAME version string.
  92. */
  93. const char *
  94. get_lame_very_short_version(void)
  95. {
  96. /* adding date and time to version string makes it harder for output
  97. validation */
  98. #if LAME_ALPHA_VERSION
  99. #define P "a"
  100. #elif LAME_BETA_VERSION
  101. #define P "b"
  102. #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
  103. #define P "r"
  104. #else
  105. #define P " "
  106. #endif
  107. static /*@observer@ */ const char *const str =
  108. #if (LAME_PATCH_VERSION > 0)
  109. "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P STR(LAME_PATCH_VERSION)
  110. #else
  111. "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
  112. #endif
  113. ;
  114. return str;
  115. }
  116. /*! Get the _very_ short LAME version string. */
  117. /*!
  118. It's used in the LAME VBR tag only, limited to 9 characters max.
  119. Due to some 3rd party HW/SW decoders, it has to start with LAME.
  120. \param void
  121. \return a pointer to the short version of the LAME version string.
  122. */
  123. const char*
  124. get_lame_tag_encoder_short_version(void)
  125. {
  126. static /*@observer@ */ const char *const str =
  127. /* FIXME: new scheme / new version counting / drop versioning here ? */
  128. "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
  129. ;
  130. return str;
  131. }
  132. /*! Get the version string for GPSYCHO. */
  133. /*!
  134. \param void
  135. \return a pointer to a string which describes the version of GPSYCHO.
  136. */
  137. const char *
  138. get_psy_version(void)
  139. {
  140. #if PSY_ALPHA_VERSION > 0
  141. static /*@observer@ */ const char *const str =
  142. STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
  143. " (alpha " STR(PSY_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";
  144. #elif PSY_BETA_VERSION > 0
  145. static /*@observer@ */ const char *const str =
  146. STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
  147. " (beta " STR(PSY_BETA_VERSION) ", " __DATE__ ")";
  148. #else
  149. static /*@observer@ */ const char *const str =
  150. STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION);
  151. #endif
  152. return str;
  153. }
  154. /*! Get the URL for the LAME website. */
  155. /*!
  156. \param void
  157. \return a pointer to a string which is a URL for the LAME website.
  158. */
  159. const char *
  160. get_lame_url(void)
  161. {
  162. static /*@observer@ */ const char *const str = LAME_URL;
  163. return str;
  164. }
  165. /*! Get the numerical representation of the version. */
  166. /*!
  167. Writes the numerical representation of the version of LAME and
  168. GPSYCHO into lvp.
  169. \param lvp
  170. */
  171. void
  172. get_lame_version_numerical(lame_version_t * lvp)
  173. {
  174. static /*@observer@ */ const char *const features = ""; /* obsolete */
  175. /* generic version */
  176. lvp->major = LAME_MAJOR_VERSION;
  177. lvp->minor = LAME_MINOR_VERSION;
  178. #if LAME_ALPHA_VERSION
  179. lvp->alpha = LAME_PATCH_VERSION;
  180. lvp->beta = 0;
  181. #elif LAME_BETA_VERSION
  182. lvp->alpha = 0;
  183. lvp->beta = LAME_PATCH_VERSION;
  184. #else
  185. lvp->alpha = 0;
  186. lvp->beta = 0;
  187. #endif
  188. /* psy version */
  189. lvp->psy_major = PSY_MAJOR_VERSION;
  190. lvp->psy_minor = PSY_MINOR_VERSION;
  191. lvp->psy_alpha = PSY_ALPHA_VERSION;
  192. lvp->psy_beta = PSY_BETA_VERSION;
  193. /* compile time features */
  194. /*@-mustfree@ */
  195. lvp->features = features;
  196. /*@=mustfree@ */
  197. }
  198. const char *
  199. get_lame_os_bitness(void)
  200. {
  201. static /*@observer@ */ const char *const strXX = "";
  202. static /*@observer@ */ const char *const str32 = "32bits";
  203. static /*@observer@ */ const char *const str64 = "64bits";
  204. switch (sizeof(void *)) {
  205. case 4:
  206. return str32;
  207. case 8:
  208. return str64;
  209. default:
  210. return strXX;
  211. }
  212. }
  213. /* end of version.c */