Enable iLBC test for android
Review URL: http://webrtc-codereview.appspot.com/68006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@213 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
238a022fc9
commit
e85b34f585
69
src/modules/audio_coding/codecs/iLBC/main/test/Android.mk
Normal file
69
src/modules/audio_coding/codecs/iLBC/main/test/Android.mk
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license
|
||||||
|
# that can be found in the LICENSE file in the root of the source
|
||||||
|
# tree. An additional intellectual property rights grant can be found
|
||||||
|
# in the file PATENTS. All contributing project authors may
|
||||||
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
|
LOCAL_PATH:= $(call my-dir)
|
||||||
|
|
||||||
|
# iLBC test app
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
LOCAL_CPP_EXTENSION := .cc
|
||||||
|
LOCAL_SRC_FILES:= \
|
||||||
|
iLBC_test.c
|
||||||
|
|
||||||
|
# Flags passed to both C and C++ files.
|
||||||
|
LOCAL_CFLAGS := \
|
||||||
|
'-DWEBRTC_TARGET_PC' \
|
||||||
|
'-DWEBRTC_LINUX' \
|
||||||
|
'-DWEBRTC_THREAD_RR'
|
||||||
|
|
||||||
|
LOCAL_CPPFLAGS :=
|
||||||
|
LOCAL_LDFLAGS :=
|
||||||
|
LOCAL_C_INCLUDES := \
|
||||||
|
$(LOCAL_PATH)/../interface \
|
||||||
|
$(LOCAL_PATH)/../../../../../..
|
||||||
|
|
||||||
|
LOCAL_STATIC_LIBRARIES :=
|
||||||
|
|
||||||
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
|
libutils \
|
||||||
|
libwebrtc
|
||||||
|
|
||||||
|
LOCAL_MODULE:= webrtc_iLBC_test
|
||||||
|
|
||||||
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
||||||
|
# iLBC_testLib test app
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
LOCAL_CPP_EXTENSION := .cc
|
||||||
|
LOCAL_SRC_FILES:= \
|
||||||
|
iLBC_testLib.c
|
||||||
|
|
||||||
|
# Flags passed to both C and C++ files.
|
||||||
|
LOCAL_CFLAGS := \
|
||||||
|
'-DWEBRTC_TARGET_PC' \
|
||||||
|
'-DWEBRTC_LINUX' \
|
||||||
|
'-DWEBRTC_THREAD_RR'
|
||||||
|
|
||||||
|
LOCAL_CPPFLAGS :=
|
||||||
|
LOCAL_LDFLAGS :=
|
||||||
|
LOCAL_C_INCLUDES := \
|
||||||
|
$(LOCAL_PATH)/../interface \
|
||||||
|
$(LOCAL_PATH)/../../../../../..
|
||||||
|
|
||||||
|
LOCAL_STATIC_LIBRARIES :=
|
||||||
|
|
||||||
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
|
libutils \
|
||||||
|
libwebrtc
|
||||||
|
|
||||||
|
LOCAL_MODULE:= webrtc_iLBC_testLib
|
||||||
|
|
||||||
|
include $(BUILD_EXECUTABLE)
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
iLBC Speech Coder ANSI-C Source Code
|
iLBC Speech Coder ANSI-C Source Code
|
||||||
|
|
||||||
iLBC_test.c
|
iLBC_test.c
|
||||||
|
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
@ -25,12 +25,12 @@ iLBC_test.c
|
|||||||
|
|
||||||
//#define JUNK_DATA
|
//#define JUNK_DATA
|
||||||
#ifdef JUNK_DATA
|
#ifdef JUNK_DATA
|
||||||
#define SEED_FILE "randseed.txt"
|
#define SEED_FILE "randseed.txt"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------*
|
/*----------------------------------------------------------------*
|
||||||
* Main program to test iLBC encoding and decoding
|
* Main program to test iLBC encoding and decoding
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* exefile_name.exe <infile> <bytefile> <outfile>
|
* exefile_name.exe <infile> <bytefile> <outfile>
|
||||||
@ -39,173 +39,169 @@ iLBC_test.c
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
FILE *ifileid,*efileid,*ofileid, *chfileid;
|
FILE *ifileid,*efileid,*ofileid, *chfileid;
|
||||||
short encoded_data[55], data[240], speechType;
|
short encoded_data[55], data[240], speechType;
|
||||||
short len, mode, pli;
|
short len, mode, pli;
|
||||||
int blockcount = 0;
|
int blockcount = 0;
|
||||||
|
|
||||||
iLBC_encinst_t *Enc_Inst;
|
|
||||||
iLBC_decinst_t *Dec_Inst;
|
|
||||||
|
|
||||||
|
iLBC_encinst_t *Enc_Inst;
|
||||||
|
iLBC_decinst_t *Dec_Inst;
|
||||||
#ifdef JUNK_DATA
|
#ifdef JUNK_DATA
|
||||||
int i;
|
int i;
|
||||||
FILE *seedfile;
|
FILE *seedfile;
|
||||||
unsigned int random_seed = (unsigned int) time(NULL);//1196764538
|
unsigned int random_seed = (unsigned int) time(NULL);//1196764538
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create structs */
|
/* Create structs */
|
||||||
WebRtcIlbcfix_EncoderCreate(&Enc_Inst);
|
WebRtcIlbcfix_EncoderCreate(&Enc_Inst);
|
||||||
WebRtcIlbcfix_DecoderCreate(&Dec_Inst);
|
WebRtcIlbcfix_DecoderCreate(&Dec_Inst);
|
||||||
|
|
||||||
/* get arguments and open files */
|
/* get arguments and open files */
|
||||||
|
|
||||||
if (argc != 6 ) {
|
if (argc != 6 ) {
|
||||||
fprintf(stderr, "%s mode inputfile bytefile outputfile channelfile\n",
|
fprintf(stderr, "%s mode inputfile bytefile outputfile channelfile\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
fprintf(stderr, "Example:\n");
|
fprintf(stderr, "Example:\n");
|
||||||
fprintf(stderr, "%s <30,20> in.pcm byte.dat out.pcm T30.0.dat\n", argv[0]);
|
fprintf(stderr, "%s <30,20> in.pcm byte.dat out.pcm T30.0.dat\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
mode=atoi(argv[1]);
|
mode=atoi(argv[1]);
|
||||||
if (mode != 20 && mode != 30) {
|
if (mode != 20 && mode != 30) {
|
||||||
fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", argv[1]);
|
fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", argv[1]);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if ( (ifileid=fopen(argv[2],"rb")) == NULL) {
|
if ( (ifileid=fopen(argv[2],"rb")) == NULL) {
|
||||||
fprintf(stderr,"Cannot open input file %s\n", argv[2]);
|
fprintf(stderr,"Cannot open input file %s\n", argv[2]);
|
||||||
exit(2);}
|
exit(2);}
|
||||||
if ( (efileid=fopen(argv[3],"wb")) == NULL) {
|
if ( (efileid=fopen(argv[3],"wb")) == NULL) {
|
||||||
fprintf(stderr, "Cannot open channelfile file %s\n",
|
fprintf(stderr, "Cannot open channelfile file %s\n",
|
||||||
argv[3]); exit(3);}
|
argv[3]); exit(3);}
|
||||||
if( (ofileid=fopen(argv[4],"wb")) == NULL) {
|
if( (ofileid=fopen(argv[4],"wb")) == NULL) {
|
||||||
fprintf(stderr, "Cannot open output file %s\n",
|
fprintf(stderr, "Cannot open output file %s\n",
|
||||||
argv[4]); exit(3);}
|
argv[4]); exit(3);}
|
||||||
if ( (chfileid=fopen(argv[5],"rb")) == NULL) {
|
if ( (chfileid=fopen(argv[5],"rb")) == NULL) {
|
||||||
fprintf(stderr,"Cannot open channel file file %s\n", argv[5]);
|
fprintf(stderr,"Cannot open channel file file %s\n", argv[5]);
|
||||||
exit(2);}
|
exit(2);
|
||||||
|
}
|
||||||
/* print info */
|
/* print info */
|
||||||
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
"*---------------------------------------------------*\n");
|
||||||
"*---------------------------------------------------*\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
"* *\n");
|
||||||
"* *\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
"* iLBCtest *\n");
|
||||||
"* iLBCtest *\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
"* *\n");
|
||||||
"* *\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
"* *\n");
|
||||||
"* *\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
|
||||||
"*---------------------------------------------------*\n");
|
"*---------------------------------------------------*\n");
|
||||||
#ifdef SPLIT_10MS
|
#ifdef SPLIT_10MS
|
||||||
fprintf(stderr,"\n10ms split with raw mode: %2d ms\n", mode);
|
fprintf(stderr,"\n10ms split with raw mode: %2d ms\n", mode);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr,"\nMode : %2d ms\n", mode);
|
fprintf(stderr,"\nMode : %2d ms\n", mode);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr,"\nInput file : %s\n", argv[2]);
|
fprintf(stderr,"\nInput file : %s\n", argv[2]);
|
||||||
fprintf(stderr,"Coded file : %s\n", argv[3]);
|
fprintf(stderr,"Coded file : %s\n", argv[3]);
|
||||||
fprintf(stderr,"Output file : %s\n\n", argv[4]);
|
fprintf(stderr,"Output file : %s\n\n", argv[4]);
|
||||||
fprintf(stderr,"Channel file : %s\n\n", argv[5]);
|
fprintf(stderr,"Channel file : %s\n\n", argv[5]);
|
||||||
|
|
||||||
|
|
||||||
#ifdef JUNK_DATA
|
#ifdef JUNK_DATA
|
||||||
srand(random_seed);
|
srand(random_seed);
|
||||||
|
|
||||||
if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
|
if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
|
||||||
fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE);
|
fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(seedfile, "%u\n", random_seed);
|
fprintf(seedfile, "%u\n", random_seed);
|
||||||
fclose(seedfile);
|
fclose(seedfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
|
WebRtcIlbcfix_EncoderInit(Enc_Inst, mode);
|
||||||
|
WebRtcIlbcfix_DecoderInit(Dec_Inst, mode);
|
||||||
|
|
||||||
WebRtcIlbcfix_EncoderInit(Enc_Inst, mode);
|
/* loop over input blocks */
|
||||||
WebRtcIlbcfix_DecoderInit(Dec_Inst, mode);
|
|
||||||
|
|
||||||
/* loop over input blocks */
|
|
||||||
#ifdef SPLIT_10MS
|
#ifdef SPLIT_10MS
|
||||||
while(fread(data, sizeof(short), 80, ifileid) == 80){
|
while(fread(data, sizeof(short), 80, ifileid) == 80) {
|
||||||
#else
|
#else
|
||||||
while( (short)fread(data,sizeof(short),(mode<<3),ifileid)==(mode<<3)){
|
while((short)fread(data,sizeof(short),(mode<<3),ifileid)==(mode<<3)) {
|
||||||
#endif
|
#endif
|
||||||
blockcount++;
|
blockcount++;
|
||||||
|
|
||||||
/* encoding */
|
/* encoding */
|
||||||
|
fprintf(stderr, "--- Encoding block %i --- ",blockcount);
|
||||||
fprintf(stderr, "--- Encoding block %i --- ",blockcount);
|
|
||||||
#ifdef SPLIT_10MS
|
#ifdef SPLIT_10MS
|
||||||
len=WebRtcIlbcfix_Encode(Enc_Inst, data, 80, encoded_data);
|
len=WebRtcIlbcfix_Encode(Enc_Inst, data, 80, encoded_data);
|
||||||
#else
|
#else
|
||||||
len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data);
|
len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "\r");
|
fprintf(stderr, "\r");
|
||||||
|
|
||||||
#ifdef JUNK_DATA
|
#ifdef JUNK_DATA
|
||||||
for ( i = 0; i < len; i++) {
|
for ( i = 0; i < len; i++) {
|
||||||
encoded_data[i] = (short) (encoded_data[i] + (short) rand());
|
encoded_data[i] = (short) (encoded_data[i] + (short) rand());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* write byte file */
|
/* write byte file */
|
||||||
if(len != 0){ //len may be 0 in 10ms split case
|
if(len != 0){ //len may be 0 in 10ms split case
|
||||||
fwrite(encoded_data,1,len,efileid);
|
fwrite(encoded_data,1,len,efileid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len != 0){ //len may be 0 in 10ms split case
|
if(len != 0){ //len may be 0 in 10ms split case
|
||||||
/* get channel data if provided */
|
/* get channel data if provided */
|
||||||
if (argc==6) {
|
if (argc==6) {
|
||||||
if (fread(&pli, sizeof(WebRtc_Word16), 1, chfileid)) {
|
if (fread(&pli, sizeof(WebRtc_Word16), 1, chfileid)) {
|
||||||
if ((pli!=0)&&(pli!=1)) {
|
if ((pli!=0)&&(pli!=1)) {
|
||||||
fprintf(stderr, "Error in channel file\n");
|
fprintf(stderr, "Error in channel file\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if (pli==0) {
|
if (pli==0) {
|
||||||
/* Packet loss -> remove info from frame */
|
/* Packet loss -> remove info from frame */
|
||||||
memset(encoded_data, 0, sizeof(WebRtc_Word16)*25);
|
memset(encoded_data, 0, sizeof(WebRtc_Word16)*25);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Error. Channel file too short\n");
|
fprintf(stderr, "Error. Channel file too short\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pli=1;
|
pli=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decoding */
|
/* decoding */
|
||||||
|
fprintf(stderr, "--- Decoding block %i --- ",blockcount);
|
||||||
|
if (pli==1) {
|
||||||
|
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data, &speechType);
|
||||||
|
} else {
|
||||||
|
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\r");
|
||||||
|
|
||||||
fprintf(stderr, "--- Decoding block %i --- ",blockcount);
|
/* write output file */
|
||||||
if (pli==1) {
|
fwrite(data,sizeof(short),len,ofileid);
|
||||||
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data, &speechType);
|
}
|
||||||
} else {
|
}
|
||||||
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1);
|
|
||||||
}
|
|
||||||
fprintf(stderr, "\r");
|
|
||||||
|
|
||||||
/* write output file */
|
|
||||||
|
|
||||||
fwrite(data,sizeof(short),len,ofileid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef JUNK_DATA
|
#ifdef JUNK_DATA
|
||||||
if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
|
if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
|
||||||
fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE);
|
fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(seedfile, "ok\n\n");
|
fprintf(seedfile, "ok\n\n");
|
||||||
fclose(seedfile);
|
fclose(seedfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* free structs */
|
/* free structs */
|
||||||
WebRtcIlbcfix_EncoderFree(Enc_Inst);
|
WebRtcIlbcfix_EncoderFree(Enc_Inst);
|
||||||
WebRtcIlbcfix_DecoderFree(Dec_Inst);
|
WebRtcIlbcfix_DecoderFree(Dec_Inst);
|
||||||
|
|
||||||
/* close files */
|
/* close files */
|
||||||
|
fclose(ifileid);
|
||||||
|
fclose(efileid);
|
||||||
|
fclose(ofileid);
|
||||||
|
|
||||||
fclose(ifileid); fclose(efileid); fclose(ofileid);
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user