Client Audio Encoding and Decoding Library API Reference
Client Audio Encoding and Decoding Library API Reference
API Reference
Issue 05
Date 2008-11-30
Part Number N/A
Notice
The information in this document is subject to change without notice. Every effort has been made in the
preparation of this document to ensure accuracy of the contents, but all statements, information, and
recommendations in this document do not constitute the warranty of any kind, express or implied.
Contents
3 Other Information......................................................................................................................3-1
3.1 Data Types...................................................................................................................................................3-1
3.2 Error Codes .................................................................................................................................................3-4
Tables
Purpose
This document describes the document contents, related product versions, intended audience,
conventions and update history.
Related Versions
The following table lists the product versions related to this document.
Intended Audience
This document is intended for the programmers who have a good command of the C
language.
Organization
This document is organized as follows:
Chapter Description
Chapter Description
Appendix A Acronyms Lists the abbreviations and acronyms and gives their full
and Abbreviations spellings.
Conventions
Symbol Conventions
The following symbols may be found in this document. They are defined as follows.
Symbol Description
General Conventions
Convention Description
Update History
Updates between document versions are cumulative. Therefore, the latest document version
contains all updates made to previous versions.
1 Overview
1.1 Scope
The client audio library supports the G.711, ADPCM, and G.726 codec. All the codecs are
specified with only 8 kHz sampling rate. The G.711 Codec provides both µ law and A law
companding and uses the non-linear quantizing method to compress the sampling data from
128 kbit/s to 64 kbit/s. The G.711 is used in the integrated service digital network (ISDN) and
most digital telephone backbones. The µ law encoding is commonly used in North America
and Japan. The A law is used throughout Europe and elsewhere. The adaptive differential
pulse code modulation (ADPCM) coder compresses 128 kbit/s linear data to 40, 32, 24, and
16 kbit/s code using the ADPCM technique.
Note Describes the matters that you need pay attention to when using a
data structure.
2 API References
[Description]
The API is used to initialize the state control data structure for the encoder and must be called
first when the channel is first created.
[Parameter]
[Return Value]
0 Success.
[Error Code]
[Request]
Header file: /include/hi_voice_api.h.
[Note]
The G711_ORG_A, G711_ORG_U, ADPCM_ORG_DVI4, and G726_ORG_16KBPS
encoder types are defined only for the Hi3510_VSSDK_V1.3.1.0. It is not recommended to
use the four encoder types in the later versions.
[Example]
HI_VOID VoiceDemo()
{
HI_RESULT Ret;
hiVOICE_G711_STATE_S g_sG711EncState;
Ret =HI_VOICE_EncReset (&g_sG711EncState, G711_A);
if (Ret != 0)
MyErrorExit("HISI_VOICE_enc_reset ");
else
printf("HISI_VOICE_enc_reset SUCCESS.\n");
}
[See Also]
HI_VOICE_EncodeFrame.
[Description]
The API is used to initialize the state control data structure for the decoder and must be called
first when the channel is first created.
[Parameter]
[Return Value]
0 Success.
Non-zero Failure. The return value is an error code.
[Error Code]
[Request]
Header file: /include/hi_voice_api.h.
[Note]
The G711_ORG_A, G711_ORG_U, ADPCM_ORG_DVI4, and G726_ORG_16KBPS
decoder types are defined only for the Hi3510_VSSDK_V1.3.1.0. It is not recommended to
use the four decoder types in the later versions.
[Example]
HI_VOID VoiceDemo()
{
HI_RESULT Ret;
hiVOICE_G711_STATE_S g_sG711DecState;
Ret=HI_VOICE_DecReset (&g_sG711DecState, G711_A);
if (Ret != 0)
MyErrorExit("HISI_VOICE_dec_reset");
else
printf("HISI_VOICE_dec_reset SUCCESS.\n");
}
[See Also]
HI_VOICE_DecodeFrame.
HI_VOICE_EncodeFrame
[Purpose]
Encode the audio input signal into a coded output packed in the Hisilicon voice frame.
[Syntax]
#include “hi_voice_api.h”
HI_VOICE_API HI_RESULT HI_VOICE_EncodeFrame(HI_VOID *pEncState,
HI_S16 *pInputBuf,
HI_S16 *pOutputBuf,
HI_S16 len);
[Description]
The API is used to encode the 16-bit audio input signal into a coded output pointed to by
pOutputBuf, and the output is packed in the Hisilicon voice frame. Note that the maximum
frame length is HI_VOICE_MAX_FRAME_SIZE. Generally, the frame length is a multiple
of 80, namely, 80, 160, 240, 320, or 480. But for the ADPCM_IMA codec, an extra sampling
point that functions as the reference level is required, so that the frame length is 81, 161, 241,
321, or 481.
[Parameter]
[Return Value]
0 Success.
Non-zero Failure. The return value is an error code.
[Error Code]
[Request]
Header file: /include/hi_voice_api.h.
[Note]
Ensure that the encoder is initialized before an encoding process.
[Example]
HI_VOID VoiceDemo()
{
Ret=HI_VOICE_EncodeFrame(&g_sG711EncState,in_pcm_buf,ou_enc_buf,MAX_FRAME
_SIZE);
}
[See Also]
z HI_VOICE_EncReset.
z Structure of the Hisilicon Voice Frame.
HI_VOICE_DecodeFrame
[Purpose]
[Description]
The API is used to transcode the coded input signal packed in the Hisilicon voice frame into a
decoded output, and the output is the 16-bit linear data.
[Parameter]
[Return Value]
0 Success.
Non-zero Failure. The return value is an error code.
[Error Code]
[Request]
Header file: /include/hi_voice_api.h.
[Note]
Ensure that the decoder is initialized and that the output buffer can accommodate a frame of
decoded data before a decoding process. The compressed data is packed in the Hisilicon voice
frame.
[Example]
HI_VOID VoiceDemo()
{
Ret = HI_VOICE_DecodeFrame(&g_sG711DecState, in_unpacked, ou_dec_pcmbuf,
&len);
}
[See Also]
z HI_VOICE_DecReset.
z Structure of the Hisilicon Voice Frame.
[Description]
The API is used to initialize the Hisilicon voice transcoder.
[Parameter]
[Return Value]
0 Success.
Non-zero Failure. The return value is an error code.
[Error Code]
[Request]
Header file: /include/hi_voice_api.h.
[Note]
The conversion process is available only for the Hi3510_VSSDK_V1.3.1.0 coded data.
[Example]
HI_VOID VoiceDemo()
{
HI_RESULT Ret;
hiVOICE_TRANSCODE_STATE_S g_TransState;
Ret= HI_VOICE_TransCodeReset (&g_TransState, ORG_G711A_TRANSF2_G711A);
if (Ret != 0)
MyErrorExit("HISI_VOICE_trans_reset");
else
printf("HISI_VOICE_trans_reset SUCCESS.\n");
}
[See Also]
HI_VOICE_TransCodeFrame.
HI_VOICE_TransCodeFrame
[Purpose]
Transcode the Hisilicon voice frame.
[Syntax]
#include “hi_voice_api.h”
HI_VOICE_API HI_RESULT HI_VOICE_TransCodeFrame (HI_VOID *pTransState,
HI_S16 *pInputBuf);
[Description]
The API is used to transcode the Hisilicon voice frame and puts the transcoded data packed in
the Hisilicon voice frame in the output buffer.
[Parameter]
[Return Value]
0 Success.
Non-zero Failure. The return value is an error code.
[Error Code]
[Request]
Header file: /include/hi_voice_api.h.
[Note]
z Ensure that the transcoder is initialized before a conversion process.
[See Also]
z HI_VOICE_TransCodeReset.
z Structure of the Hisilicon Voice Frame.
3 Other Information
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|B B B B|A A A A|D D D D|C C C C| ...
|0 1 2 3|0 1 2 3|0 1 2 3|0 1 2 3|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
MEDIA G726-32:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|A A A A|B B B B|C C C C|D D D D| ...
|3 2 1 0|3 2 1 0|3 2 1 0|3 2 1 0|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
*/
#define MEDIA_G726_16KBPS 0x24 /* G726 16kbit/s for ASF */
#define MEDIA_G726_24KBPS 0x25 /* G726 24kbit/s for ASF */
#define MEDIA_G726_32KBPS 0x26 /* G726 32kbit/s for ASF */
#define MEDIA_G726_40KBPS 0x27 /* G726 40kbit/s for ASF */
hiVOICE_G711_STATE_S
[Description]
State structure for the G711 encoder or decoder.
[Definition]
/* State for G711 encoder and decoder */
typedef struct hiVOICE_G711_STATE
{
HI_S32 G711StateBuf[2];
} hiVOICE_G711_STATE_S;
[Note]
The state structure for the G711 encoder or decoder is created independently.
hiVOICE_ADPCM_STATE_S
[Description]
State structure for the ADPCM encoder or decoder.
[Definition]
/* State for ADPCM encoder and decoder */
typedef struct hiVOICE_ADPCM_STATE
{
HI_S32 AdpcmStateBuf[4];
} hiVOICE_ADPCM_STATE_S;
[Note]
The state structure for the ADPCM encoder or decoder is created independently.
hiVOICE_G726_STATE_S
[Description]
[Note]
The state structure for the G.726 encoder or decoder is created independently.
hiVOICE_TRANSCODE_STATE_S
[Description]
State structure used to transcode the G711A, G711U, ADPCM_DVI4, and G726_16KBPS
codes from the Hi3510_VSSDK_V1.3.1.0 versions to the later versions.
[Definition]
/* State for TransCode */
typedef struct hiVOICE_TRANSCODE_STATE
{
HI_S32 TransStateBuf[0x400];
} hiVOICE_TRANSCODE_STATE_S;
[Note]
None.
A
ADPCM Adaptive Differential Pulse Code Modulation
P
PCM Pulse Code Modulation