[Speex-dev] High CPU usage

Jozsef Vass jovass at adobe.com
Thu Jun 14 14:06:13 PDT 2012


Hi Mark,

Code below:
int16_t* samples;
int16_t* fbSilenceFrame;
void *fSpeexState;
float eng(0.f);
int speexFrameSize(0);
speex_encoder_ctl(speexState, SPEEX_GET_FRAME_SIZE, &speexFrameSize);
for (int i = 0; i < speexFrameSize; i++)
{
   eng += samples[i] * samples[i];
}
if (eng / speexFrameSize < 3.f)
{			
   memcpy(samples, silenceFrame, speexFrameSize * sizeof(int16_t));
}

where samples is an array of incoming data from microphone and silenceFrame is an array of random values of [-3, 3]. If we encode at 16 kHz, both arrays contain 320 16-bit mono samples (640 bytes).

Jozsef 

-----Original Message-----
From: speex-dev-bounces at xiph.org [mailto:speex-dev-bounces at xiph.org] On Behalf Of speex-dev-request at xiph.org
Sent: Wednesday, June 13, 2012 12:00 PM
To: speex-dev at xiph.org
Subject: Speex-dev Digest, Vol 97, Issue 1

Send Speex-dev mailing list submissions to
	speex-dev at xiph.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.xiph.org/mailman/listinfo/speex-dev
or, via email, send a message with subject or body 'help' to
	speex-dev-request at xiph.org

You can reach the person managing the list at
	speex-dev-owner at xiph.org

When replying, please edit your Subject line so it is more specific than "Re: Contents of Speex-dev digest..."


Today's Topics:

   1. Re: High CPU usage (Tanmay Ambre)
   2. Re: High CPU usage (Mark Schilling)


----------------------------------------------------------------------

Message: 1
Date: Wed, 13 Jun 2012 10:01:52 +0000 (UTC)
From: Tanmay Ambre <ambre.tanmay at gmail.com>
Subject: Re: [Speex-dev] High CPU usage
To: speex-dev at xiph.org
Message-ID: <loom.20120613T115653-705 at post.gmane.org>
Content-Type: text/plain; charset=us-ascii


Mark Schilling <mark_schilling <at> gmx.de> writes:

> 
> Hi Jozsef,
> 
> this approach sounds interesting.
> Do have you have some source code available ?
> 
> Thanks
> 
> Mark
> 
> -----Original Message-----
> From: speex-dev-bounces <at> xiph.org [mailto:speex-dev-bounces <at> 
> xiph.org]
On Behalf Of Jozsef Vass
> Sent: Friday, September 25, 2009 11:43 PM
> To: mark_schilling <at> gmx.de
> Cc: speex-dev <at> xiph.org
> Subject: Re: [Speex-dev] High CPU usage
> 
> I have run into the same issue. Before sending a frame to encoder, I 
> calculate
the energy. If it is less than a
> small threshold, I simply replace this frame with "silence frame," 
> which is
320 random samples of values
> smaller than 3 (16 kHz).
> 
> BTW, I have only experience this problem with certain USB headsets 
> that
provide you all 0 samples when muted.
> 
> Jozsef
> 
>       
> _______________________________________________
> Speex-dev mailing list
> Speex-dev <at> xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
> 

Hi,

I am having a similar problem. Definitely when some head phones are muted I get

high CPU usage. Also it seems on some older machines using Pentium 4 the CPU usage is very high. 

Does compiling speex API with DISABLE_FLOAT_API and DISABLE_VBR solve the problem?

Thanks
Tanmay






------------------------------

Message: 2
Date: Wed, 13 Jun 2012 20:41:07 +0200
From: "Mark Schilling" <mark_schilling at gmx.de>
Subject: Re: [Speex-dev] High CPU usage
To: speex-dev at xiph.org
Message-ID: <20120613184107.245260 at gmx.net>
Content-Type: text/plain; charset="utf-8"

Hi Tanmay,

>Does compiling speex API with DISABLE_FLOAT_API and DISABLE_VBR solve the 
>problem?

I remember that this fixed the problem. But at that time I also needed VBR so this was not an option.
As far as I know, it is related to some calculations that involve float denormals that cause the high CPU usage.

Today I'm still using the following code before speex_encoder_init and erverything works great:

// fix denormals performance issue
// http://software.intel.com/en-us/articles/x87-and-sse-floating-point-assists-in-ia-32-flush-to-zero-ftz-and-denormals-are-zero-daz/
__m128 state[32];
__int32 temp;
__asm fxsave state;
memcpy(&temp, (char*)state + 24, 4);
temp |= (1 << 11); // UNDERFLOW_EXCEPTION_MASK
temp |= (1 << 15); // FTZ_BIT
__asm ldmxcsr temp;

Tested with Visual Studio 2010 on x86.

Please let me know if it works for you too.

Mark
-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a


------------------------------

_______________________________________________
Speex-dev mailing list
Speex-dev at xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev


End of Speex-dev Digest, Vol 97, Issue 1
****************************************


More information about the Speex-dev mailing list