Fix calculations that may lose precision compared to their target type
PiperOrigin-RevId: 444861268
This commit is contained in:
parent
5d1af64605
commit
91b0d55fb3
@ -1243,7 +1243,7 @@ public final class Util {
|
|||||||
|
|
||||||
long time = dateTime.getTimeInMillis();
|
long time = dateTime.getTimeInMillis();
|
||||||
if (timezoneShift != 0) {
|
if (timezoneShift != 0) {
|
||||||
time -= timezoneShift * 60000;
|
time -= timezoneShift * 60000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
|
@ -412,6 +412,7 @@ public final class AmrExtractor implements Extractor {
|
|||||||
* @return The stream bitrate.
|
* @return The stream bitrate.
|
||||||
*/
|
*/
|
||||||
private static int getBitrateFromFrameSize(int frameSize, long durationUsPerFrame) {
|
private static int getBitrateFromFrameSize(int frameSize, long durationUsPerFrame) {
|
||||||
return (int) ((frameSize * C.BITS_PER_BYTE * C.MICROS_PER_SECOND) / durationUsPerFrame);
|
return (int)
|
||||||
|
((frameSize * ((long) C.BITS_PER_BYTE) * C.MICROS_PER_SECOND) / durationUsPerFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1740,9 +1740,9 @@ public class MatroskaExtractor implements Extractor {
|
|||||||
checkArgument(timeUs != C.TIME_UNSET);
|
checkArgument(timeUs != C.TIME_UNSET);
|
||||||
byte[] timeCodeData;
|
byte[] timeCodeData;
|
||||||
int hours = (int) (timeUs / (3600 * C.MICROS_PER_SECOND));
|
int hours = (int) (timeUs / (3600 * C.MICROS_PER_SECOND));
|
||||||
timeUs -= (hours * 3600 * C.MICROS_PER_SECOND);
|
timeUs -= (hours * 3600L * C.MICROS_PER_SECOND);
|
||||||
int minutes = (int) (timeUs / (60 * C.MICROS_PER_SECOND));
|
int minutes = (int) (timeUs / (60 * C.MICROS_PER_SECOND));
|
||||||
timeUs -= (minutes * 60 * C.MICROS_PER_SECOND);
|
timeUs -= (minutes * 60L * C.MICROS_PER_SECOND);
|
||||||
int seconds = (int) (timeUs / C.MICROS_PER_SECOND);
|
int seconds = (int) (timeUs / C.MICROS_PER_SECOND);
|
||||||
timeUs -= (seconds * C.MICROS_PER_SECOND);
|
timeUs -= (seconds * C.MICROS_PER_SECOND);
|
||||||
int lastValue = (int) (timeUs / lastTimecodeValueScalingFactor);
|
int lastValue = (int) (timeUs / lastTimecodeValueScalingFactor);
|
||||||
|
@ -89,7 +89,7 @@ import com.google.android.exoplayer2.util.Util;
|
|||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
position += segmentSize * scale;
|
position += segmentSize * ((long) scale);
|
||||||
}
|
}
|
||||||
if (inputLength != C.LENGTH_UNSET && inputLength != position) {
|
if (inputLength != C.LENGTH_UNSET && inputLength != position) {
|
||||||
Log.w(TAG, "VBRI data size mismatch: " + inputLength + ", " + position);
|
Log.w(TAG, "VBRI data size mismatch: " + inputLength + ", " + position);
|
||||||
|
@ -363,6 +363,7 @@ public final class AdtsExtractor implements Extractor {
|
|||||||
* @return The stream bitrate.
|
* @return The stream bitrate.
|
||||||
*/
|
*/
|
||||||
private static int getBitrateFromFrameSize(int frameSize, long durationUsPerFrame) {
|
private static int getBitrateFromFrameSize(int frameSize, long durationUsPerFrame) {
|
||||||
return (int) ((frameSize * C.BITS_PER_BYTE * C.MICROS_PER_SECOND) / durationUsPerFrame);
|
return (int)
|
||||||
|
((frameSize * ((long) C.BITS_PER_BYTE) * C.MICROS_PER_SECOND) / durationUsPerFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,8 @@ public final class FakeAdaptiveDataSet extends FakeDataSet {
|
|||||||
for (int i = 0; i < trackGroup.length; i++) {
|
for (int i = 0; i < trackGroup.length; i++) {
|
||||||
String uri = getUri(i);
|
String uri = getUri(i);
|
||||||
Format format = trackGroup.getFormat(i);
|
Format format = trackGroup.getFormat(i);
|
||||||
double avgChunkLength = format.bitrate * chunkDurationUs / (8 * C.MICROS_PER_SECOND);
|
double avgChunkLength =
|
||||||
|
format.bitrate * chunkDurationUs / ((double) (8 * C.MICROS_PER_SECOND));
|
||||||
FakeData newData = this.newData(uri);
|
FakeData newData = this.newData(uri);
|
||||||
for (int j = 0; j < fullChunks; j++) {
|
for (int j = 0; j < fullChunks; j++) {
|
||||||
newData.appendReadData((int) (avgChunkLength * bitrateFactors[j]));
|
newData.appendReadData((int) (avgChunkLength * bitrateFactors[j]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user