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
a5ebb49a
authored
Oct 12, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Set the maximum input size based on the sample table for MP4s.
parent
3682141e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
13 deletions
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java
library/src/main/java/com/google/android/exoplayer/extractor/mp4/Mp4Extractor.java
library/src/main/java/com/google/android/exoplayer/extractor/mp4/TrackSampleTable.java
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
View file @
a5ebb49a
...
@@ -643,7 +643,7 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer
...
@@ -643,7 +643,7 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer
adaptiveReconfigurationBytes
);
adaptiveReconfigurationBytes
);
codec
.
queueSecureInputBuffer
(
inputIndex
,
0
,
cryptoInfo
,
presentationTimeUs
,
0
);
codec
.
queueSecureInputBuffer
(
inputIndex
,
0
,
cryptoInfo
,
presentationTimeUs
,
0
);
}
else
{
}
else
{
codec
.
queueInputBuffer
(
inputIndex
,
0
,
bufferSize
,
presentationTimeUs
,
0
);
codec
.
queueInputBuffer
(
inputIndex
,
0
,
bufferSize
,
presentationTimeUs
,
0
);
}
}
inputIndex
=
-
1
;
inputIndex
=
-
1
;
codecHasQueuedBuffers
=
true
;
codecHasQueuedBuffers
=
true
;
...
...
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
View file @
a5ebb49a
...
@@ -205,6 +205,12 @@ public final class MediaFormat {
...
@@ -205,6 +205,12 @@ public final class MediaFormat {
this
.
maxHeight
=
maxHeight
;
this
.
maxHeight
=
maxHeight
;
}
}
public
MediaFormat
copyWithMaxInputSize
(
int
maxInputSize
)
{
return
new
MediaFormat
(
trackId
,
mimeType
,
bitrate
,
maxInputSize
,
durationUs
,
width
,
height
,
rotationDegrees
,
pixelWidthHeightRatio
,
channelCount
,
sampleRate
,
language
,
subsampleOffsetUs
,
initializationData
,
adaptive
,
maxWidth
,
maxHeight
);
}
public
MediaFormat
copyWithMaxVideoDimensions
(
int
maxWidth
,
int
maxHeight
)
{
public
MediaFormat
copyWithMaxVideoDimensions
(
int
maxWidth
,
int
maxHeight
)
{
return
new
MediaFormat
(
trackId
,
mimeType
,
bitrate
,
maxInputSize
,
durationUs
,
width
,
height
,
return
new
MediaFormat
(
trackId
,
mimeType
,
bitrate
,
maxInputSize
,
durationUs
,
width
,
height
,
rotationDegrees
,
pixelWidthHeightRatio
,
channelCount
,
sampleRate
,
language
,
rotationDegrees
,
pixelWidthHeightRatio
,
channelCount
,
sampleRate
,
language
,
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java
View file @
a5ebb49a
...
@@ -106,10 +106,11 @@ import java.util.List;
...
@@ -106,10 +106,11 @@ import java.util.List;
long
[]
offsets
=
new
long
[
sampleCount
];
long
[]
offsets
=
new
long
[
sampleCount
];
int
[]
sizes
=
new
int
[
sampleCount
];
int
[]
sizes
=
new
int
[
sampleCount
];
int
maximumSize
=
0
;
long
[]
timestamps
=
new
long
[
sampleCount
];
long
[]
timestamps
=
new
long
[
sampleCount
];
int
[]
flags
=
new
int
[
sampleCount
];
int
[]
flags
=
new
int
[
sampleCount
];
if
(
sampleCount
==
0
)
{
if
(
sampleCount
==
0
)
{
return
new
TrackSampleTable
(
offsets
,
sizes
,
timestamps
,
flags
);
return
new
TrackSampleTable
(
offsets
,
sizes
,
maximumSize
,
timestamps
,
flags
);
}
}
// Prepare to read chunk offsets.
// Prepare to read chunk offsets.
...
@@ -172,6 +173,9 @@ import java.util.List;
...
@@ -172,6 +173,9 @@ import java.util.List;
for
(
int
i
=
0
;
i
<
sampleCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
sampleCount
;
i
++)
{
offsets
[
i
]
=
offsetBytes
;
offsets
[
i
]
=
offsetBytes
;
sizes
[
i
]
=
fixedSampleSize
==
0
?
stsz
.
readUnsignedIntToInt
()
:
fixedSampleSize
;
sizes
[
i
]
=
fixedSampleSize
==
0
?
stsz
.
readUnsignedIntToInt
()
:
fixedSampleSize
;
if
(
sizes
[
i
]
>
maximumSize
)
{
maximumSize
=
sizes
[
i
];
}
timestamps
[
i
]
=
timestampTimeUnits
+
timestampOffset
;
timestamps
[
i
]
=
timestampTimeUnits
+
timestampOffset
;
// All samples are synchronization samples if the stss is not present.
// All samples are synchronization samples if the stss is not present.
...
@@ -244,7 +248,7 @@ import java.util.List;
...
@@ -244,7 +248,7 @@ import java.util.List;
Assertions
.
checkArgument
(
remainingSamplesInChunk
==
0
);
Assertions
.
checkArgument
(
remainingSamplesInChunk
==
0
);
Assertions
.
checkArgument
(
remainingTimestampDeltaChanges
==
0
);
Assertions
.
checkArgument
(
remainingTimestampDeltaChanges
==
0
);
Assertions
.
checkArgument
(
remainingTimestampOffsetChanges
==
0
);
Assertions
.
checkArgument
(
remainingTimestampOffsetChanges
==
0
);
return
new
TrackSampleTable
(
offsets
,
sizes
,
timestamps
,
flags
);
return
new
TrackSampleTable
(
offsets
,
sizes
,
maximumSize
,
timestamps
,
flags
);
}
}
/**
/**
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp4/Mp4Extractor.java
View file @
a5ebb49a
...
@@ -262,7 +262,10 @@ public final class Mp4Extractor implements Extractor, SeekMap {
...
@@ -262,7 +262,10 @@ public final class Mp4Extractor implements Extractor, SeekMap {
}
}
Mp4Track
mp4Track
=
new
Mp4Track
(
track
,
trackSampleTable
,
extractorOutput
.
track
(
i
));
Mp4Track
mp4Track
=
new
Mp4Track
(
track
,
trackSampleTable
,
extractorOutput
.
track
(
i
));
mp4Track
.
trackOutput
.
format
(
track
.
mediaFormat
);
// Each sample has up to three bytes of overhead for the start code that replaces its length.
// Allow ten source samples per output sample, like the platform extractor.
int
maxInputSize
=
trackSampleTable
.
maximumSize
+
3
*
10
;
mp4Track
.
trackOutput
.
format
(
track
.
mediaFormat
.
copyWithMaxInputSize
(
maxInputSize
));
tracks
.
add
(
mp4Track
);
tracks
.
add
(
mp4Track
);
long
firstSampleOffset
=
trackSampleTable
.
offsets
[
0
];
long
firstSampleOffset
=
trackSampleTable
.
offsets
[
0
];
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp4/TrackSampleTable.java
View file @
a5ebb49a
...
@@ -19,31 +19,49 @@ import com.google.android.exoplayer.C;
...
@@ -19,31 +19,49 @@ import com.google.android.exoplayer.C;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
import
com.google.android.exoplayer.util.Util
;
/** Sample table for a track in an MP4 file. */
/**
* Sample table for a track in an MP4 file.
*/
/* package */
final
class
TrackSampleTable
{
/* package */
final
class
TrackSampleTable
{
/** Sample index when no sample is available. */
/**
* Sample index when no sample is available.
*/
public
static
final
int
NO_SAMPLE
=
-
1
;
public
static
final
int
NO_SAMPLE
=
-
1
;
/** Number of samples. */
/**
* Number of samples.
*/
public
final
int
sampleCount
;
public
final
int
sampleCount
;
/** Sample offsets in bytes. */
/**
* Sample offsets in bytes.
*/
public
final
long
[]
offsets
;
public
final
long
[]
offsets
;
/** Sample sizes in bytes. */
/**
* Sample sizes in bytes.
*/
public
final
int
[]
sizes
;
public
final
int
[]
sizes
;
/** Sample timestamps in microseconds. */
/**
* Maximum sample size in {@link #sizes}.
*/
public
final
int
maximumSize
;
/**
* Sample timestamps in microseconds.
*/
public
final
long
[]
timestampsUs
;
public
final
long
[]
timestampsUs
;
/** Sample flags. */
/**
* Sample flags.
*/
public
final
int
[]
flags
;
public
final
int
[]
flags
;
TrackSampleTable
(
TrackSampleTable
(
long
[]
offsets
,
int
[]
sizes
,
int
maximumSize
,
long
[]
timestampsUs
,
int
[]
flags
)
{
long
[]
offsets
,
int
[]
sizes
,
long
[]
timestampsUs
,
int
[]
flags
)
{
Assertions
.
checkArgument
(
sizes
.
length
==
timestampsUs
.
length
);
Assertions
.
checkArgument
(
sizes
.
length
==
timestampsUs
.
length
);
Assertions
.
checkArgument
(
offsets
.
length
==
timestampsUs
.
length
);
Assertions
.
checkArgument
(
offsets
.
length
==
timestampsUs
.
length
);
Assertions
.
checkArgument
(
flags
.
length
==
timestampsUs
.
length
);
Assertions
.
checkArgument
(
flags
.
length
==
timestampsUs
.
length
);
this
.
offsets
=
offsets
;
this
.
offsets
=
offsets
;
this
.
sizes
=
sizes
;
this
.
sizes
=
sizes
;
this
.
maximumSize
=
maximumSize
;
this
.
timestampsUs
=
timestampsUs
;
this
.
timestampsUs
=
timestampsUs
;
this
.
flags
=
flags
;
this
.
flags
=
flags
;
sampleCount
=
offsets
.
length
;
sampleCount
=
offsets
.
length
;
...
...
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