lame/CODING_STYLE, version 0.001 ;-)
---------------------------------------------------------------------
This is the first try of a Coding Style:
* Don't use tabulators (the character with the value '\t') in source code,
especially these with a width of unequal 8. Lame sources are using
different sizes for tabulators.
* Don't set the macro NDEBUG in alpha and beta versions.
* If you assume something, check this with an assert().
* Functions should be not longer than 50 lines of code.
Every function should only do ONE thing, and this should
be done well.
* Document functions.
* Use spaces in source code. They increase readablity.
* Use self explaining variable names, especially for interfaces.
* Use an intentation of 4. It's a good compromise between the
2 and the 8.
This is the first try of a Programming Style:
* Don't use single 'short' variables to save storage.
Short variables are especially on Pentium Class Computer much slower than
int's. DEC alpha also hates short variables.
Example: float bla [1024];
short i;
for ( i = 0; i < 1024; i++ )
bla [i] = i;
* To store PCM samples, use the type 'sample_t' defined in "lame.h".
Currently this is a 'signed short int' and I planed to move this to
'float'.
* Use the 'size_t' to store sizes of memory objects. Use 'off_t'
to store file offsets.
* Use the 'const' attribute if you don't intend to change the variable.
* use the 'unsigned' attribute for integer if a negative value makes
absolutely no sense.
* Use SI base units. Lame mixes Hz, kHz, kbps, bps. This is mess.
Example:
float wavelength_green = 555.e-9;
unsigned data_rate = 128000;
float lowpass_freq = 12500.;
Converting between user input and internal representation should be done
near the user interface, not in the most inner loop of an utility
function.
--
Mit freundlichen Grüßen
Frank Klemm
eMail | [EMAIL PROTECTED] home: [EMAIL PROTECTED]
phone | +49 (3641) 64-2721 home: +49 (3641) 390545
sMail | R.-Breitscheid-Str. 43, 07747 Jena, Germany
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )