DSPRelated.com
Forums

Combining G711 streams

Started by kevinmr August 7, 2003
oen_br@yahoo.com.br (Luiz Carlos) wrote in message news:<8471ba54.0308130240.6187066a@posting.google.com>...
> Jerry Avins <jya@ieee.org> wrote in message news: > > > > Addition? How? > > > > Jerry > > If you linearize the G711 you get 13 bit samples and then you need a > 13 bit adder. If you add the mantissas, shifting them by the exponents > and discarding the bits that fall out the representation, you need a 6 > bit adder. Of course this a better aproach if you are doing it in > hardware (FPGA stuff), but I think that you can save some clock cycles > of the DSP/MPU if you do not do a complete expansion of the samples to > add them. > > Luiz Carlos.
Hi, If I correctly remmember G711 uses Logarithmic functions be it a-law or u-law. Simply adding two encoded streams would result in multiplication in terms of linear domain. Vimal
Vimal wrote:
> > oen_br@yahoo.com.br (Luiz Carlos) wrote in message news:<8471ba54.0308130240.6187066a@posting.google.com>... > > Jerry Avins <jya@ieee.org> wrote in message news: > > > > > > Addition? How? > > > > > > Jerry > > > > If you linearize the G711 you get 13 bit samples and then you need a > > 13 bit adder. If you add the mantissas, shifting them by the exponents > > and discarding the bits that fall out the representation, you need a 6 > > bit adder. Of course this a better aproach if you are doing it in > > hardware (FPGA stuff), but I think that you can save some clock cycles > > of the DSP/MPU if you do not do a complete expansion of the samples to > > add them. > > > > Luiz Carlos. > > Hi, > > If I correctly remmember G711 uses Logarithmic functions be it a-law > or u-law. > Simply adding two encoded streams would result in multiplication in > terms of linear domain. > > Vimal
Vimal, You didn't read the explanation carefully. Shifting the smaller signal to make its exponent match the larger, then adding the mantissas discards only those bits that would be lost by decoding the signals, adding, and re-encoding. You and I were thinking about G711 as logarithmic encoding. Luiz pointed out that we can profitably treat it as floating point. Luiz, Thank you. I not only learned a new trick for my bag, I saw yet again how valuable another vantage point can be. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
vimal_bhatia2@yahoo.com (Vimal) wrote in message news:
> > Hi, > > If I correctly remmember G711 uses Logarithmic functions be it a-law > or u-law. > Simply adding two encoded streams would result in multiplication in > terms of linear domain. > > Vimal
You are right, but it is a base 2 log! If you simply add two samples you get trash, not a multiplication. To multiply 2 samples you have to add the exponents and multiply the mantissas. Luiz Carlos.
Hello Jerry,

Another way to think of it is mu-law and A-law use logarithmic transfer
functions sort of. Basically they break the domain into 8 segments (for the
positive nums and another similar set for the negs). The segment endpoints
are chosen based on the mu/A law transfer function, but then each segment is
decomposed into 16 linear steps. So that is how these encodings appear like
a type of floating point representation.

Clay

p.s. These encodings (logarithmic) are chosen to produce near constant
signal to noise ratios for signals and varying strengths.



"Jerry Avins" <jya@ieee.org> wrote in message
news:3F3A6DCD.47D25F5F@ieee.org...
> Vimal wrote: > > > > oen_br@yahoo.com.br (Luiz Carlos) wrote in message
news:<8471ba54.0308130240.6187066a@posting.google.com>...
> > > Jerry Avins <jya@ieee.org> wrote in message news: > > > > > > > > Addition? How? > > > > > > > > Jerry > > > > > > If you linearize the G711 you get 13 bit samples and then you need a > > > 13 bit adder. If you add the mantissas, shifting them by the exponents > > > and discarding the bits that fall out the representation, you need a 6 > > > bit adder. Of course this a better aproach if you are doing it in > > > hardware (FPGA stuff), but I think that you can save some clock cycles > > > of the DSP/MPU if you do not do a complete expansion of the samples to > > > add them. > > > > > > Luiz Carlos. > > > > Hi, > > > > If I correctly remmember G711 uses Logarithmic functions be it a-law > > or u-law. > > Simply adding two encoded streams would result in multiplication in > > terms of linear domain. > > > > Vimal > > Vimal, > > You didn't read the explanation carefully. Shifting the smaller signal > to make its exponent match the larger, then adding the mantissas > discards only those bits that would be lost by decoding the signals, > adding, and re-encoding. You and I were thinking about G711 as > logarithmic encoding. Luiz pointed out that we can profitably treat it > as floating point. > > Luiz, > > Thank you. I not only learned a new trick for my bag, I saw yet again > how valuable another vantage point can be. > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins <jya@ieee.org> wrote in message news:<3F3A6DCD.47D25F5F@ieee.org>...
> Vimal wrote: > > > > oen_br@yahoo.com.br (Luiz Carlos) wrote in message news:<8471ba54.0308130240.6187066a@posting.google.com>... > > > Jerry Avins <jya@ieee.org> wrote in message news: > > > > > > > > Addition? How? > > > > > > > > Jerry > > > > > > If you linearize the G711 you get 13 bit samples and then you need a > > > 13 bit adder. If you add the mantissas, shifting them by the exponents > > > and discarding the bits that fall out the representation, you need a 6 > > > bit adder. Of course this a better aproach if you are doing it in > > > hardware (FPGA stuff), but I think that you can save some clock cycles > > > of the DSP/MPU if you do not do a complete expansion of the samples to > > > add them. > > > > > > Luiz Carlos. > > Vimal, > > You didn't read the explanation carefully. Shifting the smaller signal > to make its exponent match the larger, then adding the mantissas > discards only those bits that would be lost by decoding the signals, > adding, and re-encoding. You and I were thinking about G711 as > logarithmic encoding. Luiz pointed out that we can profitably treat it > as floating point. > > Luiz, > > Thank you. I not only learned a new trick for my bag, I saw yet again > how valuable another vantage point can be. > > Jerry
Sorry Luiz, Thanks Jerry for explanation. Can I consider this as an example suppose we have two linear fixed point samples ie 2000 (large) and 20 (small) log10(2000) = 3.3010 // supposing they are logarithmically encoded log10(20) = 1.3010 log10(2000) + log10(20)/100 = 3.3010 + 0.013010 = approx. log(2000+20) Cheers. Vimal
> You are right, but it is a base 2 log! If you simply add two samples > you get trash, not a multiplication. To multiply 2 samples you have to > add the exponents and multiply the mantissas. > > Luiz Carlos.
Sorry Luiz, Thanks Jerry for explanation. Can I consider this as an example suppose we have two linear fixed point samples ie 2000 (large) and 20 (small) log10(2000) = 3.3010 // supposing they are logarithmically encoded log10(20) = 1.3010 log10(2000) + log10(20)/100 = 3.3010 + 0.013010 = approx. log(2000+20) Cheers. Vimal
vimal_bhatia2@yahoo.com (Vimal) wrote in message news:
> Sorry Luiz, Thanks Jerry for explanation. Can I consider this as an example > suppose we have two linear fixed point samples ie 2000 (large) and 20 (small) > > log10(2000) = 3.3010 // supposing they are logarithmically encoded > log10(20) = 1.3010 > > log10(2000) + log10(20)/100 = 3.3010 + 0.013010 = approx. log(2000+20) > > Cheers. > Vimal
No Vimal, In your example: 2000 = 2*10^3 The log "compression" is used to create the number +3:2. + -> positive number (signal of the mantissa) 3 -> 10^3 (exponent) 2 -> 2, the magnitude of the mantissa. It is the scientific format of your calculator! 20 = 2*10^1 => +1:2 To add them we must have the same exponent: +3:2 = +1:200 So, 2000+20 = [+3:2]+[+1:2] = [+1:200]+[+1:2] = [+1:202] Of course it is 202*10^1 = 2020. u/A-LAW uses 8 bit data. One bit for the signal, three bits for the exponent (always positive, only integer numbers) and four bits for the mantissa magnitude (signal/magnitude, not two's complement!). The mantissa has two hidden bits. The leftmost bit is always one, so its not showed (unless in the denormal form, exponent = 0). The rightmost bit is also always one, for rounding porpouse (+0.5), and it is not showed too. So if you have 0xB4 A-LAW (after the XOR 0x55): 0xB4=0b 1 011 0100 Signal = 1, positive number exponent = 0b011 = 3, *2^3 mantissa = 0b0100, adding the hidden bits, 0b 1 0100 1 So: 0xB4 A-LAW = +0b101001 000 = 0b0 0001 0100 1000 linear (13 bits, two's complement) I used the A-LAW because I&#4294967295;m used to work in this format, I'm in Brazil. Luiz Carlos
Luiz Carlos wrote:
> > vimal_bhatia2@yahoo.com (Vimal) wrote in message news: > > Sorry Luiz, Thanks Jerry for explanation. Can I consider this as an example > > suppose we have two linear fixed point samples ie 2000 (large) and 20 (small) > > > > log10(2000) = 3.3010 // supposing they are logarithmically encoded > > log10(20) = 1.3010 > > > > log10(2000) + log10(20)/100 = 3.3010 + 0.013010 = approx. log(2000+20) > > > > Cheers. > > Vimal > > No Vimal, > > In your example: > 2000 = 2*10^3 > The log "compression" is used to create the number +3:2. > + -> positive number (signal of the mantissa) > 3 -> 10^3 (exponent) > 2 -> 2, the magnitude of the mantissa. > It is the scientific format of your calculator! > > 20 = 2*10^1 => +1:2 > > To add them we must have the same exponent: > +3:2 = +1:200 > > So, 2000+20 = [+3:2]+[+1:2] = [+1:200]+[+1:2] = [+1:202] > Of course it is 202*10^1 = 2020. > > u/A-LAW uses 8 bit data. One bit for the signal, three bits for the > exponent (always positive, only integer numbers) and four bits for the > mantissa magnitude (signal/magnitude, not two's complement!). The > mantissa has two hidden bits. The leftmost bit is always one, so its > not showed (unless in the denormal form, exponent = 0). The rightmost > bit is also always one, for rounding porpouse (+0.5), and it is not > showed too. > > So if you have 0xB4 A-LAW (after the XOR 0x55): > 0xB4=0b 1 011 0100 > Signal = 1, positive number > exponent = 0b011 = 3, *2^3 > mantissa = 0b0100, adding the hidden bits, 0b 1 0100 1 > > So: 0xB4 A-LAW = +0b101001 000 = 0b0 0001 0100 1000 linear (13 bits, > two's complement) > > I used the A-LAW because I&#4294967295;m used to work in this format, I'm in > Brazil. > > Luiz Carlos
Luiz, Your writing "signal" where I would have used "sign" puzzled me, but only for a second. I'm glad you brought out the XOR to flip alternate bits. This thread showed how easy it is to overlook it when discussing the format, even for those of us who know. I had actually forgotten the implied most-significant 1 bit, but the least-significant bit puzzles me. Isn't that just a programmer's arithmetic choice, or a common processing convention? It's hard for me to see it as part of the defined meaning of the original code. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Vimal wrote:
> > > You are right, but it is a base 2 log! If you simply add two samples > > you get trash, not a multiplication. To multiply 2 samples you have to > > add the exponents and multiply the mantissas. > > > > Luiz Carlos. > > Sorry Luiz, Thanks Jerry for explanation. Can I consider this as an example > suppose we have two linear fixed point samples ie 2000 (large) and 20 (small) > > log10(2000) = 3.3010 // supposing they are logarithmically encoded > log10(20) = 1.3010 > > log10(2000) + log10(20)/100 = 3.3010 + 0.013010 = approx. log(2000+20) > > Cheers. > Vimal
See Luiz's latest message, posted two minutes after yours. BTW: with mu-law, there are no bit flips (XOR $55). IIRC, The implied bits are the same. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message
news:3F40DC66.475A0626@ieee.org...
> > See Luiz's latest message, posted two minutes after yours. BTW: with > mu-law, there are no bit flips (XOR $55). IIRC, The implied bits are the > same.
Jerry, mu-law inverts all bits instead of just the even positioned ones as in A-law. Clay
> > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;