Adjust timestamp even if frame is dropped.

The `SefSlowMotionVideoSampleTransformer` drops frames by
setting `buffer.data = null` and updates the timestamps of the
frames it keeps. However, these buffers with dropped frames
are still used in the pipeline as they may contain other useful
information, specifically whether the end of the input has been
reached. So, the timestamps should also be updated for the buffers
where frames are dropped.

PiperOrigin-RevId: 410797678
This commit is contained in:
hschlueter 2021-11-18 15:25:38 +00:00 committed by Ian Baker
parent 9e2348f4c3
commit ac8e418f3d

View File

@ -148,8 +148,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
"Missing SVC extension prefix NAL unit."); "Missing SVC extension prefix NAL unit.");
int layer = (scratch[3] & 0xFF) >> 5; int layer = (scratch[3] & 0xFF) >> 5;
boolean shouldKeepFrame = processCurrentFrame(layer, buffer.timeUs); boolean shouldKeepFrame = processCurrentFrame(layer, buffer.timeUs);
if (shouldKeepFrame) { // Update buffer timestamp regardless of whether the frame is dropped because the buffer might
// still be passed to a decoder if it contains an end of stream flag.
buffer.timeUs = getCurrentFrameOutputTimeUs(/* inputTimeUs= */ buffer.timeUs); buffer.timeUs = getCurrentFrameOutputTimeUs(/* inputTimeUs= */ buffer.timeUs);
if (shouldKeepFrame) {
skipToNextNalUnit(data); // Skip over prefix_nal_unit_svc. skipToNextNalUnit(data); // Skip over prefix_nal_unit_svc.
} else { } else {
buffer.data = null; buffer.data = null;