Re: [flac-dev] PATCH for rice_parameter calculation

2013-10-11 Thread Brian Willoughby
Or, I was originally thinking:

rice_parameter = 0; k = partition_samples;
if (k < mean) {
int n = mean - k;
rice_parameter += n;
k <<= n;
}

(sorry for the hasty post)


On Oct 11, 2013, at 10:34, Brian Willoughby wrote:
> Hmm, maybe I'm missing something, but what about this:
>
>   rice_parameter = 0; k = partition_samples;
>   int n = mean - k;
>   if (n > 0) {
>   rice_parameter += n;
>   k <<= n;
>   }
>
> I've not looked at this code in its context within stream_encoder.c,
> so it's easily possible that I left out something.
>
> Brian Willoughby
> Sound Consulting
>
>
> On Oct 9, 2013, at 08:54, lvqcl wrote:
>> MSVS profiler shows that the following code in stream_encoder.c takes
>> several percent of CPU time:
>>
>> for(rice_parameter = 0, k = partition_samples; k < mean;
>> rice_parameter++, k <<= 1)
>> ;
>>
>> this code is equivalent to:
>>
>> rice_parameter = 0; k = partition_samples;
>> while(k < mean) {
>> rice_parameter++; k <<= 1;
>> }
>>
>> The idea was to accelerate it:
>>
>> rice_parameter = 0; k = partition_samples;
>> while(k*2 < mean) {
>> rice_parameter+=2; k <<= 2;
>> }
>> while(k < mean) {
>> rice_parameter++; k <<= 1;
>> }
>>
>> or:
>> rice_parameter = 0; k = partition_samples;
>> while(k*4 < mean) {
>> rice_parameter+=3; k <<= 3;
>> }
>> while(k < mean) {
>> rice_parameter++; k <<= 1;
>> }

___
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev


Re: [flac-dev] PATCH for rice_parameter calculation

2013-10-11 Thread Brian Willoughby
Hmm, maybe I'm missing something, but what about this:

rice_parameter = 0; k = partition_samples;
int n = mean - k;
if (n > 0) {
rice_parameter += n;
k <<= n;
}

I've not looked at this code in its context within stream_encoder.c,  
so it's easily possible that I left out something.

Brian Willoughby
Sound Consulting


On Oct 9, 2013, at 08:54, lvqcl wrote:
> MSVS profiler shows that the following code in stream_encoder.c takes
> several percent of CPU time:
>
> for(rice_parameter = 0, k = partition_samples; k < mean;  
> rice_parameter++, k <<= 1)
> ;
>
> this code is equivalent to:
>
> rice_parameter = 0; k = partition_samples;
> while(k < mean) {
> rice_parameter++; k <<= 1;
> }
>
> The idea was to accelerate it:
>
> rice_parameter = 0; k = partition_samples;
> while(k*2 < mean) {
> rice_parameter+=2; k <<= 2;
> }
> while(k < mean) {
> rice_parameter++; k <<= 1;
> }
>
> or:
> rice_parameter = 0; k = partition_samples;
> while(k*4 < mean) {
> rice_parameter+=3; k <<= 3;
> }
> while(k < mean) {
> rice_parameter++; k <<= 1;
> }
>
>
> After tuning the code for 16-/24-bit WAV and 32-/64-bit compiles
> I wrote more complex code (see attach). It doesn't look pretty but
> it's faster than the current version. For highest compression preset,
> 24-bit input and 32-bit exe the encoding speed increases by 6..7%.


___
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev


Re: [flac-dev] unsigned long long suffix

2013-10-11 Thread Erik de Castro Lopo
lvqcl wrote:

> Erik de Castro Lopo wrote:
> 
> >> #define FLAC__U64L(x) x##ULL
> >
> > I like that one! If that works in VS2005 and later I see no reason to use
> > anything else.
> 
> MSVS 2005 Express compiles the code...
> 
> #define FLAC__U64L(x) x##ULL
> int test = FLAC__U64L(0x1234567890);
> 
> ... and generates 0 errors, 2 warnings:
>  warning C4305: 'initializing' : truncation from 'unsigned __int64' to 
> 'int'
>  warning C4309: 'initializing' : truncation of constant value
> 
> so it treats 0x1234567890ULL as 'unsigned __int64' constant.

Ok, so MSVS probably does need its own version of this macro.

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev


Re: [flac-dev] PATCH for rice_parameter calculation

2013-10-11 Thread Erik de Castro Lopo
lvqcl wrote:

> MSVS profiler shows that the following code in stream_encoder.c takes
> several percent of CPU time:


This has been applied.

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev