BladeEnc DLL
version 1.0
(BladeEnc engine version 0.75)
Programmers Manual

BladeEnc.DLL and this manual is copyright Tord Jansson and may be distributed freely
as long as no modifications are made to neither one of them.

The BladeEnc engine is heavily based on distribution 10 of ISO's reference
source code for MPEG Layer 3 encoding.

The DLL-Interface for the BladeEnc engine was written by
Jukka Poikolainen
 

Homepage: http://bladeenc.home.ml.org
E-mail: tord.jansson@swipnet.se





Distribution

People and companies  who wants to distribute BladeEnc.DLL with their commercial products are free to do so as far as I'm concerned, but should be aware that BladeEnc.DLL might infringe certain MP3 related software patents held by Fraunhofer IIS in certain countries.

However, these patents are not valid in countries that doesn't approve of software patents, which includes Sweden and, as far as I know,  most other European Countries as well. Don't ask me for specific information about any other countries, I don't have that information.
 
 

Disclaimer

BladeEnc.DLL and this manual is distributed 'as is' with no warranty of any kind. The Author is not to be held responsible for the result of any use or misuse of this product.
 
 

Current Bugs and Limitations

Although the interface is designed to be able to handle multiple parallel streams it can't be done yet due to limitations in the engine, only one stream is allowed.
 

Future Compatibility

This interface should be compatible with all future versions of BladeEnc.DLL without any need to recompile your programs. You should therefore not check the version number upon start and prevent users from running your program with a later version of BladeEnc.DLL.
 

How to use the DLL

1. Fill in a PBE_CONFIG structure and send it to beInitStream(). Make sure that BE_ERR_SUCCESSFUL is returned.

2. Reserve at least the amount of memory returned in dwBufferSize as your output buffer.

3. Call beEncodeChunk() until you've encoded everything you want.

4. Call beDeinitStream() to make sure that all encoded data is flushed out before closing the stream.

5. Close the stream using beCloseStream().
 

Return Values

See the header-file for a complete list of function return values. All functions should return BE_ERR_SUCCESSFUL unless something went wrong.
 

The BE_CONFIG - structure

These are the members of the BE_CONFIG structure you need to fill in before you call beInitStream():
 
dwConfig Specifies what kind of output you want. Since only MP3 currently is supported you must set this to BE_CONFIG_MP3
format.mp3.dwSampleRate      Samplerate in Hz for MP3 file. This can be set to either 32000, 44100 or 48000.
format.mp3.byMode Stereomode for MP3 file. This can be either BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL or BE_MP3_MODE_MONO.
format.mp3.bitrate Bitrate (i.e. size) of MP3 file in kBit/s. Allowed bitrates are: 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320.
format.mp3.bCopyright If this is set to TRUE the Copyright bit in the MP3 stream will be set.
format.mp3.bCRC Set this to TRUE in order to enable CRC-checksum in the bitstream.
format.mp3.bOriginal If this is set to TRUE the Original bit in the MP3 stream will be set.
format.mp3.bPrivate If this is set to TRUE the Private bit in the MP3 stream will be set.

 


beInitStream()
Synopsis:  BE_ERR beInitStream( PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream )
Parameters:
pbeConfig Pointer at the struct containing encoder settings.
dwSamples Pointer at double word where number of samples to send to each beEncodeChunk() is returned.
dwBufferSize Pointer at double word where minimum size in bytes of output buffer is returned.
phbeStream Pointer at integer where Stream handle is returned.
Description: This function is the first to call before starting an encoding stream.



 
beEncodeChunk()
Synopsis: BE_ERR beEncodeChunk( HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput )
Parameters:
hbeStream Handle of the stream.
nSamples Number of samples to be encoded for this call. This should be identical to what is returned by beInitStream(), unless you are encoding the last chunk, which might be smaller.
pSamples Pointer at the 16-bit signed samples to be encoded. These should be in stereo when encoding a stereo MP3 and mono when encoding a mono MP3.
pOutput Where to write the encoded data. This buffer should be at least of the minimum size returned by beInitStream().
pdwOutput Where to return number of bytes of encoded data written. The amount of data written might vary from chunk to chunk.
Description: Encodes a chunk of samples. Please note that if you have set the output to generate mono MP3 files you must feed beEncodeChunk() with mono samples!

beDeinitStream()
Synopsis: BE_ERR beDeinitStream( HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput )
Parameters:
hbeStream Handle of the stream.
pOutput Where to write the encoded data. This buffer should be at least of the minimum size returned by beInitStream().
pdwOutput Where to return number of bytes of encoded data written.
Description: This function should be called after encoding the last chunk in order to flush the encoder. It writes any encoded data that still might be left inside the encoder to the output buffer. This function should NOT be called unless you have encoded all of the chunks in your stream.


beCloseStream()
Synopsis: BE_ERR beCloseStream( HBE_STREAM hbeStream )
Parameters:
hbeStream Handle of the stream.
Description: Last function to be called when finished encoding a stream. Should unlike beDeinitStream() also be called if the encoding is canceled.


beVersion()
Synopsis: VOID beVersion( PBE_VERSION pbeVersion )
Parameters:
pbeVersion Pointer at struct where version number, release date and URL for homepage is returned.
Description: Returns information like version numbers (both of the DLL and encoding engine), release date and URL for BladeEnc's homepage. All this information should be made available to the user of your product through a dialog box or something similar.