Return-Path: From: "Christian Hoene" To: "'Frans de Bont'" Date: Thu, 30 Oct 2008 15:54:38 +0100 Message-ID: <001d01c93a9f$6f2c8710$4d859530$@de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_001E_01C93AA7.D0F11620" Cc: 'BlueZ development' Subject: [Bluez-devel] FW: REALLY Bad encoding performance of Linux SBC audio codec Reply-To: BlueZ development List-Id: BlueZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bluez-devel-bounces@lists.sourceforge.net Dies ist eine mehrteilige Nachricht im MIME-Format. ------=_NextPart_000_001E_01C93AA7.D0F11620 Content-Type: multipart/alternative; boundary="----=_NextPart_001_001F_01C93AA7.D0F11620" ------=_NextPart_001_001F_01C93AA7.D0F11620 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello Frans, thank you for the patch!! Christian From: Frans de Bont [mailto:frans.de.bont@philips.com] Sent: Thursday, October 30, 2008 2:34 PM To: Christian Hoene Subject: RE: [Bluez-devel] REALLY Bad encoding performance of Linux SBC audio codec Hello Christian, I had a quick look into the bluez sbc decoder test application. I discovered that the buffering was not correct. Attached a modified version. Please note that the output level of the decoder is still 6 dB too low. This wouldn't be too difficult to fix for the bluez developers. Best regards, Frans "Christian Hoene" 2008-10-29 04:30 PM To "'BlueZ development'" cc Frans de Bont/EHV/APPTECH/PHILIPS@PHILIPS Subject RE: [Bluez-devel] REALLY Bad encoding performance of Linux SBC audio codec Classification Hello, Sorry Bad news. the encoding and decodng performance of bluez's SBC is really bad. I just used the latest sbcenc program from bluez-4.17 and compared it to the reference Attached you will find wav-files encoded with the Bluetooth reference implementation and bluez Filelist ======== compare.sh is the scrip that I use to compare both codec versions refsop01.wav the original sample tmp.ref.sbc with reference encoded tmp.bluez.sbc with bluez encoded tmp.ref.sw.wav with reference encoded and decoded (has good quality) tmp.bluez.sw.wav with bluez encoded and decoded (has bad quality ODG=) tmp.refbluez.sw.wav with reference encoded and with bluez decoded (has bad quality) tmp.bluezref.sw.wav with bluez encoded and with reference decoded (has medium quality) Both the bluez encoder and decoder do not work as good as the reference implementation. I also conducted some perceptual audio tests with ITU BS.1387 (PEAQ), which confirm these results. With best regards, Christian PS: Attached also an enhanced version for sbc/sbcenc.c, which considers more command line options. > -----Original Message----- > From: Marcel Holtmann [mailto:marcel@holtmann.org] > Sent: Monday, October 27, 2008 8:42 PM > To: BlueZ development > Subject: Re: [Bluez-devel] Bad encoding performance of Linux SBC audio > codec > > Hi Brad, > > > > I am sorry to say that the audio quality of the open source version > of SBC > > > is far worse than the reference implementation. > > > > If you are using the standalone "sbc" project at sourceforge, then > you > > should try the version inside bluez. The standalone used to simply be > > slower, but we identified & fixed some quality issues too that should > > be backported. > > the standalone version should not be used at all at the moment. All > efforts should go into the version included in bluez-4.x.tar.gz. > > Regards > > Marcel > > > > ----------------------------------------------------------------------- > -- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Bluez-devel mailing list > Bluez-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bluez-devel [attachment "sbcenc.c" deleted by Frans de Bont/EHV/APPTECH/PHILIPS] [attachment "compare.tar.gz" deleted by Frans de Bont/EHV/APPTECH/PHILIPS] ------=_NextPart_001_001F_01C93AA7.D0F11620 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello Frans,

 

thank you for the patch!!

 

Christian

 

 

From:= Frans de = Bont [mailto:frans.de.bont@philips.com]
Sent: Thursday, October 30, 2008 2:34 PM
To: Christian Hoene
Subject: RE: [Bluez-devel] REALLY Bad encoding performance of = Linux SBC audio codec

 


Hello Christian,

I had = a quick look into the bluez sbc decoder test application.
I = discovered that the buffering was not correct.
Attached a modified version.

Please = note that the output level of the decoder is still 6 dB too low.
This = wouldn't be too difficult to fix for the bluez developers.

Best = regards,
Frans =







"Christia= n Hoene" <hoene@uni-tuebingen.de>

2008-10-29 04:30 PM

To=

"'BlueZ development'" <bluez-devel@lists.sourceforge.net> =

cc=

Frans de Bont/EHV/APPTECH/PHILIPS@PHILIPS

Subject=

RE: [Bluez-devel] REALLY Bad encoding performance of Linux SBC   =       audio codec

Classification=

 




Hello,

Sorry Bad news.
the encoding and decodng performance of bluez's SBC is really bad. =
I just used the latest sbcenc program from bluez-4.17 and compared = it to the
reference

Attached you will find wav-files encoded with the Bluetooth = reference
implementation and bluez

Filelist
=3D=3D=3D=3D=3D=3D=3D=3D
compare.sh                 =         is the scrip that I use to compare both = codec
versions
refsop01.wav        the original sample
tmp.ref.sbc         with reference = encoded
tmp.bluez.sbc       with bluez encoded
tmp.ref.sw.wav      with reference encoded and = decoded (has good quality)
tmp.bluez.sw.wav    with bluez encoded and decoded (has = bad quality ODG=3D)
tmp.refbluez.sw.wav with reference encoded and with bluez decoded = (has bad
quality)
tmp.bluezref.sw.wav with bluez encoded and with reference decoded = (has
medium quality)

Both the bluez encoder and decoder do not work as good as the = reference
implementation.

I also conducted some perceptual audio tests with ITU BS.1387 = (PEAQ), which
confirm these results.

With best regards,

Christian

PS:
Attached also an enhanced version for sbc/sbcenc.c, which considers = more
command line options.



> -----Original Message-----
> From: Marcel Holtmann [mailto:marcel@holtmann.org]
> Sent: Monday, October 27, 2008 8:42 PM
> To: BlueZ development
> Subject: Re: [Bluez-devel] Bad encoding performance of Linux = SBC audio
> codec
>
> Hi Brad,
>
> > > I am sorry to say that the audio quality of the open = source version
> of SBC
> > > is far worse than the reference = implementation.
> >
> > If you are using the standalone "sbc" project at sourceforge, then
> you
> > should try the version inside bluez. The standalone used = to simply be
> > slower, but we identified & fixed some quality issues = too that should
> > be backported.
>
> the standalone version should not be used at all at the moment. = All
> efforts should go into the version included in = bluez-4.x.tar.gz.
>
> Regards
>
> Marcel
>
>
>
> -----------------------------------------------------------------------
> --
> This SF.Net email is sponsored by the Moblin Your Move = Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK = & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere = in the
> world
> = http://moblin-contest.org/redirect.php?banner_id=3D100&url=3D/ > _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> = https://lists.sourceforge.net/lists/listinfo/bluez-devel
[attachment "sbcenc.c" deleted by Frans de Bont/EHV/APPTECH/PHILIPS] [attachment "compare.tar.gz" deleted = by Frans de Bont/EHV/APPTECH/PHILIPS]

------=_NextPart_001_001F_01C93AA7.D0F11620-- ------=_NextPart_000_001E_01C93AA7.D0F11620 Content-Type: application/octet-stream; name="sbcdec.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sbcdec.c" /*=0A= *=0A= * Bluetooth low-complexity, subband codec (SBC) decoder=0A= *=0A= * Copyright (C) 2004-2008 Marcel Holtmann =0A= *=0A= *=0A= * This program is free software; you can redistribute it and/or modify=0A= * it under the terms of the GNU General Public License as published by=0A= * the Free Software Foundation; either version 2 of the License, or=0A= * (at your option) any later version.=0A= *=0A= * This program is distributed in the hope that it will be useful,=0A= * but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= * GNU General Public License for more details.=0A= *=0A= * You should have received a copy of the GNU General Public License=0A= * along with this program; if not, write to the Free Software=0A= * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA = 02110-1301 USA=0A= *=0A= */=0A= =0A= #ifdef HAVE_CONFIG_H=0A= #include =0A= #endif=0A= =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= =0A= #include "sbc.h"=0A= #include "formats.h"=0A= =0A= #define BUF_SIZE 8192=0A= =0A= static void decode(char *filename, char *output, int tofile)=0A= {=0A= unsigned char buf[BUF_SIZE], *stream;=0A= struct stat st;=0A= off_t filesize;=0A= sbc_t sbc;=0A= int fd, ad, pos, streamlen, framelen, count, written, len;=0A= int format =3D AFMT_S16_BE, frequency, channels;=0A= =0A= if (stat(filename, &st) < 0) {=0A= fprintf(stderr, "Can't get size of file %s: %s\n",=0A= filename, strerror(errno));=0A= return;=0A= }=0A= =0A= filesize =3D st.st_size;=0A= stream =3D malloc(st.st_size);=0A= =0A= if (!stream) {=0A= fprintf(stderr, "Can't allocate memory for %s: %s\n",=0A= filename, strerror(errno));=0A= return;=0A= }=0A= =0A= fd =3D open(filename, O_RDONLY);=0A= if (fd < 0) {=0A= fprintf(stderr, "Can't open file %s: %s\n",=0A= filename, strerror(errno));=0A= goto free;=0A= }=0A= =0A= if (read(fd, stream, st.st_size) !=3D st.st_size) {=0A= fprintf(stderr, "Can't read content of %s: %s\n",=0A= filename, strerror(errno));=0A= close(fd);=0A= goto free;=0A= }=0A= =0A= close(fd);=0A= =0A= pos =3D 0;=0A= streamlen =3D st.st_size;=0A= =0A= if (tofile)=0A= ad =3D open(output, O_WRONLY | O_CREAT | O_TRUNC, 0644);=0A= else=0A= ad =3D open(output, O_WRONLY, 0);=0A= =0A= if (ad < 0) {=0A= fprintf(stderr, "Can't open output %s: %s\n",=0A= output, strerror(errno));=0A= goto free;=0A= }=0A= =0A= sbc_init(&sbc, 0L);=0A= sbc.endian =3D SBC_BE;=0A= =0A= framelen =3D sbc_decode(&sbc, stream, streamlen, buf, sizeof(buf), = &len);=0A= channels =3D sbc.mode =3D=3D SBC_MODE_MONO ? 1 : 2;=0A= switch (sbc.frequency) {=0A= case SBC_FREQ_16000:=0A= frequency =3D 16000;=0A= break;=0A= =0A= case SBC_FREQ_32000:=0A= frequency =3D 32000;=0A= break;=0A= =0A= case SBC_FREQ_44100:=0A= frequency =3D 44100;=0A= break;=0A= =0A= case SBC_FREQ_48000:=0A= frequency =3D 48000;=0A= break;=0A= default:=0A= frequency =3D 0;=0A= }=0A= =0A= printf("%d Hz, %d channels\n", frequency, channels);=0A= if (tofile) {=0A= struct au_header au_hdr;=0A= =0A= au_hdr.magic =3D AU_MAGIC;=0A= au_hdr.hdr_size =3D BE_INT(24);=0A= au_hdr.data_size =3D BE_INT(0);=0A= au_hdr.encoding =3D BE_INT(AU_FMT_LIN16);=0A= au_hdr.sample_rate =3D BE_INT(frequency);=0A= au_hdr.channels =3D BE_INT(channels);=0A= =0A= written =3D write(ad, &au_hdr, sizeof(au_hdr));=0A= if (written < sizeof(au_hdr)) {=0A= fprintf(stderr, "Failed to write header\n");=0A= goto close;=0A= }=0A= } else {=0A= if (ioctl(ad, SNDCTL_DSP_SETFMT, &format) < 0) {=0A= fprintf(stderr, "Can't set audio format on %s: %s\n",=0A= output, strerror(errno));=0A= goto close;=0A= }=0A= =0A= if (ioctl(ad, SNDCTL_DSP_CHANNELS, &channels) < 0) {=0A= fprintf(stderr,=0A= "Can't set number of channels on %s: %s\n",=0A= output, strerror(errno));=0A= goto close;=0A= }=0A= =0A= if (ioctl(ad, SNDCTL_DSP_SPEED, &frequency) < 0) {=0A= fprintf(stderr, "Can't set audio rate on %s: %s\n",=0A= output, strerror(errno));=0A= goto close;=0A= }=0A= }=0A= =0A= count =3D len;=0A= while (framelen > 0) {=0A= /* we have completed an sbc_decode at this point sbc.len is the=0A= * length of the frame we just decoded count is the number of=0A= * decoded bytes yet to be written */=0A= =0A= if (count + len >=3D BUF_SIZE) {=0A= /* buffer is too full to stuff decoded audio in so it=0A= * must be written to the device */=0A= written =3D write(ad, buf, count);=0A= if (written > 0)=0A= count -=3D written;=0A= }=0A= =0A= /* sanity check */=0A= if (count + len >=3D BUF_SIZE) {=0A= fprintf(stderr,=0A= "buffer size of %d is too small for decoded"=0A= " data (%d)\n", BUF_SIZE, len + count);=0A= exit(1);=0A= }=0A= =0A= /* push the pointer in the file forward to the next bit to be=0A= * decoded tell the decoder to decode up to the remaining=0A= * length of the file (!) */=0A= pos +=3D framelen;=0A= framelen =3D sbc_decode(&sbc, stream + pos, streamlen - pos,=0A= buf + count, sizeof(buf) - count, &len);=0A= =0A= /* increase the count */=0A= count +=3D len;=0A= }=0A= =0A= if (count > 0) {=0A= written =3D write(ad, buf, count);=0A= if (written > 0)=0A= count -=3D written;=0A= }=0A= =0A= close:=0A= sbc_finish(&sbc);=0A= =0A= close(ad);=0A= =0A= free:=0A= free(stream);=0A= }=0A= =0A= static void usage(void)=0A= {=0A= printf("SBC decoder utility ver %s\n", VERSION);=0A= printf("Copyright (c) 2004-2008 Marcel Holtmann\n\n");=0A= =0A= printf("Usage:\n"=0A= "\tsbcdec [options] file(s)\n"=0A= "\n");=0A= =0A= printf("Options:\n"=0A= "\t-h, --help Display help\n"=0A= "\t-v, --verbose Verbose mode\n"=0A= "\t-d, --device Sound device\n"=0A= "\t-f, --file Decode to a file\n"=0A= "\n");=0A= }=0A= =0A= static struct option main_options[] =3D {=0A= { "help", 0, 0, 'h' },=0A= { "device", 1, 0, 'd' },=0A= { "verbose", 0, 0, 'v' },=0A= { "file", 1, 0, 'f' },=0A= { 0, 0, 0, 0 }=0A= };=0A= =0A= int main(int argc, char *argv[])=0A= {=0A= char *output =3D NULL;=0A= int i, opt, verbose =3D 0, tofile =3D 0;=0A= =0A= while ((opt =3D getopt_long(argc, argv, "+hvd:f:", main_options, NULL)) = !=3D -1) {=0A= switch(opt) {=0A= case 'h':=0A= usage();=0A= exit(0);=0A= =0A= case 'v':=0A= verbose =3D 1;=0A= break;=0A= =0A= case 'd':=0A= if (output)=0A= free(output);=0A= output =3D strdup(optarg);=0A= tofile =3D 0;=0A= break;=0A= =0A= case 'f' :=0A= if (output)=0A= free(output);=0A= output =3D strdup(optarg);=0A= tofile =3D 1;=0A= break;=0A= =0A= default:=0A= exit(1);=0A= }=0A= }=0A= =0A= argc -=3D optind;=0A= argv +=3D optind;=0A= optind =3D 0;=0A= =0A= if (argc < 1) {=0A= usage();=0A= exit(1);=0A= }=0A= =0A= for (i =3D 0; i < argc; i++)=0A= decode(argv[i], output ? output : "/dev/dsp", tofile);=0A= =0A= if (output)=0A= free(output);=0A= =0A= return 0;=0A= }=0A= ------=_NextPart_000_001E_01C93AA7.D0F11620 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ------=_NextPart_000_001E_01C93AA7.D0F11620 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ------=_NextPart_000_001E_01C93AA7.D0F11620--