📄 im726.h
字号:
#ifndef IM726_H
#define IM726_H
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int G726HAND;
/*
Init G726 Encoder/Decoder
@return 0 - Success, 1 - Error
*/
extern unsigned int G726_init(G726HAND *phG726);
/*
将PCM数据编码为G726流
Each ADPCM value only occupies the minimum number of bits required and successive
values occupy adjacent bit positions. E.g. Four 3 bit ADPCM values (A,B,C,D) are
stored in two successive bytes like this: 1st byte: ccbbbaaa 2nd byte: ----dddc.
Note that any unused bits in the last byte are set to zero.
@param dst Pointer to location to store ADPCM values.
@param dstOffset Offset from \a dst, in number-of-bits, at which the decoded values
will be stored. I.e. the least significant bit of the first ADPCM
value will be stored in byte
@code dst[dstOffset>>3] @endcode
at bit position
@code dstOffset&7 @endcode
Where the bit 0 is the least significant bit in a byte
and bit 7 is the most significant bit.
@param src Pointer to the buffer of PCM values to be converted.
@param srcSize The size in bytes of the buffer at \a src.
Must be a multiple of the size of a single PCM sample.
@return The number of bits were stored in the \a dst buffer.
*/
extern unsigned int G726_Encode(G726HAND h, void* dst, int dstOffset, const void* src, unsigned srcSize);
/*
Decode a buffer of ADPCM values into 16 bit uniform PCM values.
Each ADPCM value only occupies the minimum number of bits required and successive
values occupy adjacent bit positions. E.g. Four 3 bit ADPCM values (A,B,C,D) are
stored in two successive bytes like this: 1st byte: ccbbbaaa 2nd byte: ----dddc.
@param dst Pointer to location to store PCM values.
@param src Pointer to the buffer of ADPCM values to be converted.
@param srcOffset Offset from \a src, in number-of-bits, from which the ADPCM values
will be read. I.e. the least significant bit of the first ADPCM
value will be read from byte
@code src[srcOffset>>3] @endcode
at bit position
@code srcOffset&7 @endcode
Where the bit 0 is the least significant bit in a byte
and bit 7 is the most significant bit.
@param srcSize The number of bits to be read from the buffer at \a src.
Must be a multiple of the size of a single ADPCM value.
@return The number of bytes which were stored in the \a dst buffer.
*/
extern unsigned int G726_Decode(G726HAND h, void* dst, const void* src, int srcOffset, unsigned srcSize);
/*
Clears the internal state variables to their 'reset' values.
Call this function before startings to decode/encode a new audio stream.
*/
extern unsigned int G726_Reset(G726HAND h);
/*
Close G726 instance
*/
extern unsigned int G726_Close(G726HAND h);
/* Call Sample
G726HAND g726enc, g726dec;
short src[128], dst[128];
int lenBits, lenBytes, i;
for(i = 0; i < 128; i++)
src[i] = rand(); //init src pcm buf to rand value
G726_init(&g726enc); // init encoder
G726_init(&g726dec); // init decoder
lenBits = G726_Encode(g726enc, dst, 0, src, 128); // encode
lenBytes = G726_Decode(g726dec, src, dst, 0, lenBits); // decode
*/
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -