[FFmpeg-soc] [soc]: r369 - jpeg2000/j2kenc.c

Kamil Nowosad kamil.nowosad at gmail.com
Thu Jul 12 13:35:03 CEST 2007


Hi

On Wed, Jul 11, 2007 at 01:16:04AM +0200, Michael Niedermayer wrote:
> > @@ -817,14 +818,14 @@ static int getnmsedec_ref(int x, int bpn
> >  
> >  static double getwmsedec(int nmsedec, int bandpos, int lev, int bpno)
> >  {
> > -   static const double dwt_norms[4][10] = {
> > -    {1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
> > -    {1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
> > -    {1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
> > -    {.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}};
> > +   static const int dwt_norms[4][10] = { // multiplied by 10000
> > +    {10000, 15000, 27500, 53750, 106800, 213400, 426700, 853300, 1707000, 3413000},
> > +    {10380, 15920, 29190, 57030, 113300, 226400, 452500, 904800, 1809000},
> > +    {10380, 15920, 29190, 57030, 113300, 226400, 452500, 904800, 1809000},
> > +    { 7186,  9218, 15860, 30430,  60190, 120100, 240000, 479700,  959300}};
> >  
> > -    double t = dwt_norms[bandpos][lev] * (1 << bpno);
> > -    return t * t * nmsedec / 8192.0;
> > +    int t = (dwt_norms[bandpos][lev]) * (1 << bpno);
> > +    return (double) t * (double) t * nmsedec;
> >  }
> 
> why is the returned values not int64_t or int?
> same question for the code which uses getwmsedec() ?

The values returned by this function can reach 2^81 (nmsedec - 2^23,
dwt_norms - 2^22, 1<<bpno - 2^7), and they are then summed up for whole
code block [about 20 times], and for whole tile (up to 256 code blocks).
But in some cases the values can be small. So dividing them by a
constant would make, in my opinion, too big precision loss.
Maybe there exists a smart solution, but I don't see it.

[there's something wrong with my school mail server, and i'm now using
gmail; because of that this mail can arrive twice; sorry]

-- 
Best regards,
Kamil Nowosad



More information about the FFmpeg-soc mailing list