On Sun, Oct 01, 2000 at 09:10:19PM +0200, Robert Hegemann wrote:
>
> So for backward compatibility we should make a wrapper library
> with the old interface (as much as possible) and mark this as
> old and outdated, to give clients the possibility for smooth
> migration to the new API.
>
>
> old client new clients
> | |
> v |
> wrapper lib |
> | |
> +--------------------+---------
> | | |
> v v v
> lame-enc-lib lame-dec-lib lame-hdr-lib
>
>
> lame-enc-lib:
> - lame's encoding engine
> - maybe with Xing's VBR header stuff if it must be
>
> lame-dec-lib
> - lame's wrapper to the mpg123 library
>
> lame-hdr-lib
> - wave header
> - Xing header
> - ID3 stuff
>
> wrapper lib
> - the old libmp3lame and interface
>
What about the proposal to design and discuss a well designed lame API now
without implementation? AFAICS this takes at least 3 months, if you want to
have a durable and neat API, Mark don't want to change the API until summer
2001. May be should use this time to design all the structures are needed
and the lame.h file needed. This interface should be designed in a way, so
* no arbitrary constants are in it
* also Layer I, Layer II and AAC can added to this interface
* also multiple channels are possible
* feed count be int16, int32, float, double
* Support of huge arrays (open file, memmap, run encoder once, save result)
* solving 'Gap' problem
* solving compatibility problem with LAME 3.xx interface
I propose a file 'NewAPI.h', were all this is written down (prototypes and
rationale). This is better than only discussing and later forgetting the
results.
/*
* All Bitstream Data is stored in a bitbuffer_t structure. So you
* - only have to pass one argument
* - functions have the chance to increase the buffer if necessary
* - you don't need the return value to return the size of the MP3 data,
* so you can return other things (error codes or other stuff)
* - correctness of the bitbuffer parameter can be checked by the C Compiler
* - all functions have the same structure
*
typedef struct {
void* data; // data buffer, allocated via malloc ()
const size_t size; // maximal size of the data buffer
size_t len; // valid octets stored in this structure
} bitbuffer_t
/*
* The lame API only sees very little of the internal structure of
* _IO_LAME. Only if compiled with BUILD_LAME_LIB all elements are
* visible (and writable).
*/
typedef void (*fnptr) (...);
typedef struct {
#ifdef BUILD_LAME_LIB
const fnptr* virtual_function_table;
int128 struct_ID;
int init_state;
...
#else /* BUILD_LAME_LIB */
const fnptr* virtual_function_table;
const int128 struct_ID;
const int init_state;
const char __internal_data__ [32000];
#endif /* BUILD_LAME_LIB */
} _IO_LAME;
typedef int errorcode_t;
bitbuffer_t open_bitbuffer ( size_t size = 16384 );
int close_bitbuffer ( bitbuffer_t* buffer );
int set_FILE_binary ( FILE* fp );
LAME* lame_open ( void );
int lame_close ( LAME* lp );
/* Nice would be if this fucntions returns the exact input frequency. But this is only
possible if
the output frequency is available */
long double lame_set_input_samplefreq ( LAME* lp, long double freq = 44100.l );
long double lame_set_output_samplefreq ( LAME* lp, long double freq = 44100.l );
int lame_set_number_of_channels ( LAME* lp, int front = 2, int rear = 0, int
dual = 0, int docu = 0 );
int lame_set_min_bitrate ( LAME* lp, int minbitrate = 112000 );
int lame_set_max_bitrate ( LAME* lp, int maxbitrate = 320000 );
int lame_set_minmax_bitrate ( LAME* lp, int minbitrate = 112000,
maxbitrate = 320000 );
int lame_set_cbr_bitrate ( LAME* lp, int minbitrate = 128000 );
real lame_set_cwlimit ( LAME* lp, real freq = 8871.68 );
const char* lame_version ( LAME* lp );
real lame_set_mask_to_noise_ratio( LAME* lp, real ratio = 0. );
lame_mode_t lame_set_bitrate_mode ( LAME* lp, lame_mode_t mode = lame_cbr );
real lame_set_fullscale_level ( LAME* lp, real fullscale = 32768. );
int lame_set_coding_quality ( LAME* lp, int quality = 50 ); // 0 worst,
50 default, 100 best
int64 lame_read_coded_pcmsamples ( LAME* lp );
errorcode_t lame_encode_buffer_short (
LAME* lp,
bitbuffer_t* buffer,
size_t pcmdata_len,
const short* channel1,
... );
errorcode_t lame_encode_buffer_interleaved_short (
LAME* lp,
bitbuffer_t* buffer,
size_t pcmdata_len,
const short* channels );
errorcode_t lame_encode_finish (
LAME* lp,
bitbuffer_t* buffer );
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )