Omit clipped samples when applying edits for audio tracks.
Issue: #2408 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146389955
This commit is contained in:
parent
537a3ab5be
commit
c82319332f
@ -332,6 +332,9 @@ import java.util.List;
|
|||||||
return new TrackSampleTable(offsets, sizes, maximumSize, timestamps, flags);
|
return new TrackSampleTable(offsets, sizes, maximumSize, timestamps, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Omit any sample at the end point of an edit for audio tracks.
|
||||||
|
boolean omitClippedSample = track.type == C.TRACK_TYPE_AUDIO;
|
||||||
|
|
||||||
// Count the number of samples after applying edits.
|
// Count the number of samples after applying edits.
|
||||||
int editedSampleCount = 0;
|
int editedSampleCount = 0;
|
||||||
int nextSampleIndex = 0;
|
int nextSampleIndex = 0;
|
||||||
@ -342,7 +345,8 @@ import java.util.List;
|
|||||||
long duration = Util.scaleLargeTimestamp(track.editListDurations[i], track.timescale,
|
long duration = Util.scaleLargeTimestamp(track.editListDurations[i], track.timescale,
|
||||||
track.movieTimescale);
|
track.movieTimescale);
|
||||||
int startIndex = Util.binarySearchCeil(timestamps, mediaTime, true, true);
|
int startIndex = Util.binarySearchCeil(timestamps, mediaTime, true, true);
|
||||||
int endIndex = Util.binarySearchCeil(timestamps, mediaTime + duration, true, false);
|
int endIndex = Util.binarySearchCeil(timestamps, mediaTime + duration, omitClippedSample,
|
||||||
|
false);
|
||||||
editedSampleCount += endIndex - startIndex;
|
editedSampleCount += endIndex - startIndex;
|
||||||
copyMetadata |= nextSampleIndex != startIndex;
|
copyMetadata |= nextSampleIndex != startIndex;
|
||||||
nextSampleIndex = endIndex;
|
nextSampleIndex = endIndex;
|
||||||
@ -365,7 +369,7 @@ import java.util.List;
|
|||||||
long endMediaTime = mediaTime + Util.scaleLargeTimestamp(duration, track.timescale,
|
long endMediaTime = mediaTime + Util.scaleLargeTimestamp(duration, track.timescale,
|
||||||
track.movieTimescale);
|
track.movieTimescale);
|
||||||
int startIndex = Util.binarySearchCeil(timestamps, mediaTime, true, true);
|
int startIndex = Util.binarySearchCeil(timestamps, mediaTime, true, true);
|
||||||
int endIndex = Util.binarySearchCeil(timestamps, endMediaTime, true, false);
|
int endIndex = Util.binarySearchCeil(timestamps, endMediaTime, omitClippedSample, false);
|
||||||
if (copyMetadata) {
|
if (copyMetadata) {
|
||||||
int count = endIndex - startIndex;
|
int count = endIndex - startIndex;
|
||||||
System.arraycopy(offsets, startIndex, editedOffsets, sampleIndex, count);
|
System.arraycopy(offsets, startIndex, editedOffsets, sampleIndex, count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user