From: Steve K. <st...@st...> - 2004-04-10 00:37:04
|
On Apr 9, 2004, at 7:55 PM, Steven Sokol wrote: > Ok. I bit the bullet and went out to the iLBC web site to download the > code. Odd thing is, the code there is embedded in the RFC for the > codec. > SO... After jacking around with an Awk script for a whie, I was able > to pull > out the code. While I'm sure that was fun, it's just as easy to take the code from the iLBC directory in iaxclient. > I got it to compile under Windows (gcc) without any issues. I now > have a > nice libilbc.a file sitting here. The real question is, how do I go > about > making it a part of the library? Or do I? My inclination is to try to > "externalize" the codecs - move both iLBC and GSM outside of the > library (as > DLLs in Windows -- presumably SOs in Linux). The most important thing is to modularize the interface to the codecs. Whether or not the codecs are included in the library is less important (although, for iLBC, there's licensing issues to consider, because it's not GPL-compatible). Anyway, I'd start out with something simpler than iLBC, although it won't make much difference. That way you don't need to mess with Makefiles and stuff too much. First, you need to make an interface to the codecs. This will look something like the interface to audio drivers, or asterisk's interface to codecs (translators). I think that an IAX conversation currently needs to use the same codec in both directions, so you can make something like struct iaxc_codec. The definition of struct iaxc_codec goes in iaxclient_lib.h The structure will contain pointers to codec functions, as well as a pointer to a codec-specific data structure (or pair of structures). For each codec, you'll make a codec_xxx.c file [a codec_xxx.h file too, perhaps, but I'm not sure it's necessary]. This file will have an "init" function that will initialize the encode and decode states, stash those in it's private storage area, and return a struct iaxc_codec function. I'd actually start by making codec_gsm.c and codec_ulaw.c the ulaw function is pretty simple, there's several examples of it out there. Once that work is done, adding more codecs like speex will be easy. iLBC adds one additional complication, in that it it uses a 30ms frame size instead of 20ms like gsm, ulaw and speex. It isn't really a big deal, since our input and output is buffered anyway. I'd work on the basics first before you work on any specific (and very platform-dependent) details about shared libraries. There's two drawbacks to shared libraries: 1) they are very platform-dependent, different on Windows, Mac and Linux, 2) If your architecture requires them, it makes it impossible to distribute a single-file binary. I've also done some benchmarking on the different codecs. The "common wisdom" here was that iLBC was as fast as GSM, and speex was much slower, and that speex and iLBC sounded similar, and both were better than GSM. I actually found that iLBC and speex encode speeds were about the same, and GSM was still much faster for encode. For decode, speex beats everyone. Here's some results, on my Athlon 1.4Ghz (XP1800+). The tests also include some work I did to find ideal gcc optimizations (gcc-3.3): iLBC -O2: Encode/Decode = 38.3X/112.2X iLBC -O3 -ffast-math -funroll-all-loops -march=pentium3 -fprefetch-loop-arrays -fsingle-precision-constant: Encode/Decode = 48.8X/183.8X GSM -O2: Encode/Decode = 146x/280x For speex, some things depend on the bandwidth choices you use. If we use speex in iaxclient, we might want some codec-specific way to choose these (for people who want/need lower bandwidth. The default is about 15kbps). With sse enabled (for speex, which includes this now) and the flags -O3 -msse -ffast-math -funroll-all-loops -march=pentium3 -fprefetch-loop-arrays -fsingle-precision-constant): 8kbps complexity 1: Encode/Decode = 69x / 460x realtime. Default complexity and bandwidth: Encode/Decode = 28x/409x So, speex really isn't that slow, and it gets faster the lower bandwidth you use (although it gets pretty bad below about 6.5 kbps). Also, speex decodes _much_ faster than anything else.. [none of this matters too much for single-user clients. Using 1/28 of your CPU isn't a big deal. I did this benchmarking to determine load on the other side]. > Before I go hacking away, does anybody have any thoughts about this? > > Thanks, > > Steve > > Steven Sokol > Owner/Manager > Sokol & Associates, LLC > > Phone: 816.822.1807 > IaxTel: 700.613.9004 > Web: http://www.sokol-associates.com > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Iaxclient-devel mailing list > Iax...@li... > https://lists.sourceforge.net/lists/listinfo/iaxclient-devel > |