You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.jitsi.util.RTPUtils.sequenceNumberDiff(...)
line 34
incorrect: diff > 1<<15
problem : 1<<15 is not in the short range (-2^15 .. 2^15 - 1)
correct : diff >= 1<<15
The text was updated successfully, but these errors were encountered:
Well, if the difference between two sequence numbers is exactly 2^15, then we don't know which one comes first. I think both 2^15 and -2^15 are reasonable values to return, and I don't know of a requirement for the return value to be in the short range.
Casted back to an short leads to the same result anyway (2^15 -> -2^15). I do not know if its matter, but since the two inputs are in (-2^15 .. 2^15 - 1), I thought it would be more consistent if the computed value lays in the same range (unique representative modulo 2^16). Note that the docu says "modulo 2^16", without specifying the range (which is not ambiguous in C with uint16_t). That the inputs are also "modulo 2^16" is not explicitly stated neither, but otherwise the code does not make much sense.
I suggest this simpler implementation, which I had in mind as I opened this ticket:
public static short sequenceNumberDiff_loic(short a, short b) {
return (short) (a - b);
}
Then it is clear what "modulo 2^16" means. It is (up to the handling of 2^15) equivalent to the original code, shorter and possibly faster. I even question if a function is needed for that.
Up to you judgment to adapt the code and/or the documentation, it is not critical in my opinion.
The text was updated successfully, but these errors were encountered: