mirror of
https://github.com/androidx/media.git
synced 2025-05-15 19:49:50 +08:00
Fixed TS+H262 playback when no pts is available
If this situation is encountered, we assume that the encoder has a good reason to do this and use the last pts + frameDuration as new pts. Issue: #1295 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117808961
This commit is contained in:
parent
1ca5378cda
commit
5b06bfd5a8
@ -53,7 +53,7 @@ import java.util.Collections;
|
|||||||
|
|
||||||
// Per packet state that gets reset at the start of each packet.
|
// Per packet state that gets reset at the start of each packet.
|
||||||
private long pesTimeUs;
|
private long pesTimeUs;
|
||||||
private boolean foundFirstFrameInPacket;
|
private boolean pesPtsUsAvailable;
|
||||||
|
|
||||||
// Per sample state that gets reset at the start of each frame.
|
// Per sample state that gets reset at the start of each frame.
|
||||||
private boolean isKeyframe;
|
private boolean isKeyframe;
|
||||||
@ -70,15 +70,17 @@ import java.util.Collections;
|
|||||||
public void seek() {
|
public void seek() {
|
||||||
NalUnitUtil.clearPrefixFlags(prefixFlags);
|
NalUnitUtil.clearPrefixFlags(prefixFlags);
|
||||||
csdBuffer.reset();
|
csdBuffer.reset();
|
||||||
foundFirstFrameInPacket = false;
|
pesPtsUsAvailable = false;
|
||||||
foundFirstFrameInGroup = false;
|
foundFirstFrameInGroup = false;
|
||||||
totalBytesWritten = 0;
|
totalBytesWritten = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void packetStarted(long pesTimeUs, boolean dataAlignmentIndicator) {
|
public void packetStarted(long pesTimeUs, boolean dataAlignmentIndicator) {
|
||||||
|
pesPtsUsAvailable = pesTimeUs != C.UNKNOWN_TIME_US;
|
||||||
|
if (pesPtsUsAvailable) {
|
||||||
this.pesTimeUs = pesTimeUs;
|
this.pesTimeUs = pesTimeUs;
|
||||||
foundFirstFrameInPacket = false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,9 +140,9 @@ import java.util.Collections;
|
|||||||
foundFirstFrameInGroup = false;
|
foundFirstFrameInGroup = false;
|
||||||
isKeyframe = true;
|
isKeyframe = true;
|
||||||
} else /* startCode == START_PICTURE */ {
|
} else /* startCode == START_PICTURE */ {
|
||||||
frameTimeUs = !foundFirstFrameInPacket ? pesTimeUs : (frameTimeUs + frameDurationUs);
|
frameTimeUs = pesPtsUsAvailable ? pesTimeUs : (frameTimeUs + frameDurationUs);
|
||||||
framePosition = totalBytesWritten - bytesWrittenPastStartCode;
|
framePosition = totalBytesWritten - bytesWrittenPastStartCode;
|
||||||
foundFirstFrameInPacket = true;
|
pesPtsUsAvailable = false;
|
||||||
foundFirstFrameInGroup = true;
|
foundFirstFrameInGroup = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
|
|
||||||
private void parseHeaderExtension() {
|
private void parseHeaderExtension() {
|
||||||
pesScratch.setPosition(0);
|
pesScratch.setPosition(0);
|
||||||
timeUs = 0;
|
timeUs = C.UNKNOWN_TIME_US;
|
||||||
if (ptsFlag) {
|
if (ptsFlag) {
|
||||||
pesScratch.skipBits(4); // '0010' or '0011'
|
pesScratch.skipBits(4); // '0010' or '0011'
|
||||||
long pts = (long) pesScratch.readBits(3) << 30;
|
long pts = (long) pesScratch.readBits(3) << 30;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user