[FFmpeg-devel] [PATCH/RFC] Remove triplication of compute_lpc_coefs() function
Vitor Sessak
vitor1001
Sun Aug 31 05:08:26 CEST 2008
Michael Niedermayer wrote:
> On Thu, Aug 28, 2008 at 02:28:50PM +0200, Vitor Sessak wrote:
>> Hi all.
>>
>> I've finally found a more or less clean way of doing $subj. I also want to
>
> going back to this patch ...
>
> after some tests, ive not been able to find a compute_lpc_coefs() with floats
> that results in acceptable compression
> btw, my tests gave:
> 27063400
> vs.
> 27731934
> which is a little worse than the 0.4% quoted ... (so much for the, it doesnt
> matter)
>
> using http://www.gnu.org/fun/jokes/eternal-flame.ogg
>
> so lets see if we can improve this patch ...
>
> [...]
>
>> + if ((autoc[max_order] == 0 || autoc[0] <= 0) && fail)
>> + return -1;
>
> fail should be first
done (but I wonder if gcc would be so stupid not to optimize this out in
an inline function)
>
>> +
>> + for(i=0; i<max_order; i++) lpc_tmp[i] = 0;
>> + err = autoc[0];
>> +
>> + for(i=0; i<max_order; i++) {
>> + if (normalize) {
>> + r = -autoc[i+1];
>> + for(j=0; j<i; j++) {
>> + r -= lpc_tmp[j] * autoc[i-j];
>> + }
>> + r /= err;
>> + } else
>> + r = -autoc[i];
>> +
>> + if (ref)
>> + ref[i] = fabs(r);
>> +
>> + err *= 1.0 - (r * r);
>> +
>> + i2 = (i >> 1);
>> + lpc_tmp[i] = r;
>> + for(j=0; j<i2; j++) {
>> + tmp = lpc_tmp[j];
>> + lpc_tmp[j] += r * lpc_tmp[i-1-j];
>> + lpc_tmp[i-1-j] += r * tmp;
>> + }
>> + if(i & 1) {
>> + lpc_tmp[j] += lpc_tmp[j] * r;
>> + }
>> +
>
>> + if (lpc)
>> + for(j=0; j<=i; j++) {
>> + lpc[i][j] = -lpc_tmp[j];
>> + }
>
> is this really needed?
> cant a simple
> lpc+= stride;
> be used to decide if space gets reused or all intermediates get exported?
It could, but I won't make the code simpler. lpc_tmp (which is not a
temporary var, actually) will be modified in the next loop iteration, so
one have to do some memcpy'ing anyway. (Yes, I plan to rename lpc_tmp
after this patch is commited).
About the minus operation, it'll require changes to both aac and ra288...
>> +
>> + if (err < 0 && fail)
>> + return -1;
>
> fail should be first
done.
New patch attached. I've also diff'ed it against lpc.c so you can see
what actually changed in the function.
-Vitor
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080831/09cf7c4e/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compute_lpc2.diff
Type: text/x-diff
Size: 7216 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080831/09cf7c4e/attachment.diff>
More information about the ffmpeg-devel
mailing list