To remove all calls involving scratch-memory

Review URL: http://webrtc-codereview.appspot.com/129001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@462 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
turajs@google.com 2011-08-26 16:03:49 +00:00
parent ac55f7b33c
commit 7f2bbbbefd
2 changed files with 376 additions and 395 deletions

View File

@ -38,12 +38,6 @@
#define BLOCKL_MAX 240 #define BLOCKL_MAX 240
#define ILBCNOOFWORDS_MAX 25 #define ILBCNOOFWORDS_MAX 25
#define ILBCSCRATCHMEMSIZE 2156
#ifdef __ILBC_WITH_SCRATCHMEM
WebRtc_Word16 iLBC_ScratchMem[ILBCSCRATCHMEMSIZE];
WebRtc_Word16 size;
#endif
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -152,13 +146,6 @@ int main(int argc, char* argv[])
WebRtcIlbcfix_EncoderCreate(&Enc_Inst); WebRtcIlbcfix_EncoderCreate(&Enc_Inst);
WebRtcIlbcfix_DecoderCreate(&Dec_Inst); WebRtcIlbcfix_DecoderCreate(&Dec_Inst);
#ifdef __ILBC_WITH_SCRATCHMEM
/* Assign scratch memory. Note that Enc and Dec can use the same area */
WebRtcIlbcfix_EncoderAssignScratchMem(Enc_Inst, iLBC_ScratchMem, &size);
if (size>ILBCSCRATCHMEMSIZE) { fprintf(stderr,"Error: Scratch not big enough"); exit(0); }
WebRtcIlbcfix_DecoderAssignScratchMem(Dec_Inst, iLBC_ScratchMem, &size);
if (size>ILBCSCRATCHMEMSIZE) { fprintf(stderr,"Error: Scratch not big enough"); exit(0); }
#endif
/* Initialization */ /* Initialization */
@ -236,4 +223,3 @@ int main(int argc, char* argv[])
return(0); return(0);
} }

View File

@ -43,7 +43,7 @@ short encode( /* (o) Number of bytes encoded */
iLBC_Enc_Inst_t *iLBCenc_inst, /* (i/o) Encoder instance */ iLBC_Enc_Inst_t *iLBCenc_inst, /* (i/o) Encoder instance */
WebRtc_Word16 *encoded_data, /* (o) The encoded bytes */ WebRtc_Word16 *encoded_data, /* (o) The encoded bytes */
WebRtc_Word16 *data /* (i) The signal block to encode */ WebRtc_Word16 *data /* (i) The signal block to encode */
){ ){
/* do the actual encoding */ /* do the actual encoding */
WebRtcIlbcfix_Encode((WebRtc_UWord16 *)encoded_data, data, iLBCenc_inst); WebRtcIlbcfix_Encode((WebRtc_UWord16 *)encoded_data, data, iLBCenc_inst);
@ -60,7 +60,7 @@ short decode( /* (o) Number of decoded samples */
short *decoded_data, /* (o) Decoded signal block */ short *decoded_data, /* (o) Decoded signal block */
short *encoded_data, /* (i) Encoded bytes */ short *encoded_data, /* (i) Encoded bytes */
short mode /* (i) 0=PL, 1=Normal */ short mode /* (i) 0=PL, 1=Normal */
){ ){
/* check if mode is valid */ /* check if mode is valid */
@ -195,12 +195,6 @@ int main(int argc, char* argv[])
WebRtcIlbcfix_EncoderInit(&Enc_Inst, mode); WebRtcIlbcfix_EncoderInit(&Enc_Inst, mode);
WebRtcIlbcfix_DecoderInit(&Dec_Inst, mode, 1); WebRtcIlbcfix_DecoderInit(&Dec_Inst, mode, 1);
#if __ILBC_WITH_SCRATCHMEM
// we can use the same scratch space for both encoder and decoder.
WebRtcIlbcfix_EncoderAssignScratchMem((iLBC_encinst_t*)&Enc_Inst, scratchBlock, &size);
WebRtcIlbcfix_DecoderAssignScratchMem((iLBC_decinst_t*)&Dec_Inst, scratchBlock, &size);
#endif
/* extract the input file and channel file */ /* extract the input file and channel file */
#ifdef SPLIT_10MS #ifdef SPLIT_10MS
@ -225,8 +219,8 @@ int main(int argc, char* argv[])
#endif #endif
while ( (fread(&channeldata[blockcount],sizeof(short), 1,chfileid)==1) while ((fread(&channeldata[blockcount],sizeof(short), 1,chfileid)==1)
&& ( blockcount < noOfBlocks/(Enc_Inst.blockl/frameLen) ) ) { && ( blockcount < noOfBlocks/(Enc_Inst.blockl/frameLen) )) {
blockcount++; blockcount++;
} }
@ -246,28 +240,29 @@ int main(int argc, char* argv[])
starttime1 = clock()/(float)CLOCKS_PER_SEC; starttime1 = clock()/(float)CLOCKS_PER_SEC;
/* Encoding loop */ /* Encoding loop */
#ifdef PRINT_MIPS #ifdef PRINT_MIPS
printf("-1 -1\n"); printf("-1 -1\n");
#endif #endif
#ifdef SPLIT_10MS #ifdef SPLIT_10MS
/* "Enc_Inst.section != 0" is to make sure we run through full /* "Enc_Inst.section != 0" is to make sure we run through full
lengths of all vectors for 10ms split mode. lengths of all vectors for 10ms split mode.
*/ */
// while( (count < noOfBlocks) || (Enc_Inst.section != 0) ) { // while( (count < noOfBlocks) || (Enc_Inst.section != 0) ) {
while( count < blockcount * (Enc_Inst.blockl/frameLen) ) { while( count < blockcount * (Enc_Inst.blockl/frameLen) ) {
encode(&Enc_Inst, &encodeddata[Enc_Inst.no_of_words * encode(&Enc_Inst, &encodeddata[Enc_Inst.no_of_words *
(count/(Enc_Inst.nsub/2))], &inputdata[frameLen * count] ); (count/(Enc_Inst.nsub/2))],
&inputdata[frameLen * count] );
#else #else
while (count < noOfBlocks) { while (count < noOfBlocks) {
encode( &Enc_Inst, &encodeddata[Enc_Inst.no_of_words * count], encode( &Enc_Inst, &encodeddata[Enc_Inst.no_of_words * count],
&inputdata[frameLen * count] ); &inputdata[frameLen * count] );
#endif #endif
#ifdef PRINT_MIPS #ifdef PRINT_MIPS
printf("-1 -1\n"); printf("-1 -1\n");
#endif #endif
count++; count++;
} }
@ -297,9 +292,9 @@ int main(int argc, char* argv[])
printf("Error in channel file (values have to be either 1 or 0)\n"); printf("Error in channel file (values have to be either 1 or 0)\n");
exit(0); exit(0);
} }
#ifdef PRINT_MIPS #ifdef PRINT_MIPS
printf("-1 -1\n"); printf("-1 -1\n");
#endif #endif
count++; count++;
} }
@ -345,4 +340,4 @@ int main(int argc, char* argv[])
free(channeldata); free(channeldata);
fclose(ifileid); fclose(efileid); fclose(ofileid); fclose(ifileid); fclose(efileid); fclose(ofileid);
return(0); return(0);
} }