[Ffmpeg-devel] [PATCH] updated LGPL AC-3 decoder
Aurelien Jacobs
aurel
Sat Feb 10 17:29:13 CET 2007
On Sat, 10 Feb 2007 16:30:41 +0100
Michael Niedermayer <michaelni at gmx.at> wrote:
> On Sat, Feb 10, 2007 at 01:02:20AM -0500, Justin Ruggles wrote:
> [...]
> > #include "avcodec.h"
> > #include "ac3.h"
> > #include "ac3tab.h"
> >
> > static inline int calc_lowcomp1(int a, int b0, int b1)
> > {
> > if ((b0 + 256) == b1) {
> > a = 384 ;
> > } else if (b0 > b1) {
> > a = a - 64;
> > if (a < 0) a=0;
> > }
> > return a;
> > }
>
> calc_lowcomp1(int a, int b0, int b1, int C){
> if ((b0 + 256) == b1) {
> a= C;
> } else if (b0 > b1) {
> a= FFMAX(a - 64, 0);
> }
> return a;
I had already spoted lots of potential FFMIN/FFMAX usage before seeing
Michael's reply. So here are a few more that I spoted:
> > [...]
> > end1=bndend;
> > if (end1 > 22) end1=22;
end1 = FFMIN(bndend, 22);
> > for (bin = begin; bin < end1; bin++) {
> > if (!(is_lfe && bin == 6))
> > lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin) ;
> >
> > fastleak -= s->fdecay ;
> > v = bndpsd[bin] - fgain;
> > if (fastleak < v) fastleak = v;
>
> FFMAX
fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
> > slowleak -= s->sdecay ;
> > v = bndpsd[bin] - s->sgain;
> > if (slowleak < v) slowleak = v;
>
> FFMAX
slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
> > v=fastleak - lowcomp;
> > if (slowleak > v) v=slowleak;
>
> v= FFMAX(fastleak - lowcomp, slowleak)
>
> [...]
>
> /* compute masking curve */
>
> for (bin = bndstrt; bin < bndend; bin++) {
> v1 = excite[bin];
> tmp = s->dbknee - bndpsd[bin];
> if (tmp > 0) {
> v1 += tmp >> 2;
> }
> v=hth[bin >> s->halfratecod][s->fscod];
> if (v1 > v) v=v1;
> mask[bin] = v;
mask[bin] = FFMAX(hth[bin >> s->halfratecod][s->fscod], v1);
> [...]
> v=mask[j];
> v -= snroffset ;
> v -= s->floor ;
> if (v < 0) v = 0;
> v &= 0x1fe0 ;
> v += s->floor ;
v = (FFMAX(mask[j] - snroffset - s->floor, 0) & 0x1fe0) + s->floor;
> end1=bndtab[j] + bndsz[j];
> if (end1 > end) end1=end;
end1 = FFMIN(bndtab[j] + bndsz[j], end);
Aurel
More information about the ffmpeg-devel
mailing list