mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Use C.MICROS_PER_SECOND more consistently.
This commit is contained in:
parent
daa5835915
commit
13aaa5a5db
4 changed files with 8 additions and 7 deletions
|
|
@ -22,7 +22,6 @@ import com.google.android.exoplayer.C;
|
|||
*/
|
||||
/* package */ final class ConstantBitrateSeeker implements Mp3Extractor.Seeker {
|
||||
|
||||
private static final int MICROSECONDS_PER_SECOND = 1000000;
|
||||
private static final int BITS_PER_BYTE = 8;
|
||||
|
||||
private final long firstFramePosition;
|
||||
|
|
@ -43,12 +42,12 @@ import com.google.android.exoplayer.C;
|
|||
@Override
|
||||
public long getPosition(long timeUs) {
|
||||
return durationUs == C.UNKNOWN_TIME_US ? 0
|
||||
: firstFramePosition + (timeUs * bitrate) / (MICROSECONDS_PER_SECOND * BITS_PER_BYTE);
|
||||
: firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeUs(long position) {
|
||||
return ((position - firstFramePosition) * MICROSECONDS_PER_SECOND * BITS_PER_BYTE) / bitrate;
|
||||
return ((position - firstFramePosition) * C.MICROS_PER_SECOND * BITS_PER_BYTE) / bitrate;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public final class Mp3Extractor implements Extractor {
|
|||
sampleBytesRemaining = synchronizedHeader.frameSize;
|
||||
}
|
||||
|
||||
long timeUs = basisTimeUs + (samplesRead * 1000000L / synchronizedHeader.sampleRate);
|
||||
long timeUs = basisTimeUs + (samplesRead * C.MICROS_PER_SECOND / synchronizedHeader.sampleRate);
|
||||
|
||||
// Start by draining any buffered bytes, then read directly from the extractor input.
|
||||
sampleBytesRemaining -= inputBuffer.drainToOutput(trackOutput, sampleBytesRemaining);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.google.android.exoplayer.extractor.mp3;
|
||||
|
||||
import com.google.android.exoplayer.C;
|
||||
import com.google.android.exoplayer.util.MpegAudioHeader;
|
||||
import com.google.android.exoplayer.util.ParsableByteArray;
|
||||
import com.google.android.exoplayer.util.Util;
|
||||
|
|
@ -44,8 +45,8 @@ import com.google.android.exoplayer.util.Util;
|
|||
return null;
|
||||
}
|
||||
int sampleRate = mpegAudioHeader.sampleRate;
|
||||
long durationUs = Util.scaleLargeTimestamp(
|
||||
numFrames, 1000000L * (sampleRate >= 32000 ? 1152 : 576), sampleRate);
|
||||
long durationUs = Util.scaleLargeTimestamp(numFrames,
|
||||
C.MICROS_PER_SECOND * (sampleRate >= 32000 ? 1152 : 576), sampleRate);
|
||||
int numEntries = frame.readUnsignedShort();
|
||||
int scale = frame.readUnsignedShort();
|
||||
int entrySize = frame.readUnsignedShort();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ import com.google.android.exoplayer.util.Util;
|
|||
// If the frame count is missing/invalid, the header can't be used to determine the duration.
|
||||
return null;
|
||||
}
|
||||
long durationUs = Util.scaleLargeTimestamp(frameCount, samplesPerFrame * 1000000L, sampleRate);
|
||||
long durationUs = Util.scaleLargeTimestamp(frameCount, samplesPerFrame * C.MICROS_PER_SECOND,
|
||||
sampleRate);
|
||||
if ((flags & 0x06) != 0x06) {
|
||||
// If the size in bytes or table of contents is missing, the stream is not seekable.
|
||||
return new XingSeeker(inputLength, firstFramePosition, durationUs);
|
||||
|
|
|
|||
Loading…
Reference in a new issue