Simplify CalculateFrameShift() - #1161
Conversation
|
Thank you. We're going to wait until after the 19.8 release to merge this. If possible could you please update the code comment to give a full bibliographic reference for the citation. Ideally with a succinct (few-line) explanation and/or proof of what properties the shift value needs to have and why this calculation satisfies the properties. |
|
Thanks for the contribution and the links to the papers. I like simpler code. I wrote a little C program to verify that the new code gives the same result as the old code for M,N between 1 to 10000. // #include <stdlib.h> #define PA_MIN_( a, b ) ( ((a)<(b)) ? (a) : (b) ) /* greatest common divisor */ /* least common multiple - PPCM in French / #define PA_MAX_( a, b ) (((a) > (b)) ? (a) : (b)) static unsigned long CalculateFrameShiftOld( unsigned long M, unsigned long N ) } static unsigned long CalculateFrameShiftNew( unsigned long M, unsigned long N ) int main(int argc, const char * argv[]) { error: |
Sure, no problem, this is not urgent. I'm looking forward to the new 19.8 release!
done: 77def5d
I don't think it's possible to summarize it meaningfully in a few lines. The proof in the paper has been criticized for being too long, but even the suggested alternative proof sketch is too long to put it into a comment in the source code (see https://lists.linuxaudio.org/hyperkitty/list/linux-audio-dev@lists.linuxaudio.org/thread/LAW4I4EQS6QTUCFE33PVRLQF6DPEEKOS/). |
The explanation/proof for why that formula is correct is in the referenced paper: https://lac2026.sciencesconf.org/722511
The paper also provides a comparison to the previous implementation, which is described here: https://hal.science/hal-02158912v1
The code was not wrong before, it's now just simpler (and needs fewer computations, but that's probably not really relevant in this case).