forked from EasyDarwin/EasyAACEncoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIDecodeToPcm.cpp
More file actions
92 lines (73 loc) · 1.64 KB
/
Copy pathIDecodeToPcm.cpp
File metadata and controls
92 lines (73 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "IDecodeToPcm.h"
#include "audio_buffer.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
IDecodeToPcm::IDecodeToPcm(void)
{
}
IDecodeToPcm::~IDecodeToPcm(void)
{
}
//------------------------------------------------------------------------------------------------------------------------
InAudioInfo::InAudioInfo()
{
InitParam& initParam = m_initparam;
initParam.u32AudioSamplerate=8000;
initParam.ucAudioChannel=1;
initParam.u32PCMBitSize=16;
initParam.ucAudioCodec = Law_ALaw;
}
InAudioInfo::InAudioInfo(InitParam param):m_initparam(param)
{
}
//------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
DecodeToPcmBase::DecodeToPcmBase(void)
{
}
DecodeToPcmBase::~DecodeToPcmBase(void)
{
}
int DecodeToPcmBase::Init(InAudioInfo info)
{
m_g7FrameSize = G711_ONE_LEN;
return 0;
}
int DecodeToPcmBase::PCMSize()
{
return CON_PCM_SIZE;
}
int DecodeToPcmBase::G7FrameSize()
{
return m_g7FrameSize;
}
int DecodeToPcmBase::Decode(unsigned char* pout_buf, unsigned int* pout_len , unsigned char* pin_buf, unsigned int in_len)
{
int16_t *dst = (int16_t *) pout_buf;
uint8_t *src = (uint8_t *) pin_buf;
uint32_t i = 0;
int Ret = 0;
if ((NULL == pout_buf) || \
(NULL == pout_len) || \
(NULL == pin_buf) || \
(0 == in_len))
{
return -1;
}
if (*pout_len < 2 * in_len)
{
return -2;
}
//---{{{
for (i = 0; i < in_len; i++)
{
*(dst++) = (int16_t)DecodeOneChar(*(src++));
}
//---}}}
*pout_len = 2 * in_len;
Ret = 2 * in_len;
return Ret;
return 0;
}