From: Takehiro T. <tak...@in...> - 2002-08-25 12:01:26
|
Some of you know I tackled to the psymodel.c and clean up and remove the too much fat of it. In this work, I found some bugs and improvement. I approve these patches and want everyone to check them. This is the one of fours. fix1: Total energy calculation uses the wrong high pass filter. in psymodel.c arround line 350, tot_ener[] is calculated by /* sum total energy at nearly no extra cost */ gfc->tot_ener[chn] = NON_LINEAR_SCALE_ENERGY(gfc->energy[0]); for (j=BLKSIZE/2-1; j >= 0; --j) { FLOAT re = (*wsamp_l)[BLKSIZE/2-j]; FLOAT im = (*wsamp_l)[BLKSIZE/2+j]; gfc->energy[BLKSIZE/2-j] = NON_LINEAR_SCALE_ENERGY((re * re + im * im) * (FLOAT)0.5); if (BLKSIZE/2-j > 10) gfc->tot_ener[chn] += gfc->energy[BLKSIZE/2-j]; } (the same routine is in the nspsy version too.) tot_ener[] is sum of gfc->energy[0] and gfc->energy[11, 12, ..., BLKSIZE/2-1]. This is too odd to me. tot_enery[] is used to calculate the ms_ratio and Main/Sub channel bit allocation, but from the psychoacoustic view, in both case, there are no need to handle DC element. It should filter out the DC element or do not use any filter, IMO. This filtering was introduced in the patch http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/lame/lame/Attic/psymodel.c.diff?r1=1.63&r2=1.64 It seems Mark missed tot_ener[] is initialized by DC element. So, I think we should apply this patch. diff -u -r1.110 psymodel.c --- libmp3lame/psymodel.c 16 Jun 2002 20:16:17 -0000 1.110 +++ libmp3lame/psymodel.c 25 Aug 2002 11:58:58 -0000 @@ -361,7 +361,7 @@ gfc->energy[0] *= gfc->energy[0]; /* sum total energy at nearly no extra cost */ - gfc->tot_ener[chn] = NON_LINEAR_SCALE_ENERGY(gfc->energy[0]); + gfc->tot_ener[chn] = 0.0; for (j=BLKSIZE/2-1; j >= 0; --j) { @@ -1451,7 +1451,7 @@ gfc->energy[0] *= gfc->energy[0]; /* sum total energy at nearly no extra cost */ - gfc->tot_ener[chn] = gfc->energy[0]; + gfc->tot_ener[chn] = 0.0; for (j=BLKSIZE/2-1; j >= 0; --j) { of course, this patch changes the result little bit and breaks testcase. But as far as my test, this is ok for me. -- Takehiro TOMINAGA // may the source be with you! |