SBC encoder conformance test for version 4.25 passed!
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello Siarhei,
sorry for the delay - these days my family comes first ;-)
Good news! All tests passed!
http://net.cs.uni-tuebingen.de/html/nexgenvoip/
Congratulations and a happy new year!
Christian
Quoted 12 lines
-----Original Message-----
From: Siarhei Siamashka [mailto:[email protected]]
Sent: Tuesday, December 30, 2008 11:46 AM
To: ext Christian Hoene
Subject: SBC encoder conformance test for version 4.25Hello Christian,
Could you please rebuild SBC encoder test results on
http://net.cs.uni-tuebingen.de/html/nexgenvoip/html/
for the just released version 4.25?
Quoted 6 lines
I'm going to submit SIMD optimizations for the analysis filter which are almost done now (using ARM NEON, but Intel MMX/SSE2 requires only a minor modification). In any case I would prefer to make sure that the current C code is in a good shape first.
Thanks a lot for your participation. I hope that with our combined
efforts,
Quoted 5 lines
we can make SBC really much better and faster.
--
Best regards,
Siarhei Siamashka
Quoted 6 lines · On Thursday 01 January 2009 16:24:21 ext Christian Hoene wrote:
Hello Siarhei,
sorry for the delay - these days my family comes first ;-)
Good news! All tests passed!
http://net.cs.uni-tuebingen.de/html/nexgenvoip/
Thank you very much. Sorry for the delay with reply too.
I wonder if we need to do something about test 08?
Also could you try running a special test of version 4.25 with SBC_HIGH_PRECISION enabled? The point is that it uses the best possible precision for the analysis filter and minimizes effects of rounding errors (I would estimate that the precision should be even better than single precision floating point). Having the test run with this precision settings can expose some of the other minor bugs in the code (if they exist), which can now be hidden under the slight precision loss because of using 16-bit fixed point calculations.
Best regards,
Siarhei Siamashka
PATCH 1/1 SBC Encoder program
Quoted 2 lines
I wonder if we need to do something about test 08?
Yes, there was a bug in the encoder program. Attached the patch.
Greetings
Christian
Quoted 1 line
From
e302dcac067486b83d1ba824227fd14878321cb2Mon Sep 17 00:00:00 2001
From: Christian Hoene <[email protected]>
Date: Mon, 5 Jan 2009 12:38:52 +0100
Subject: [PATCH 3/3] Bug fix in SBC encoder program to correctly handle file sizes.
--- sbc/sbcenc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
sbc/sbcenc.c +3 -1
@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count)while (count >0 ) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos>len?pos:len; count -= len; pos += len;
@@ -188,6 +188,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, len =sbc_encode (&sbc, input, size, output,sizeof (output), &encoded); +if (len <=0 ) +break ;if (len < size)memmove (input, input + len, size - len);
Signature · 1 line
1.6.1.rc2
Luiz Augusto von Dentz
maintainerRe: [PATCH] SBC Encoder program
Hi Christian
Quoted 6 lines
Yes, there was a bug in the encoder program. Attached the patch.
Greetings
Christian
Coding style:
return pos > len ? pos : len;
Signature · 2 lines
Luiz Augusto von Dentz Engenheiro de Computação
Re: [PATCH] SBC Encoder program
Quoted 4 lines · Luiz Augusto von Dentz
Hi Christian
Quoted 2 lines
Yes, there was a bug in the encoder program. Attached the patch.
Quoted 8 lines
Quoted 4 lines
Greetings
ChristianCoding style:
return pos > len ? pos : len;
Thanks. I corrected it and even found another bug.
Attached the new and corrected patch.
Greetings
Christian
Quoted 1 line
From
9a914d4b282f4c885ff074263c4da03e482fd99dMon Sep 17 00:00:00 2001
From: Christian Hoene <[email protected]>
Date: Mon, 5 Jan 2009 13:26:08 +0100
Subject: [PATCH 3/3] Fixed correct handling of frame sizes in the encoder
--- sbc/sbc.c | 6 +++--- sbc/sbc.h | 2 +- sbc/sbcenc.c | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-)
sbc/sbc.c +3 -3
@@ -69,7 +69,7 @@ struct sbc_frame {uint8_t subband_mode;uint8_t subbands;uint8_t bitpool; -uint8_t codesize; +uint16_t codesize;uint8_t length;/* bit number x set means joint stereo has been used in subband x */
@@ -1293,9 +1293,9 @@ int sbc_get_frame_duration(sbc_t *sbc)return (1000000 * blocks * subbands) / frequency; } -int sbc_get_codesize (sbc_t *sbc) +uint16_t sbc_get_codesize (sbc_t *sbc) { -uint8_t subbands, channels, blocks; +uint16_t subbands, channels, blocks;struct sbc_priv *priv; priv = sbc->priv;
sbc/sbc.h +1 -1
@@ -87,7 +87,7 @@ int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output, int output_len, int *written);int sbc_get_frame_length (sbc_t *sbc);int sbc_get_frame_duration (sbc_t *sbc); -int sbc_get_codesize (sbc_t *sbc); +uint16_t sbc_get_codesize (sbc_t *sbc);void sbc_finish (sbc_t *sbc);#ifdef __cplusplus
sbc/sbcenc.c +3 -1
@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count)while (count >0 ) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos > len ? pos : len; count -= len; pos += len;
@@ -188,6 +188,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, len =sbc_encode (&sbc, input, size, output,sizeof (output), &encoded); +if (len <=0 ) +break ;if (len < size)memmove (input, input + len, size - len);
Signature · 1 line
1.6.1.rc2
Luiz Augusto von Dentz
maintainerRe: [PATCH] SBC Encoder program
Hi Christian,
Just the codesize is 16 bit, right? So I guess the following changes are not really necessary:
+ uint16_t subbands, channels, blocks;
Signature · 2 lines
Luiz Augusto von Dentz Engenheiro de Computação
RE: [PATCH] SBC Encoder program
sbc/sbc.c int sbc_get_frame_duration(sbc_t *sbc) · line 1298
Quoted 5 lines
Just the codesize is 16 bit, right? So I guess the following changes are not really necessary:
sbc/sbc.c +1
-0+uint16_t subbands, channels, blocks;
No, but then we have to change the last line of the function to
return ((uint16_t)subbands) * blocks * channels * 2;
CH
Re: [PATCH] SBC Encoder program
Quoted 8 lines · On Monday 05 January 2009 16:42:39 ext Christian Hoene wrote:
sbc/sbc.c int sbc_get_frame_duration(sbc_t *sbc) · line 1298
Quoted 5 lines
Just the codesize is 16 bit, right? So I guess the following changes are not really necessary:
sbc/sbc.c +1
-0+uint16_t subbands, channels, blocks;No, but then we have to change the last line of the function to
return ((uint16_t)subbands) * blocks * channels * 2;
Not quite so. There is such thing as "integer promotion" defined in C standard. And integer type is guaranteed to be at least 16 bit. But I agree that explicitly having uint16_t is much more likely not to raise any doubts about its correctness :)
Signature · 2 lines
Best regards, Siarhei Siamashka
Re: [PATCH] SBC Encoder program
In reply to Christian HoeneQuoted 8 lines · On Monday 05 January 2009 14:28:36 ext Christian Hoene wrote:
Quoted 7 lines · Luiz Augusto von Dentz
Hi Christian
Quoted 4 lines
Yes, there was a bug in the encoder program. Attached the patch.
Greetings
Christian
Quoted 7 lines
Quoted 3 lines
Coding style:
return pos > len ? pos : len;
Thanks. I corrected it and even found another bug.
Attached the new and corrected patch.
There are some parts that look a bit redundant/suspicious:
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t count) · line 53
Quoted 9 lines
sbc/sbcenc.c +1
-1@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count)while (count >0 ) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos > len ? pos : len; count -= len; pos += len;
Is the ternary '?' operator really needed here? In this part of code we know for sure that 'len' is less or equal to zero, also 'pos ' is a positive number or zero. Having just 'return pos' should be enough.
sbc/sbcenc.c static void encode(char *filename, int subbands, int · line 195
Quoted 9 lines
sbc/sbcenc.c +2
-0@@ -188,6 +188,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, len =sbc_encode (&sbc, input, size, output,sizeof (output), &encoded); +if (len <=0 ) +break ;if (len < size)memmove (input, input + len, size - len);
If the return value is negative, there was some error. Probably showing some kind of error message is appropriate here instead of just silently bailing out.
Signature · 2 lines
Best regards, Siarhei Siamashka
RE: [PATCH] SBC Encoder program
Quoted 9 lines
There are some parts that look a bit redundant/suspicious:
Quoted 7 lines
sbc/sbcenc.c +1
-1@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count)while (count >0 ) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos > len ? pos : len;
Quoted 6 lines
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t count) · line 53
Quoted 2 lines
sbc/sbcenc.c +0
-0count -= len; pos += len;Is the ternary '?' operator really needed here? In this part of code we know for sure that 'len' is less or equal to zero, also 'pos ' is a positive number or zero. Having just 'return pos' should be enough.
No. If read returns an error, the this error is passed to __read, too.
Quoted 13 lines
sbc/sbcenc.c static void encode(char *filename, int subbands, int · line 195
Quoted 9 lines
sbc/sbcenc.c +2
-0@@ -188,6 +188,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint, len =sbc_encode (&sbc, input, size, output,sizeof (output), &encoded); +if (len <=0 ) +break ;if (len < size)memmove (input, input + len, size - len);If the return value is negative, there was some error. Probably showing some kind of error message is appropriate here instead of just silently bailing out.
Yes, if len is -1 then errno depended message shall be printed and the program should quit.
CH
Re: [PATCH] SBC Encoder program
Quoted 8 lines · On Monday 05 January 2009 16:42:39 ext Christian Hoene wrote:
Quoted 8 lines
There are some parts that look a bit redundant/suspicious:
Quoted 7 lines
sbc/sbcenc.c +1
-1@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count) while (count > 0) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos > len ? pos : len;
Quoted 8 lines
Quoted 6 lines
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t count) · line 53
Quoted 2 lines
sbc/sbcenc.c +0
-0count -= len; pos += len;Is the ternary '?' operator really needed here? In this part of code we know for sure that 'len' is less or equal to zero, also 'pos ' is a positive number or zero. Having just 'return pos' should be enough.
No. If read returns an error, the this error is passed to
__read, too.
I mean that 'return pos > len ? pos : len' and 'return pos' expressions are completely interexchangeable in this context.
Regarding this particular change itself, was there a reproducible problem in your testing that strictly required this fix? Was it involving sockets or pipes?
But the bug in 'sbc_get_codesize' is the unquestionable one for sure. Good job finding and fixing it.
Signature · 2 lines
Best regards, Siarhei Siamashka
Re: [PATCH] SBC Encoder program
Quoted 1 line · On Monday 05 January 2009 17:18:44 ext Siarhei Siamashka wrote:
On Monday 05 January 2009 16:42:39 ext Christian Hoene wrote:
[...]
Quoted 2 lines
But the bug in '
sbc_get_codesize' is the unquestionable one for sure. Good job finding and fixing it.
Sorry, I meant the need to promote 'codesize' to uint16_t is unquestionable, not changing the 'sbc_get_codesize' function itself :)
Signature · 2 lines
Best regards, Siarhei Siamashka
RE: [PATCH] SBC Encoder program
In reply to Siarhei SiamashkaQuoted 2 lines
I mean that 'return pos > len ? pos : len' and 'return pos' expressions are completely interexchangeable in this context.
They are slightly different but really, I do not care. Both fixes will work. At least one must be applied.
BTW: Why not use fread instead? ;-)
Greetings
Christian
Re: [PATCH] SBC Encoder program
Quoted 4 lines · On Monday 05 January 2009 17:33:10 ext Christian Hoene wrote:
Quoted 2 lines
I mean that 'return pos > len ? pos : len' and 'return pos' expressions are completely interexchangeable in this context.
They are slightly different but really, I do not care. Both fixes will work.
Yes, because they provide exactly identical results :-) In this sense, your fix is a bit broken, because it will never allow to pass through and return a negative error code.
Quoted 1 line
At least one must be applied. BTW: Why not use fread instead? ;-)
Agreed here. What's the point of having double underscored versions (such identifiers are reserved and not allowed to be used by programs) of read and write functions? Maybe they can be purged and just normal read/write calls could be used instead? Or alternatively fread/fwrite indeed?
Also there seems to be a performance issue: memove calls are redundant and can be avoided in SBC encoder program.
I can confirm that getting rid of the __read and __write functions (or fixing them with your patch or its modification) is the only change, needed to pass encoder test 08.
All the other changes are not directly related to this particular testcase, though a fix for 'codesize' is also nice to have. It would be required for a faster, memmove-free version of the encoder.
You have found and fixed two definite bugs (as I can see it now), that's very good. Now it would be nice to apply the fixes to git with the descriptive commit messages and move forward ;-)
Signature · 2 lines
Best regards, Siarhei Siamashka
Re: [PATCH] SBC Encoder program
In reply to Siarhei Siamashka2009/1/5 Siarhei Siamashka <[email protected]>:
Quoted 16 lines · On Monday 05 January 2009 16:42:39 ext Christian Hoene wrote:
Quoted 15 lines
Quoted 14 lines
There are some parts that look a bit redundant/suspicious:
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t · line 53
Quoted 9 lines
sbc/sbcenc.c +1
-1@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count) while (count > 0) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos > len ? pos : len; count -= len; pos += len;Is the ternary '?' operator really needed here? In this part of code we know for sure that 'len' is less or equal to zero, also 'pos ' is a positive number or zero. Having just 'return pos' should be enough.
Quoted 5 lines
Quoted 1 line
No. If read returns an error, the this error is passed to
__read, too.I mean that 'return pos > len ? pos : len' and 'return pos' expressions are completely interexchangeable in this context.
I wonder if you
shouldn't check before you read if position is not exceeding the length?
+ if (pos > len) // if we are beyond end then why
bother to read more
+ return pos;
Quoted 2 lines
len = read(fd, buf + pos, count);
if (len <= 0)+ return len; //to report an error
-> - return len;
-> + return pos > len ? pos : len;
and as position is always >0 and len < 0 in this place it would always be reduced to pos
Quoted 3 lines
count -= len;
pos += len;Best wishes
Marcin Tolysz
Re: [PATCH] SBC Encoder program
In reply to Siarhei SiamashkaQuoted 18 lines · Siarhei Siamashka
Quoted 16 lines · On Monday 05 January 2009 16:42:39 ext Christian Hoene wrote:
Quoted 16 lines
There are some parts that look a bit redundant/suspicious:
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t · line 53
Quoted 10 lines
sbc/sbcenc.c +1
-1@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count) while (count > 0) { len =read (fd, buf + pos, count);if (len <=0 ) -return len; +return pos > len ? pos : len; count -= len; pos += len;Is the ternary '?' operator really needed here? In this part of code we know for sure that 'len' is less or equal to zero, also 'pos ' is a positive number or zero. Having just 'return pos' should be enough.
Quoted 6 lines
Quoted 2 lines
No. If read returns an error, the this error is passed to
__read, too.I mean that 'return pos > len ? pos : len' and 'return pos' expressions are completely interexchangeable in this context.
Is it trying to say: return pos > 0 ? pos : len;
That's slightly functionally different, but makes it make sense to have a ternary there :) Dodgy to ignore the error though (when pos > 0).
Re: [PATCH] SBC Encoder program
In reply to Siarhei SiamashkaHi all,
I want to apologize for my previous post :)
If what you want is to know is if there was an error & how much you red? that it might not work as you cann't return two value at once (not this way).
But if you want to now if there was an error on first reading?
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t count) · line 49
Quoted 4 lines
sbc/sbcenc.c +0
-0@@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count)while (count >0 ) { len =read (fd, buf + pos, count);if (len <=0 )
-> - return len;
-> + return pos > len ? pos : len;
+ return pos > 0 ? pos : len;
sbc/sbcenc.c static ssize_t __read(int fd, void *buf, size_t count) · line 53
Quoted 3 lines
sbc/sbcenc.c +0
-0count -= len; pos += len;
this will return error code on first reading and the position successfully red (i.e. before the error) on sequent readings. (all assuming that pos==on entry)
You probably do not want to know the variant with position(=0) on the first reading and error code on subsequent(before your patch)
Before your patch it was an error code all the time After your patch it was the position all the time
Best Wishes
Marcin Tolysz
Marcel Holtmann
maintainerRe: [PATCH] SBC Encoder program
In reply to Christian HoeneHi Christian,
Quoted 10 lines
Quoted 6 lines
Quoted 1 line
Yes, there was a bug in the encoder program. Attached the patch.
Coding style:
return pos > len ? pos : len;
Thanks. I corrected it and even found another bug.
Attached the new and corrected patch.
patch has been applied. Thanks.
Regards
Marcel
Luiz Augusto von Dentz
maintainerHi,
Christian did your changes to codesize fixes the test 08, or there a bug on 16 bit version?
--=20
Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o
Is it possible that user change a stream path between Speaker and Bluetooth like normal phone?
Hi,
If you know or possible,
Could you explain me how to change stream path between Speaker or Bluetooth with BlueZ gstreamer plug-in like normal phone?
In my case, I could see it works well with a gstreamer output-selector element except some case.
1. User listens to Bluetooth Stereo Audio.
2. Switch off the headset when stream position is about 5 second from the start of the song.
3. Gstreamer Plug-in gst_avdtp_sink_render() we could see g_io_channel_write()works well even though headset is already off.
4. When stream position is about 9 second, g_io_channel_write() function is blocked....-.-;
5. When it is 14 second , g_io_chhanel_write() returns with timeout error.
It's problem that at 14 second , gstreamer could not do anything even if they know the error...
Related to this scenario , Do you have a good idea?
As a matter of fact, I try to avoid blocking , I change g_io_channel_write() as non-blocking call.
Because Non blocking call makes the situation to the gstreamer like normal condition. So we can change it easily as usual.
But the side effects occurs that music stream is mixed..when wireless communication doesn't work well-.-;
Regards.
Chanyeol
Re: Is it possible that user change a stream path between Speaker and Bluetooth like normal phone?
Quoted 8 lines · Chan-Yeol Park
Hi,
If you know or possible,
Could you explain me how to change stream path between Speaker or Bluetooth with BlueZ gstreamer plug-in like normal phone?In my case, I could see it works well with a gstreamer output-selector element except some case.
Use PulseAudio's Bluetooth module, that's what it's made for.
Quoted 6 lines
Quoted 2 lines
Good news! All tests passed!
http://net.cs.uni-tuebingen.de/html/nexgenvoip/Thank you very much. Sorry for the delay with reply too.
I wonder if we need to do something about test 08?
Done.
Quoted 5 lines
Also could you try running a special test of version 4.25 with
SBC_HIGH_PRECISIONenabled? The point is that it uses the best possible precision for the analysis filter and minimizes effects of rounding errors (I would estimate that the precision should be even better than single precision floating point). Having the test run with
this
Quoted 3 lines
precision settings can expose some of the other minor bugs in the code (if they exist), which can now be hidden under the slight precision loss because of using 16-bit fixed point calculations.
I have uploaded the results to
http://net.cs.uni-tuebingen.de/html/nexgenvoip/4.25_high_precision
The encoding results did not change.
Best regards,
Christian
Quoted 17 lines · On Monday 05 January 2009 16:55:27 ext Christian Hoene wrote:
Quoted 6 lines
Quoted 2 lines
Good news! All tests passed!
http://net.cs.uni-tuebingen.de/html/nexgenvoip/Thank you very much. Sorry for the delay with reply too.
I wonder if we need to do something about test 08?
Done.
Quoted 5 lines
Also could you try running a special test of version 4.25 with
SBC_HIGH_PRECISIONenabled? The point is that it uses the best possible precision for the analysis filter and minimizes effects of rounding errors (I would estimate that the precision should be even better than single precision floating point). Having the test run withthis
Quoted 8 lines
Quoted 3 lines
precision settings can expose some of the other minor bugs in the code (if they exist), which can now be hidden under the slight precision loss because of using 16-bit fixed point calculations.
I have uploaded the results to
http://net.cs.uni-tuebingen.de/html/nexgenvoip/4.25_high_precisionThe encoding results did not change.
Great, it means that sbc encoder is mostly bug free (at least none of them shows up on this test set with all the available bugfixes applied).
Now a good improvement would be to tweak the default 16-bit version of analysis filter to improve its precision. It is a lot faster than the high precision variant and already provides sufficient quality :)
Signature · 2 lines
Best regards, Siarhei Siamashka
Quoted 7 lines · Siarhei Siamashka
Quoted 6 lines · On Thursday 01 January 2009 16:24:21 ext Christian Hoene wrote:
Hello Siarhei,
sorry for the delay - these days my family comes first ;-)
Good news! All tests passed!
http://net.cs.uni-tuebingen.de/html/nexgenvoip/
Congratulations!