mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Change adjustLastSampleDuration() to getLastSampleDurationVu()
This is a no-op change. PiperOrigin-RevId: 669283958
This commit is contained in:
parent
dc9854cc5b
commit
613c7a6aa7
@ -828,10 +828,9 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
durationsVu.add((int) currentSampleDurationVu);
|
durationsVu.add((int) currentSampleDurationVu);
|
||||||
currentSampleTimeUs = nextSampleTimeUs;
|
currentSampleTimeUs = nextSampleTimeUs;
|
||||||
}
|
}
|
||||||
// Default duration for the last sample.
|
|
||||||
durationsVu.add(0);
|
|
||||||
|
|
||||||
adjustLastSampleDuration(durationsVu, lastSampleDurationBehavior);
|
durationsVu.add(getLastSampleDurationVu(durationsVu, lastSampleDurationBehavior));
|
||||||
|
|
||||||
return durationsVu;
|
return durationsVu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1235,29 +1234,26 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
return timestampVu * 1_000_000L / videoUnitTimebase;
|
return timestampVu * 1_000_000L / videoUnitTimebase;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: b/317117431 - Change this method to getLastSampleDuration().
|
/**
|
||||||
/** Adjusts the duration of the very last sample if needed. */
|
* Returns the duration of the last sample (in video units) based on previous sample durations and
|
||||||
private static void adjustLastSampleDuration(
|
* the {@code lastSampleDurationBehavior}.
|
||||||
List<Integer> durationsToBeAdjustedVu, @Mp4Muxer.LastSampleDurationBehavior int behavior) {
|
*/
|
||||||
// For a track having less than 3 samples, duplicating the last frame duration will
|
private static int getLastSampleDurationVu(
|
||||||
// significantly increase the overall track duration, so avoid that.
|
List<Integer> sampleDurationsExceptLast,
|
||||||
if (durationsToBeAdjustedVu.size() <= 2) {
|
@Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior) {
|
||||||
return;
|
switch (lastSampleDurationBehavior) {
|
||||||
}
|
|
||||||
|
|
||||||
switch (behavior) {
|
|
||||||
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION:
|
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION:
|
||||||
durationsToBeAdjustedVu.set(
|
// For a track having less than 3 samples, duplicating the last frame duration will
|
||||||
durationsToBeAdjustedVu.size() - 1,
|
// significantly increase the overall track duration, so avoid that.
|
||||||
durationsToBeAdjustedVu.get(durationsToBeAdjustedVu.size() - 2));
|
return sampleDurationsExceptLast.size() < 2
|
||||||
break;
|
? 0
|
||||||
|
: Iterables.getLast(sampleDurationsExceptLast);
|
||||||
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE:
|
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_INSERT_SHORT_SAMPLE:
|
||||||
// Keep the last sample duration as short as possible.
|
// Keep the last sample duration as short as possible.
|
||||||
checkState(Iterables.getLast(durationsToBeAdjustedVu) == 0L);
|
return 0;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Unexpected value for the last frame duration behavior " + behavior);
|
"Unexpected value for the last frame duration behavior " + lastSampleDurationBehavior);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user