Greetings, I've just started porting speex to a TI C5509 DSP. It doesn't look like it's going to be too painful, but there are a couple of quirks about the C5x. 1) chars are 16 bits because memory addresses are for 16bit words 2) ints and short are also 16 bits (so sizeof(char) = sizeof(short) = sizeof(int) = 1) 3) the c5x is essentially big endian My plan is to change int and unsigned int to int32_t and uint32_t where 32 bit ints are needed, such as in the stream header. I'm attaching a patch that updates bits.c to work with 16bit chars, renaming "byte" to "char" and using macros BYTES_PER_CHAR, BITS_PER_CHAR, and LOG2_BITS_PER_CHAR to keep the code portable between 8-bit chars and 16-bit chars. Other than compiling, I have not tested this code but I wanted a style check before going too far down this path. I hope that these changes or suitable reworking of them will be acceptable into the Speex code. Jamey Hicks HP Labs -------------- next part -------------- A non-text attachment was scrubbed... Name: speex-1.1.6-bits.patch Type: text/x-patch Size: 14132 bytes Desc: not available Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20040916/aa6c4c08/speex-1.1.6-bits.bin
Hi Jamey, Really cool to see Speex being ported to the C55xx and I'd be glad to integrate the changes required in Speex (and the style's fine with me). Here are a couple comments on the patch you sent (I looked at it, but haven't compiled). 1) The changes you made to the pack un unpack functions would only work if the 16-bit chars are "big endian" (relative to the two bytes in the 16-bit chars) 2) I would prefer spx_int16_t to int16_t. Eventually, part of that should go in the configure script and the config.h 3) Not relative to this patch, but I think an important issue will be what to do about the codebooks. All codebooks are stored as "signed char", you'd be wasting lots of space on the C55xx unless you find a way of packing everything. Regarding 32 bit ints, I don't think they will be required much (except for the header). I don't think there is any loop in the code that goes past 2^15. Jean-Marc On jeu, 2004-09-16 at 16:53 -0400, Jamey Hicks wrote:> Greetings, > > I've just started porting speex to a TI C5509 DSP. It doesn't look like > it's going to be too painful, but there are a couple of quirks about the > C5x. > > 1) chars are 16 bits because memory addresses are for 16bit words > 2) ints and short are also 16 bits (so sizeof(char) = sizeof(short) = > sizeof(int) = 1) > 3) the c5x is essentially big endian > > My plan is to change int and unsigned int to int32_t and uint32_t where > 32 bit ints are needed, such as in the stream header. > > I'm attaching a patch that updates bits.c to work with 16bit chars, > renaming "byte" to "char" and using macros BYTES_PER_CHAR, > BITS_PER_CHAR, and LOG2_BITS_PER_CHAR to keep the code portable between > 8-bit chars and 16-bit chars. Other than compiling, I have not tested > this code but I wanted a style check before going too far down this path. > > I hope that these changes or suitable reworking of them will be > acceptable into the Speex code. > > Jamey Hicks > HP Labs > > _______________________________________________ > Speex-dev mailing list > Speex-dev@xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev
Jean-Marc Valin wrote:>Hi Jamey, > >Really cool to see Speex being ported to the C55xx and I'd be glad to >integrate the changes required in Speex (and the style's fine with me). >Here are a couple comments on the patch you sent (I looked at it, but >haven't compiled). > > >Cool.>1) The changes you made to the pack un unpack functions would only work >if the 16-bit chars are "big endian" (relative to the two bytes in the >16-bit chars) >2) I would prefer spx_int16_t to int16_t. Eventually, part of that >should go in the configure script and the config.h > >Sounds good to me.>3) Not relative to this patch, but I think an important issue will be >what to do about the codebooks. All codebooks are stored as "signed >char", you'd be wasting lots of space on the C55xx unless you find a way >of packing everything. > > >Yes, I noticed that. I think I'll leave that alone until I get the rest working, then try to pack the codebooks.>Regarding 32 bit ints, I don't think they will be required much (except >for the header). I don't think there is any loop in the code that goes >past 2^15. > > >The thing that got me worried about this was the le_int() and be_int() routines that operate on 32-bit quantities now. Thanks for the feedback. I'll keep you posted on progress. Jamey
Jean-Marc Valin wrote:>Hi Jamey, > >Really cool to see Speex being ported to the C55xx and I'd be glad to >integrate the changes required in Speex (and the style's fine with me). > >I have the encoder and decoder running now and have verified that the encoder is bit-exact wrt to the fixed-point code running on x86 for the same 30-second audio sample. Encode and decode together run in real-time for 8KHz data, complexity=3, on 120MHz C5509 when code and data are all in on-chip SRAM. I have not tested the wideband codec yet.>Here are a couple comments on the patch you sent (I looked at it, but >haven't compiled). > >1) The changes you made to the pack un unpack functions would only work >if the 16-bit chars are "big endian" (relative to the two bytes in the >16-bit chars) > >I fixed the problem where extracting bytes from SpeexBits was wrong endian.>2) I would prefer spx_int16_t to int16_t. Eventually, part of that >should go in the configure script and the config.h > >I changed int32_t to spx_int32_t.>3) Not relative to this patch, but I think an important issue will be >what to do about the codebooks. All codebooks are stored as "signed >char", you'd be wasting lots of space on the C55xx unless you find a way >of packing everything. >I have not addressed this problem yet. In my testing all the Speex code and data in the on-chip sram of TI C5509 DSP, and it all fit. Is compute_weighted_codebook the only routine that looks at the raw codebooks? If so, I'll take a look at packing the codebooks to save a few KB. Here is a description of the changes. 1) update arch.h to provide definitions of spx_int32_t, spx_sig_t, etc, for 16-bit processor. 2) update fixed_generic.h with typecasts to compensate for difference between GCC and TI's C compiler. I believe that the result is portable so I have not wrapped this in ifdefs. TI's compiler, unlike GCC on 32bit machines, produces 16bit results for shift, add, and multiply if the operands are 16-bit, even if result will be expanded to 32-bit. There were also some occurrances of this problem in a few of the files, and tracking those down was quite tedious. 3) update SpeexBits implementation to work with 8 or 16bit characters. Patch is attached. Jamey -------------- next part -------------- A non-text attachment was scrubbed... Name: speex-1.1.6-jeh1.patch Type: text/x-patch Size: 37358 bytes Desc: not available Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20041029/facb8c73/speex-1.1.6-jeh1-0001.bin