Public bug reported:

I found a bug with the function av_rescale_q() in the latest versions on
Precise LTS & Lucid LTS on amd64 processor.

Below is my test code (to be linked against libavutilXX):
uint64_t av_rescale_q_test(uint64_t a, AVRational b, AVRational c)
{
        uint64_t num = b.num * c.den;
        uint64_t den = b.den * c.num;
        return ( a * num + (den>>1)) / den;
}

void test()
{
        uint64_t out, out2, pts=30305290;
        AVRational base = { 1, 14112000};
        AVRational bq = { 1, 1000000000};

        out = av_rescale_q(pts, base, bq);
        out2 = av_rescale_q_test(pts, base, bq);
        printf("pts=0x%lX, out=0x%lX, out2=0x%lX\n", pts, out, out2);    
}


And the output is: 
pts=0x1CE6C0A, out=0xFFFFFFFF80000036, out2=0x80000036

Obviously av_rescale_q() gives wrong answer.


The interesting thing is: if I pull the source code of av_rescale_q() and all 
the invoked functions together from libav into my test code, the result becomes:
pts=0x1CE6C0A, out=0x80000036, out2=0x80000036

Looks like the libav sourcecode itself is OK, but the built library is
buggy. I have no idea how to further debug this problem. Somebody please
look into this bug. I believe it could be reappeared on all amd64
distros including Lucid/Precie/Quantal.

** Affects: libav (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "Test snippet"
   
https://bugs.launchpad.net/bugs/1159760/+attachment/3595858/+files/avutil-test.tar.bz2

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1159760

Title:
  av_rescale_q() returns wrong value on Precise amd64

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libav/+bug/1159760/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to