[sip-comm-dev] Re: svn commit: r5415 - branches/gsoc09/sli/src/net/java/sip/communicator/impl/media


#1

Hey all,

The mail sent to the commits list was meant to Dilshan actually, but I
still would like your input on the following point:

> + public int process(Buffer inputBuffer, Buffer outputBuffer)

> + int sample = tempH | (tempL & 255);

I'm pretty sure this should be tempH << 8 | (tempL & 255). I'll confirm
later.

This how a RTP sample (linear, 16-bit samples, signed, little endian) is
extracted from an array of bytes, according to the JMF documentation
[0]:

int tempL = inData[inOffset ++];
int tempH = inData[inOffset ++];
int sample = tempH | (tempL & 255)

I would rather do:
int sample = tempH << 8 | (tempL & 255)

but I may have overlooked something. Can someone find where? Let me
detail my reasoning:

Let's work with a sample of value: -280:

On 16 bits, this would give:
(-) 0000 0001 0001 1000
and with 2's complement for the sign:
1111 1110 1110 1000
and with little-endian, I expect the value of the two consecutives RTP
bytes in the array to be:
1110 1000 1111 1110
Now let's convert it to Java's big endian int:
int tempL = inData[inOffset ++];
int tempH = inData[inOffset ++];
which gives us tempL:
1111 1111 1111 1111 1111 1111 1110 1000
and tempH:
1111 1111 1111 1111 1111 1111 1111 1110
tempH << 8:
1111 1111 1111 1111 1111 1110 0000 0000
tempL & 255:
0000 0000 0000 0000 0000 0000 1110 1000
(tempH << 8) | (tempL & 255):
1111 1111 1111 1111 1111 1110 1110 1000
which in a Java's big-endian int, makes -280

Now where is the error? :wink:

[0] http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/guide/JMFExtending.html

Cheers,

···

On Wed, Jun 24, 2009 at 01:25:52AM +0200, Sébastien Mazy wrote:

On Mon, Jun 22, 2009 at 04:57:07PM -0000, Dilmash@dev.java.net wrote:

--
Sébastien Mazy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net