mirror of
https://github.com/samsonjs/media.git
synced 2026-04-20 13:45:47 +00:00
Timestamp HEVC samples based on the first NALU's timestamp.
Issue: #893
This commit is contained in:
parent
c0a81e1138
commit
daa5835915
1 changed files with 9 additions and 7 deletions
|
|
@ -120,7 +120,7 @@ import java.util.Collections;
|
|||
|
||||
// Indicate the start of the next NAL unit.
|
||||
int nalUnitType = NalUnitUtil.getH265NalUnitType(dataArray, nalUnitOffset);
|
||||
startNalUnit(absolutePosition, bytesWrittenPastPosition, nalUnitType);
|
||||
startNalUnit(absolutePosition, bytesWrittenPastPosition, nalUnitType, pesTimeUs);
|
||||
// Continue scanning the data.
|
||||
offset = nalUnitOffset + 3;
|
||||
} else {
|
||||
|
|
@ -136,7 +136,7 @@ import java.util.Collections;
|
|||
// Do nothing.
|
||||
}
|
||||
|
||||
private void startNalUnit(long position, int offset, int nalUnitType) {
|
||||
private void startNalUnit(long position, int offset, int nalUnitType, long pesTimeUs) {
|
||||
if (!hasOutputFormat) {
|
||||
vps.startNalUnit(nalUnitType);
|
||||
sps.startNalUnit(nalUnitType);
|
||||
|
|
@ -144,7 +144,7 @@ import java.util.Collections;
|
|||
}
|
||||
prefixSei.startNalUnit(nalUnitType);
|
||||
suffixSei.startNalUnit(nalUnitType);
|
||||
sampleReader.startNalUnit(position, offset, nalUnitType);
|
||||
sampleReader.startNalUnit(position, offset, nalUnitType, pesTimeUs);
|
||||
}
|
||||
|
||||
private void nalUnitData(byte[] dataArray, int offset, int limit) {
|
||||
|
|
@ -161,7 +161,7 @@ import java.util.Collections;
|
|||
|
||||
private void nalUnitEnd(long position, int offset, int discardPadding, long pesTimeUs) {
|
||||
if (hasOutputFormat) {
|
||||
sampleReader.endNalUnit(position, offset, pesTimeUs);
|
||||
sampleReader.endNalUnit(position, offset);
|
||||
} else {
|
||||
vps.endNalUnit(discardPadding);
|
||||
sps.endNalUnit(discardPadding);
|
||||
|
|
@ -377,6 +377,7 @@ import java.util.Collections;
|
|||
private long nalUnitStartPosition;
|
||||
private boolean nalUnitHasKeyframeData;
|
||||
private int nalUnitBytesRead;
|
||||
private long nalUnitTimeUs;
|
||||
private boolean lookingForFirstSliceFlag;
|
||||
private boolean firstSliceFlag;
|
||||
|
||||
|
|
@ -396,8 +397,9 @@ import java.util.Collections;
|
|||
readingSample = false;
|
||||
}
|
||||
|
||||
public void startNalUnit(long position, int offset, int nalUnitType) {
|
||||
public void startNalUnit(long position, int offset, int nalUnitType, long pesTimeUs) {
|
||||
firstSliceFlag = false;
|
||||
nalUnitTimeUs = pesTimeUs;
|
||||
nalUnitBytesRead = 0;
|
||||
nalUnitStartPosition = position;
|
||||
// Flush the previous sample when reading a non-VCL NAL unit.
|
||||
|
|
@ -422,7 +424,7 @@ import java.util.Collections;
|
|||
}
|
||||
}
|
||||
|
||||
public void endNalUnit(long position, int offset, long timeUs) {
|
||||
public void endNalUnit(long position, int offset) {
|
||||
if (firstSliceFlag) {
|
||||
// If the NAL unit ending is the start of a new sample, output the previous one.
|
||||
if (readingSample) {
|
||||
|
|
@ -430,7 +432,7 @@ import java.util.Collections;
|
|||
outputSample(offset + nalUnitLength);
|
||||
}
|
||||
samplePosition = nalUnitStartPosition;
|
||||
sampleTimeUs = timeUs;
|
||||
sampleTimeUs = nalUnitTimeUs;
|
||||
readingSample = true;
|
||||
sampleIsKeyframe = nalUnitHasKeyframeData;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue