Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
13aaa5a5
authored
Oct 26, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Use C.MICROS_PER_SECOND more consistently.
parent
daa58359
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
library/src/main/java/com/google/android/exoplayer/extractor/mp3/ConstantBitrateSeeker.java
library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java
library/src/main/java/com/google/android/exoplayer/extractor/mp3/VbriSeeker.java
library/src/main/java/com/google/android/exoplayer/extractor/mp3/XingSeeker.java
library/src/main/java/com/google/android/exoplayer/extractor/mp3/ConstantBitrateSeeker.java
View file @
13aaa5a5
...
@@ -22,7 +22,6 @@ import com.google.android.exoplayer.C;
...
@@ -22,7 +22,6 @@ import com.google.android.exoplayer.C;
*/
*/
/* package */
final
class
ConstantBitrateSeeker
implements
Mp3Extractor
.
Seeker
{
/* package */
final
class
ConstantBitrateSeeker
implements
Mp3Extractor
.
Seeker
{
private
static
final
int
MICROSECONDS_PER_SECOND
=
1000000
;
private
static
final
int
BITS_PER_BYTE
=
8
;
private
static
final
int
BITS_PER_BYTE
=
8
;
private
final
long
firstFramePosition
;
private
final
long
firstFramePosition
;
...
@@ -43,12 +42,12 @@ import com.google.android.exoplayer.C;
...
@@ -43,12 +42,12 @@ import com.google.android.exoplayer.C;
@Override
@Override
public
long
getPosition
(
long
timeUs
)
{
public
long
getPosition
(
long
timeUs
)
{
return
durationUs
==
C
.
UNKNOWN_TIME_US
?
0
return
durationUs
==
C
.
UNKNOWN_TIME_US
?
0
:
firstFramePosition
+
(
timeUs
*
bitrate
)
/
(
MICROSECOND
S_PER_SECOND
*
BITS_PER_BYTE
);
:
firstFramePosition
+
(
timeUs
*
bitrate
)
/
(
C
.
MICRO
S_PER_SECOND
*
BITS_PER_BYTE
);
}
}
@Override
@Override
public
long
getTimeUs
(
long
position
)
{
public
long
getTimeUs
(
long
position
)
{
return
((
position
-
firstFramePosition
)
*
MICROSECOND
S_PER_SECOND
*
BITS_PER_BYTE
)
/
bitrate
;
return
((
position
-
firstFramePosition
)
*
C
.
MICRO
S_PER_SECOND
*
BITS_PER_BYTE
)
/
bitrate
;
}
}
@Override
@Override
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java
View file @
13aaa5a5
...
@@ -187,7 +187,7 @@ public final class Mp3Extractor implements Extractor {
...
@@ -187,7 +187,7 @@ public final class Mp3Extractor implements Extractor {
sampleBytesRemaining
=
synchronizedHeader
.
frameSize
;
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.
// Start by draining any buffered bytes, then read directly from the extractor input.
sampleBytesRemaining
-=
inputBuffer
.
drainToOutput
(
trackOutput
,
sampleBytesRemaining
);
sampleBytesRemaining
-=
inputBuffer
.
drainToOutput
(
trackOutput
,
sampleBytesRemaining
);
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp3/VbriSeeker.java
View file @
13aaa5a5
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
com
.
google
.
android
.
exoplayer
.
extractor
.
mp3
;
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.MpegAudioHeader
;
import
com.google.android.exoplayer.util.ParsableByteArray
;
import
com.google.android.exoplayer.util.ParsableByteArray
;
import
com.google.android.exoplayer.util.Util
;
import
com.google.android.exoplayer.util.Util
;
...
@@ -44,8 +45,8 @@ import com.google.android.exoplayer.util.Util;
...
@@ -44,8 +45,8 @@ import com.google.android.exoplayer.util.Util;
return
null
;
return
null
;
}
}
int
sampleRate
=
mpegAudioHeader
.
sampleRate
;
int
sampleRate
=
mpegAudioHeader
.
sampleRate
;
long
durationUs
=
Util
.
scaleLargeTimestamp
(
long
durationUs
=
Util
.
scaleLargeTimestamp
(
numFrames
,
numFrames
,
1000000L
*
(
sampleRate
>=
32000
?
1152
:
576
),
sampleRate
);
C
.
MICROS_PER_SECOND
*
(
sampleRate
>=
32000
?
1152
:
576
),
sampleRate
);
int
numEntries
=
frame
.
readUnsignedShort
();
int
numEntries
=
frame
.
readUnsignedShort
();
int
scale
=
frame
.
readUnsignedShort
();
int
scale
=
frame
.
readUnsignedShort
();
int
entrySize
=
frame
.
readUnsignedShort
();
int
entrySize
=
frame
.
readUnsignedShort
();
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp3/XingSeeker.java
View file @
13aaa5a5
...
@@ -50,7 +50,8 @@ import com.google.android.exoplayer.util.Util;
...
@@ -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.
// If the frame count is missing/invalid, the header can't be used to determine the duration.
return
null
;
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
((
flags
&
0x06
)
!=
0x06
)
{
// If the size in bytes or table of contents is missing, the stream is not seekable.
// If the size in bytes or table of contents is missing, the stream is not seekable.
return
new
XingSeeker
(
inputLength
,
firstFramePosition
,
durationUs
);
return
new
XingSeeker
(
inputLength
,
firstFramePosition
,
durationUs
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment