Add HALF_UP rounding TODO to scaleLargeTimestamp (and its usages)

PiperOrigin-RevId: 686921743
This commit is contained in:
ibaker 2024-10-17 08:20:51 -07:00 committed by Copybara-Service
parent 64e0397811
commit 8cb558e875
2 changed files with 4 additions and 0 deletions

View file

@ -1909,6 +1909,8 @@ public final class Util {
* @param divisor The divisor.
* @return The scaled timestamp.
*/
// TODO: b/372204124 - Consider switching this (and impls below) to HALF_UP rounding to reduce
// round-trip errors when switching between time bases with different resolutions.
@UnstableApi
public static long scaleLargeTimestamp(long timestamp, long multiplier, long divisor) {
return scaleLargeValue(timestamp, multiplier, divisor, RoundingMode.DOWN);

View file

@ -1309,6 +1309,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
/** Converts video units to microseconds, using the provided timebase. */
private static long usFromVu(long timestampVu, long videoUnitTimebase) {
// TODO: b/372204124 - Switch to scaleLargeTimestamp when it uses HALF_UP rounding.
return Util.scaleLargeValue(
timestampVu, C.MICROS_PER_SECOND, videoUnitTimebase, RoundingMode.HALF_UP);
}
@ -1908,6 +1909,7 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
/** Converts microseconds to video units, using the provided timebase. */
private static long vuFromUs(long timestampUs, long videoUnitTimebase) {
// TODO: b/372204124 - Switch to scaleLargeTimestamp when it uses HALF_UP rounding.
return Util.scaleLargeValue(
timestampUs, videoUnitTimebase, C.MICROS_PER_SECOND, RoundingMode.HALF_UP);
}