Skip to content

Commit d4402ee

Browse files
author
spxnndl
committedNov 27, 2019
add cmake support; rm build warnings in test code
Use cmake can easy generate Makefile and IDE, for example, 1. generate Makefile: mkdir build; cd build; cmake .. 2. generate Makefile for ARM: mkdir build; cd build; cmake .. -DBUILD_ARM=ON 3. generate Xcode Project: mkdir build; cd build; cmake .. -G "Xcode" 4. generate VS2015 Project: mkdir build; cd build; cmake .. -G "Visual Studio 14"
1 parent deaa8ad commit d4402ee

File tree

9 files changed

+137
-116
lines changed

9 files changed

+137
-116
lines changed
 

‎.DS_Store

-6 KB
Binary file not shown.

‎.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.o
2+
.deps
3+
.dirstamp
4+
5+
.DS_Store
6+
.vscode

‎CMakeLists.txt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(solo VERSION 1.0.0 LANGUAGES C)
3+
4+
option(BUILD_ARM "Build ARM lib and test" OFF)
5+
6+
if (BUILD_ARM)
7+
set(CODE_PATH ${PROJECT_SOURCE_DIR}/JC1_SDK_SRC_ARM)
8+
else()
9+
set(CODE_PATH ${PROJECT_SOURCE_DIR}/JC1_SDK_SRC_FLP)
10+
endif()
11+
12+
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
13+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
14+
15+
include_directories(
16+
${CODE_PATH}/interface
17+
${CODE_PATH}/src/libBWE
18+
${CODE_PATH}/src/libSATECodec
19+
)
20+
21+
file(GLOB SRC_LIST
22+
${CODE_PATH}/interface/*.h
23+
${CODE_PATH}/src/libBWE/*.c
24+
${CODE_PATH}/src/libBWE/*.h
25+
${CODE_PATH}/src/libSATECodec/*.c
26+
${CODE_PATH}/src/libSATECodec/*.h
27+
)
28+
29+
add_library(JC1Codec STATIC ${SRC_LIST})
30+
31+
add_executable(JC1Encoder ${CODE_PATH}/test/enc_main.c)
32+
target_link_libraries(JC1Encoder JC1Codec)
33+
34+
add_executable(JC1Decoder ${CODE_PATH}/test/dec_main.c)
35+
target_link_libraries(JC1Decoder JC1Codec)

‎JC1_SDK_SRC_ARM/.DS_Store

-6 KB
Binary file not shown.

‎JC1_SDK_SRC_ARM/test/dec_main.c

+23-32
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) _stricmp(x, y)
1010
#else
1111
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y)
12-
#endif
12+
#endif
1313

1414

1515
#pragma comment(lib,"libSATECodec_FIX.lib")
1616
#pragma comment(lib,"libBWE.lib")
1717

1818

19-
20-
2119
/* PSEUDO-RANDOM GENERATOR */
2220
/* Make sure to store the result as the seed for the next call (also in between */
2321
/* frames), otherwise result won't be random at all. When only using some of the */
@@ -29,7 +27,7 @@
2927
#define cmdControl
3028

3129
/* Define codec specific settings */
32-
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
30+
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
3331
#define FRAME_LENGTH_MS 20
3432
#define MAX_API_FS_KHZ 48
3533
#define MAX_FRAME_SIZE 1920
@@ -55,19 +53,13 @@ int main(int argc, char **argv)
5553
FILE *fin;
5654
FILE *fout;
5755
void *stDec;
58-
//short nbBytes;
59-
6056
int frame = 0,j;
61-
int codec_type = 0;
6257
short FrmBuf[MAX_FRAME_SIZE];
63-
6458
size_t counter;
6559
int totPackets, lost, quiet = 0, i, k;
66-
short tot_len;
6760
short nBytes[6] = { 0, 0, 0, 0, 0, 0};
6861
unsigned char payload[MAX_FRAME_BYTES];
6962
unsigned char *payloadEnd = NULL, *payloadToDec = NULL;
70-
short out[ MAX_FRAME_SIZE ], *outPtr;
7163
int loss_prob;
7264
int sate_plc = 1; // 1 for SATE PLC, 0 for SILK PLC
7365
int dec_mode = 0,MDI_in_bitstream = 0;
@@ -76,13 +68,12 @@ int main(int argc, char **argv)
7668
int lostMD[8];
7769
int lostcnt = 0;
7870
int MD_type = 0;
79-
8071
short nSamplesOut;
8172

8273
USER_Ctrl_dec dec_Ctrl;
8374

8475
#ifndef cmdControl
85-
76+
8677
char *InFileName = "..\\Testseq\\Ch_f1_raw.pcm";
8778
char *MidFileName= "..\\Testseq\\ch8kall_16k.enc";
8879
char *OutFileName= "..\\Testseq\\Ch_f1_scodec.dec";
@@ -147,7 +138,7 @@ int main(int argc, char **argv)
147138

148139
if((dec_mode > 0) && (dec_Ctrl.packetLoss_perc > 0))
149140
{
150-
141+
151142
printf("dec_mode is the test for the single stream decoding\n");
152143
printf("loss and dec_mode can't be set at the same time\n");
153144
exit(0);
@@ -174,30 +165,29 @@ int main(int argc, char **argv)
174165

175166
printf("inputfile : %s\n",InFileName);
176167
printf("outputfile: %s\n",OutFileName);
177-
178168

179-
if((dec_Ctrl.framesize_ms != 40)&&
180-
(dec_Ctrl.framesize_ms != 80)&&
181-
(dec_Ctrl.framesize_ms != 120)&&
169+
170+
if((dec_Ctrl.framesize_ms != 40)&&
171+
(dec_Ctrl.framesize_ms != 80)&&
172+
(dec_Ctrl.framesize_ms != 120)&&
182173
(dec_Ctrl.framesize_ms != 160))
183174
{
184175
fprintf(stderr," framesize (ms) must be integer times of 40\n");
185176
return 0;
186177
}
187-
188-
if((dec_Ctrl.samplerate != 16000)&&
189-
(dec_Ctrl.samplerate != 32000)&&
178+
179+
if((dec_Ctrl.samplerate != 16000)&&
180+
(dec_Ctrl.samplerate != 32000)&&
190181
(dec_Ctrl.samplerate != 48000))
191182
{
192183
fprintf(stderr," sample rate (hz) must be 16000 , 32000 or 48000\n");
193184
return 0;
194185
}
195-
196-
186+
197187
dec_Ctrl.useMDIndex = MDI_in_bitstream;
198188
stDec = AGR_Sate_Decoder_Init(&dec_Ctrl);
199189
frame =0;
200-
190+
201191
nwrite = dec_Ctrl.framesize_ms*dec_Ctrl.samplerate/1000;
202192

203193
/* default settings */
@@ -228,15 +218,16 @@ int main(int argc, char **argv)
228218
229219
MD1 Steam = Low Band MD1 Stream
230220
MD2 Steam = Low Band MD2 Stream + High Band Stream
231-
Length£¨ MD1 Steam £© = Length£¨ Low Band MD1 Stream £©
232-
Length£¨ MD2 Steam £© = Length£¨ Low Band MD2 Stream £© + Length£¨ High Band Stream £©
233-
Byte0 = Length£¨ MD1 Steam £© + Length£¨ MD2 Steam £©
234-
= Length£¨ Low Band MD1 Stream £© + Length£¨ Low Band MD2 Stream £© + Length£¨ High Band Stream £©
235-
Byte1 = Length£¨ MD2 Steam £©
221+
Length(MD1 Stream) = Length(Low Band MD1 Stream)
222+
Length(MD2 Stream) = Length(Low Band MD2 Stream) + Length(High Band Stream)
223+
Byte0 = Length(MD1 Stream) + Length(MD2 Stream)
224+
= Length(Low Band MD1 Stream) + Length(Low Band MD2 Stream) + Length(High Band Stream)
225+
Byte1 = Length(MD2 Stream)
236226
237227
*/
238228

239-
counter = fread(payloadEnd, sizeof(unsigned char), nBytes[0], fin);
229+
counter = fread(payloadEnd, sizeof(unsigned char), nBytes[0], fin);
230+
240231
if( ( short )counter < nBytes[0] ) {
241232
break;
242233
}
@@ -251,7 +242,7 @@ int main(int argc, char **argv)
251242
if(nBytes[j] == 0)
252243
lostMD[j] = 1;
253244
else
254-
lostMD[j] = 0;
245+
lostMD[j] = 0;
255246
}
256247
else {
257248
lostMD[j] = 1;
@@ -292,7 +283,7 @@ int main(int argc, char **argv)
292283
else if ((lostMD[0] == 1) && (lostMD[1] == 0))
293284
{/* Loss the MD1 Steam ,use the MD2 Steam */
294285
lost = 0;
295-
payloadToDec = payload + nBytes[0] - nBytes[1];
286+
payloadToDec = payload + nBytes[0] - nBytes[1];
296287
nBytes[0] = nBytes[1];
297288
nBytes[1] = 0;
298289
MD_type = 1;
@@ -363,7 +354,7 @@ int main(int argc, char **argv)
363354
else if(dec_mode == 2)
364355
{
365356
lost = 0;
366-
payloadToDec = payload + nBytes[0] - nBytes[1];
357+
payloadToDec = payload + nBytes[0] - nBytes[1];
367358
nBytes[0] = nBytes[1];
368359
nBytes[1] = 0;
369360
MD_type = 1;

‎JC1_SDK_SRC_ARM/test/enc_main.c

+26-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
#include <stdio.h>
3-
#include <string.h>
42
#include <stdlib.h>
5-
#include <io.h>
3+
#include <string.h>
4+
#include <unistd.h>
65

76
#include "AGR_JC1_SDK_API.h"
87

@@ -18,7 +17,7 @@
1817
#define MAX_FRAME_BYTES 1024
1918

2019
/* Define codec specific settings */
21-
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
20+
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
2221
#define MAX_INPUT_FRAMES 5
2322
#define MAX_LBRR_DELAY 2
2423
#define MAX_FRAME_LENGTH 480
@@ -29,7 +28,7 @@
2928
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) _stricmp(x, y)
3029
#else
3130
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y)
32-
#endif
31+
#endif
3332

3433

3534
static void print_usage( char* argv[] ) {
@@ -57,7 +56,7 @@ int main(int argc, char **argv)
5756
int k, totPackets, totActPackets;
5857
double sumBytes, sumCoreBytes, sumActBytes, avg_rate, avg_md2_rate, act_rate, nrg, sumBytes2;//,avg_rate2;
5958

60-
char cbits[MAX_FRAME_BYTES];
59+
unsigned char cbits[MAX_FRAME_BYTES];
6160

6261

6362
int frame = 0;
@@ -98,7 +97,7 @@ int main(int argc, char **argv)
9897
enc_Ctrl.joint_enable = 0;
9998
enc_Ctrl.joint_mode = 0;
10099
enc_Ctrl.framesize_ms = 40;
101-
100+
102101
if( argc < 3 ) {
103102
print_usage( argv );
104103
exit( 0 );
@@ -147,13 +146,13 @@ int main(int argc, char **argv)
147146
joint disable
148147
20ms 2MD
149148
40ms 2MD
150-
joint mode 0 reserve for low band multiframe joint coding
149+
joint mode 0 reserve for low band multiframe joint coding
151150
joint mode 1 high band multiframe joint coding method 0
152151
joint mode 2 reserve for high band multiframe joint coding method 1 (LPC and Res)
153-
joint mode 3 reserve for low band and high band all multiframe joint coding
152+
joint mode 3 reserve for low band and high band all multiframe joint coding
154153
reserve for 1. low band multiframe joint coding is OK
155154
2. select a better joint method in 0 or 1 of high band
156-
155+
157156
*/
158157
#endif
159158
if(enc_Ctrl.samplerate != 16000)
@@ -193,16 +192,16 @@ int main(int argc, char **argv)
193192

194193
while(fread(&FrmBuf[0],sizeof(short),nread,fin)==nread)
195194
{
196-
197195
//if(deg_info)printf("********************* frame : %d************************\n",frame);
198196

197+
memset(nBytes, 0, sizeof(short) * 6);
199198
nBytesX = AGR_Sate_Encoder_Encode(stEnc,&FrmBuf[0],cbits, MAX_FRAME_BYTES, &nBytes[0]);
200-
199+
201200
if (nBytesX < 0) {
202201
printf("\nYY_SSC_Encode returned %d", nBytesX);
203202
break;
204203
}
205-
204+
206205
smplsSinceLastPacket += nread;
207206

208207
if( ( ( 1000 * smplsSinceLastPacket ) / enc_Ctrl.samplerate ) == packetSize_ms ) {
@@ -232,26 +231,25 @@ int main(int argc, char **argv)
232231
233232
MD1 Steam = Low Band MD1 Stream
234233
MD2 Steam = Low Band MD2 Stream + High Band Stream
235-
LengthMD1 Steam ) = LengthLow Band MD1 Stream
236-
LengthMD2 Steam ) = LengthLow Band MD2 Stream+ LengthHigh Band Stream
237-
Byte0 = LengthMD1 Steam+ LengthMD2 Steam
238-
= LengthLow Band MD1 Stream+ LengthLow Band MD2 Stream+ LengthHigh Band Stream
239-
Byte1 = LengthMD2 Steam
234+
Length(MD1 Steam) = Length(Low Band MD1 Stream)
235+
Length(MD2 Steam) = Length(Low Band MD2 Stream) + Length(High Band Stream)
236+
Byte0 = Length(MD1 Steam) + Length(MD2 Steam)
237+
= Length(Low Band MD1 Stream) + Length(Low Band MD2 Stream) + Length(High Band Stream)
238+
Byte1 = Length(MD2 Steam)
240239
241240
*/
242-
//printf("nbBytes = %d\n",nBytes);
243-
241+
//printf("nbBytes = %d\n",nBytes);
242+
244243
fwrite(&nBytes[0], sizeof(short), 1, fout);
245-
fwrite(&nBytes[1], sizeof(short), 1, fout);
244+
fwrite(&nBytes[1], sizeof(short), 1, fout);
246245

247246
if (nBytes[0])
248247
{
249248
fwrite(&cbits[0], sizeof(char), nBytesX, fout);
250249
}
251250

252-
memset(nBytes, 0, sizeof(short) * 6);
253251
frame++;
254-
printf("%d frames processed!\r",frame);
252+
printf("%d frames processed!\r",frame);
255253
}//end while()
256254

257255
if (frame == 0)
@@ -263,10 +261,10 @@ int main(int argc, char **argv)
263261
avg_rate = 8.0 / packetSize_ms * sumBytes / totPackets;
264262
avg_md2_rate = 8.0 / packetSize_ms * sumBytes2 / totPackets;
265263
act_rate = 8.0 / packetSize_ms * sumActBytes / totActPackets;
266-
printf("\n\nAverage bitrate: %.3f kbps", (avg_rate - avg_md2_rate));
267-
printf("\nAverage bitrate: %.3f kbps", avg_md2_rate);
268-
printf("\nAverage T bitrate: %.3f kbps", (avg_rate));
269-
printf("\nActive bitrate: %.3f kbps", act_rate);
264+
printf("\n\nAverage bitrate: %.3f kbps", (avg_rate - avg_md2_rate));
265+
printf("\nAverage bitrate: %.3f kbps", avg_md2_rate);
266+
printf("\nAverage T bitrate: %.3f kbps", (avg_rate));
267+
printf("\nActive bitrate: %.3f kbps", act_rate);
270268
printf("\n\n");
271269

272270
}
@@ -277,7 +275,7 @@ int main(int argc, char **argv)
277275
fclose(fin);
278276
fclose(fout);
279277

280-
if(access("_bitrate.txt",0))//判断目录是否存在
278+
if(access("_bitrate.txt",0))
281279
{
282280
FILE *brf;
283281
brf = fopen("_bitrate.txt","wb+");

‎JC1_SDK_SRC_FLP/test/dec_main.c

+21-25
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,25 @@
99
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) _stricmp(x, y)
1010
#else
1111
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y)
12-
#endif
12+
#endif
1313

1414

1515
#pragma comment(lib,"libSATECodec_FLP.lib")
1616
#pragma comment(lib,"libBWE.lib")
1717

1818

19-
20-
2119
/* PSEUDO-RANDOM GENERATOR */
2220
/* Make sure to store the result as the seed for the next call (also in between */
2321
/* frames), otherwise result won't be random at all. When only using some of the */
2422
/* bits, take the most significant bits by right-shifting. Do not just mask off */
25-
/* the lowest bits. */
23+
/* the lowest bits. */
2624
#define SKP_RAND(seed) ((907633515) + (seed) * (196314165))
2725

2826

2927
#define cmdControl
3028

3129
/* Define codec specific settings */
32-
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
30+
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
3331
#define FRAME_LENGTH_MS 20
3432
#define MAX_API_FS_KHZ 48
3533
#define MAX_FRAME_SIZE 1920
@@ -56,7 +54,6 @@ int main(int argc, char **argv)
5654
FILE *fout;
5755
void *stDec;
5856
int frame = 0,j;
59-
int codec_type = 0;
6057
short FrmBuf[MAX_FRAME_SIZE];
6158
size_t counter;
6259
int totPackets, lost, quiet = 0, i, k;
@@ -76,7 +73,7 @@ int main(int argc, char **argv)
7673
USER_Ctrl_dec dec_Ctrl;
7774

7875
#ifndef cmdControl
79-
76+
8077
char *InFileName = "..\\Testseq\\Ch_f1_raw.pcm";
8178
char *MidFileName= "..\\Testseq\\ch8kall_16k.enc";
8279
char *OutFileName= "..\\Testseq\\Ch_f1_scodec.dec";
@@ -163,28 +160,27 @@ int main(int argc, char **argv)
163160

164161
printf("inputfile : %s\n",InFileName);
165162
printf("outputfile: %s\n",OutFileName);
166-
167163

168-
if((dec_Ctrl.framesize_ms != 40)&&
169-
(dec_Ctrl.framesize_ms != 80)&&
170-
(dec_Ctrl.framesize_ms != 120)&&
164+
165+
if((dec_Ctrl.framesize_ms != 40)&&
166+
(dec_Ctrl.framesize_ms != 80)&&
167+
(dec_Ctrl.framesize_ms != 120)&&
171168
(dec_Ctrl.framesize_ms != 160)){
172169
fprintf(stderr," framesize (ms) must be integer times of 40\n");
173170
return 0;
174171
}
175-
176-
if((dec_Ctrl.samplerate != 16000)&&
177-
(dec_Ctrl.samplerate != 32000)&&
172+
173+
if((dec_Ctrl.samplerate != 16000)&&
174+
(dec_Ctrl.samplerate != 32000)&&
178175
(dec_Ctrl.samplerate != 48000)){
179176
fprintf(stderr," sample rate (hz) must be 16000 , 32000 or 48000\n");
180177
return 0;
181178
}
182179

183-
184180
dec_Ctrl.useMDIndex = MDI_in_bitstream;
185181
stDec = AGR_Sate_Decoder_Init(&dec_Ctrl);
186182
frame =0;
187-
183+
188184
nwrite = dec_Ctrl.framesize_ms*dec_Ctrl.samplerate/1000;
189185

190186
/* default settings */
@@ -213,16 +209,16 @@ int main(int argc, char **argv)
213209
214210
MD1 Steam = Low Band MD1 Stream
215211
MD2 Steam = Low Band MD2 Stream + High Band Stream
216-
Length£¨ MD1 Steam £© = Length£¨ Low Band MD1 Stream £©
217-
Length£¨ MD2 Steam £© = Length£¨ Low Band MD2 Stream £© + Length£¨ High Band Stream £©
218-
Byte0 = Length£¨ MD1 Steam £© + Length£¨ MD2 Steam £©
219-
= Length£¨ Low Band MD1 Stream £© + Length£¨ Low Band MD2 Stream £© + Length£¨ High Band Stream £©
220-
Byte1 = Length£¨ MD2 Steam £©
212+
Length(MD1 Stream) = Length(Low Band MD1 Stream)
213+
Length(MD2 Stream) = Length(Low Band MD2 Stream) + Length(High Band Stream)
214+
Byte0 = Length(MD1 Stream) + Length(MD2 Stream)
215+
= Length(Low Band MD1 Stream) + Length(Low Band MD2 Stream) + Length(High Band Stream)
216+
Byte1 = Length(MD2 Stream)
221217
222218
*/
223219

224220
counter = fread(payloadEnd, sizeof(unsigned char), nBytes[0], fin);
225-
221+
226222
if( ( short )counter < nBytes[0] ) {
227223
break;
228224
}
@@ -270,7 +266,7 @@ int main(int argc, char **argv)
270266
#endif
271267
}else if ((lostMD[0] == 1) && (lostMD[1] == 0)) {/* Loss the MD1 Steam ,use the MD2 Steam */
272268
lost = 0;
273-
payloadToDec = payload + nBytes[0] - nBytes[1];
269+
payloadToDec = payload + nBytes[0] - nBytes[1];
274270
nBytes[0] = nBytes[1];
275271
nBytes[1] = 0;
276272
MD_type = 1;
@@ -325,7 +321,7 @@ int main(int argc, char **argv)
325321
MD_type = 0;
326322
}else if(dec_mode == 2){
327323
lost = 0;
328-
payloadToDec = payload + nBytes[0] - nBytes[1];
324+
payloadToDec = payload + nBytes[0] - nBytes[1];
329325
nBytes[0] = nBytes[1];
330326
nBytes[1] = 0;
331327
MD_type = 1;
@@ -354,7 +350,7 @@ int main(int argc, char **argv)
354350
}
355351

356352
DecEnd:
357-
353+
358354
AGR_Sate_Decoder_Uninit(stDec);
359355

360356
fclose(fin);

‎JC1_SDK_SRC_FLP/test/enc_main.c

+25-30
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
#include <stdio.h>
3-
#include <string.h>
42
#include <stdlib.h>
5-
#include <io.h>
3+
#include <string.h>
4+
#include <unistd.h>
65

76
#include "AGR_JC1_SDK_API.h"
87

@@ -15,7 +14,7 @@
1514
#define MAX_FRAME_BYTES 1024
1615

1716
/* Define codec specific settings */
18-
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
17+
#define MAX_BYTES_PER_FRAME 250 // Equals peak bitrate of 100 kbps
1918
#define MAX_INPUT_FRAMES 5
2019
#define MAX_LBRR_DELAY 2
2120
#define MAX_FRAME_LENGTH 480
@@ -26,7 +25,7 @@
2625
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) _stricmp(x, y)
2726
#else
2827
# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y)
29-
#endif
28+
#endif
3029

3130

3231
static void print_usage( char* argv[] ) {
@@ -54,19 +53,16 @@ int main(int argc, char **argv)
5453
int k, totPackets, totActPackets;
5554
double sumBytes, sumCoreBytes, sumActBytes, avg_rate, avg_md2_rate, act_rate, nrg, sumBytes2;//,avg_rate2;
5655

57-
char cbits[MAX_FRAME_BYTES];
56+
unsigned char cbits[MAX_FRAME_BYTES];
5857

5958

6059
int frame = 0;
61-
int codec_type = 0;
6260
short FrmBuf[MAX_FRAME_SIZE];
6361

6462
/* default settings */
6563
int API_fs_Hz = 16000;
66-
int max_internal_fs_Hz = 0;
6764
int packetSize_ms;
6865
int quiet = 0;
69-
int deg_info = 1;
7066
int smplsSinceLastPacket;
7167
short nBytes[6] = {0,0,0,0,0,0};
7268
int WriteMDI = 0;
@@ -86,7 +82,7 @@ int main(int argc, char **argv)
8682
enc_Ctrl.joint_enable = 0;
8783
enc_Ctrl.joint_mode = 0;
8884
enc_Ctrl.framesize_ms = 40;
89-
85+
9086
if( argc < 3 ) {
9187
print_usage( argv );
9288
exit( 0 );
@@ -135,13 +131,13 @@ int main(int argc, char **argv)
135131
joint disable
136132
20ms 2MD
137133
40ms 2MD
138-
joint mode 0 reserve for low band multiframe joint coding
134+
joint mode 0 reserve for low band multiframe joint coding
139135
joint mode 1 high band multiframe joint coding method 0
140136
joint mode 2 reserve for high band multiframe joint coding method 1 (LPC and Res)
141-
joint mode 3 reserve for low band and high band all multiframe joint coding
137+
joint mode 3 reserve for low band and high band all multiframe joint coding
142138
reserve for 1. low band multiframe joint coding is OK
143139
2. select a better joint method in 0 or 1 of high band
144-
140+
145141
*/
146142

147143
if(enc_Ctrl.samplerate != 16000)
@@ -181,14 +177,14 @@ int main(int argc, char **argv)
181177

182178
while(fread(&FrmBuf[0],sizeof(short),nread,fin)==nread)
183179
{
180+
memset(nBytes, 0, sizeof(short) * 6);
181+
nBytesX = AGR_Sate_Encoder_Encode(stEnc, &FrmBuf[0], cbits, MAX_FRAME_BYTES, &nBytes[0]);
184182

185-
nBytesX = AGR_Sate_Encoder_Encode(stEnc,&FrmBuf[0],cbits, MAX_FRAME_BYTES, &nBytes[0]);
186-
187183
if (nBytesX < 0) {
188184
printf("\nYY_SSC_Encode returned %d", nBytesX);
189185
break;
190186
}
191-
187+
192188
smplsSinceLastPacket += nread;
193189

194190
if( ( ( 1000 * smplsSinceLastPacket ) / enc_Ctrl.samplerate ) == packetSize_ms ) {
@@ -209,7 +205,7 @@ int main(int argc, char **argv)
209205
smplsSinceLastPacket = 0;
210206
}
211207

212-
208+
213209
/*
214210
215211
|-------|-------|---------------------|---------------------|---------------------|
@@ -218,25 +214,24 @@ int main(int argc, char **argv)
218214
219215
MD1 Steam = Low Band MD1 Stream
220216
MD2 Steam = Low Band MD2 Stream + High Band Stream
221-
Length£¨ MD1 Steam £© = Length£¨ Low Band MD1 Stream £©
222-
Length£¨ MD2 Steam £© = Length£¨ Low Band MD2 Stream £© + Length£¨ High Band Stream £©
223-
Byte0 = Length£¨ MD1 Steam £© + Length£¨ MD2 Steam £©
224-
= Length£¨ Low Band MD1 Stream £© + Length£¨ Low Band MD2 Stream £© + Length£¨ High Band Stream £©
225-
Byte1 = Length£¨ MD2 Steam £©
217+
Length(MD1 Steam) = Length(Low Band MD1 Stream)
218+
Length(MD2 Steam) = Length(Low Band MD2 Stream) + Length(High Band Stream)
219+
Byte0 = Length(MD1 Steam) + Length(MD2 Steam)
220+
= Length(Low Band MD1 Stream) + Length(Low Band MD2 Stream) + Length(High Band Stream)
221+
Byte1 = Length(MD2 Steam)
226222
227223
*/
228-
224+
229225
fwrite(&nBytes[0], sizeof(short), 1, fout);
230-
fwrite(&nBytes[1], sizeof(short), 1, fout);
226+
fwrite(&nBytes[1], sizeof(short), 1, fout);
231227

232228
if (nBytes[0])
233229
{
234230
fwrite(&cbits[0], sizeof(char), nBytesX, fout);
235231
}
236232

237-
memset(nBytes, 0, sizeof(short) * 6);
238233
frame++;
239-
printf("%d frames processed!\r",frame);
234+
printf("%d frames processed!\r",frame);
240235
}//end while()
241236

242237
if (frame == 0)
@@ -248,10 +243,10 @@ int main(int argc, char **argv)
248243
avg_rate = 8.0 / packetSize_ms * sumBytes / totPackets;
249244
avg_md2_rate = 8.0 / packetSize_ms * sumBytes2 / totPackets;
250245
act_rate = 8.0 / packetSize_ms * sumActBytes / totActPackets;
251-
printf("\n\nAverage bitrate: %.3f kbps", (avg_rate - avg_md2_rate));
252-
printf("\nAverage bitrate: %.3f kbps", avg_md2_rate);
253-
printf("\nAverage T bitrate: %.3f kbps", (avg_rate));
254-
printf("\nActive bitrate: %.3f kbps", act_rate);
246+
printf("\n\nAverage bitrate: %.3f kbps", (avg_rate - avg_md2_rate));
247+
printf("\nAverage bitrate: %.3f kbps", avg_md2_rate);
248+
printf("\nAverage T bitrate: %.3f kbps", (avg_rate));
249+
printf("\nActive bitrate: %.3f kbps", act_rate);
255250
printf("\n\n");
256251

257252
}

‎README.zh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Solo默认配置为每次输入40ms(2帧),输出两段互补的多描述
5151
![solo_API_de](https://github.com/AgoraIO-Community/Solo/blob/master/imag/solo_API_de.png)
5252

5353
## 编码端分包发送
54-
编码器每次输入40ms信号,输出的是一整段包含两段互补码流的码流。如图所示,蓝色框和橙色框分别代表输出码流里的两段独立码流,每段码流都包含帧1和帧2的信息,编码器输出码流的同时,也会通过nBytesOut输出每段互补码流的长度,nBytesOut[0]表示码流总长度,nBytesOut[1]表示第一段互补码流的长度,引擎端需要依据此长度,将其分割成两段码流,并分包进行发送。
54+
编码器每次输入40ms信号,输出的是一整段包含两段互补码流的码流。如图所示,蓝色框和橙色框分别代表输出码流里的两段独立码流,每段码流都包含帧1和帧2的信息,编码器输出码流的同时,也会通过nBytesOut输出每段互补码流的长度,nBytesOut[0]表示码流总长度,nBytesOut[1]表示的是第一段互补码流的长度,第二段互补码流的长度是通过nBytesOut[0]-nBytesOut[1]计算出来的,引擎端需要依据此长度,将其分割成两段码流,并分包进行发送。
5555

5656
图7. 码流分割及发包:
5757
![solo_sending](https://github.com/AgoraIO-Community/Solo/blob/master/imag/solo_sending.png)

0 commit comments

Comments
 (0)
Please sign in to comment.