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
91b0d55f
authored
Apr 27, 2022
by
ibaker
Committed by
Ian Baker
May 09, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix calculations that may lose precision compared to their target type
PiperOrigin-RevId: 444861268
parent
5d1af646
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
7 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/amr/AmrExtractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/VbriSeeker.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSet.java
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
91b0d55f
...
@@ -1243,7 +1243,7 @@ public final class Util {
...
@@ -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
*
60000
L
;
}
}
return
time
;
return
time
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/amr/AmrExtractor.java
View file @
91b0d55f
...
@@ -412,6 +412,7 @@ public final class AmrExtractor implements Extractor {
...
@@ -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
);
}
}
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
View file @
91b0d55f
...
@@ -1740,9 +1740,9 @@ public class MatroskaExtractor implements Extractor {
...
@@ -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
*
3600
L
*
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
*
60
L
*
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
);
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/VbriSeeker.java
View file @
91b0d55f
...
@@ -89,7 +89,7 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -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
);
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java
View file @
91b0d55f
...
@@ -363,6 +363,7 @@ public final class AdtsExtractor implements Extractor {
...
@@ -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
);
}
}
}
}
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSet.java
View file @
91b0d55f
...
@@ -142,7 +142,8 @@ public final class FakeAdaptiveDataSet extends FakeDataSet {
...
@@ -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
]));
...
...
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