Change adjustLastSampleDuration() to getLastSampleDurationVu()

This is a no-op change.

PiperOrigin-RevId: 669283958
This commit is contained in:
sheenachhabra 2024-08-30 04:52:42 -07:00 committed by Copybara-Service
parent dc9854cc5b
commit 613c7a6aa7

View File

@ -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) { */
private static int getLastSampleDurationVu(
List<Integer> sampleDurationsExceptLast,
@Mp4Muxer.LastSampleDurationBehavior int lastSampleDurationBehavior) {
switch (lastSampleDurationBehavior) {
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION:
// For a track having less than 3 samples, duplicating the last frame duration will // For a track having less than 3 samples, duplicating the last frame duration will
// significantly increase the overall track duration, so avoid that. // significantly increase the overall track duration, so avoid that.
if (durationsToBeAdjustedVu.size() <= 2) { return sampleDurationsExceptLast.size() < 2
return; ? 0
} : Iterables.getLast(sampleDurationsExceptLast);
switch (behavior) {
case Mp4Muxer.LAST_SAMPLE_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION:
durationsToBeAdjustedVu.set(
durationsToBeAdjustedVu.size() - 1,
durationsToBeAdjustedVu.get(durationsToBeAdjustedVu.size() - 2));
break;
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);
} }
} }