Fix H264 transformer test, fix H265 byterange case; re-enable file H262 case

This commit is contained in:
Daniele Sparano 2024-04-16 12:20:42 +01:00 committed by Rohit Singh
parent 3cafb08a32
commit 029b8bad86
4 changed files with 12 additions and 8 deletions

View file

@ -518,8 +518,8 @@ public final class H264Reader implements ElementaryStreamReader {
public void end(long position) { public void end(long position) {
// Output a final sample with the NAL units currently held // Output a final sample with the NAL units currently held
nalUnitStartPosition = position + 1; nalUnitStartPosition = position;
outputSample(/* offset= */ -1); outputSample(/* offset= */ 0);
readingSample = false; readingSample = false;
} }

View file

@ -393,9 +393,12 @@ public final class H265Reader implements ElementaryStreamReader {
} }
public void end(long position) { public void end(long position) {
// Output a final sample with the NAL units currently held // Output a sample with the NAL units since the current nalUnitPosition
nalUnitPosition = position + 1; outputSample(/* offset= */ (int)(position - nalUnitPosition));
outputSample(/* offset= */ -1); // Output a final sample with the remaining NAL units up to the passed position
samplePosition = nalUnitPosition;
nalUnitPosition = position;
outputSample(/* offset= */ 0);
readingSample = false; readingSample = false;
} }

View file

@ -165,14 +165,14 @@ public final class PesReader implements TsPayloadReader {
bytesRead = 0; bytesRead = 0;
} }
public boolean canConsumeDummyEndOfInput() { public boolean canConsumeDummyEndOfInput(boolean isModeHls) {
// Pusi only payload to trigger end of sample data is only applicable if // Pusi only payload to trigger end of sample data is only applicable if
// pes does not have a length field and body is being read, another exclusion // pes does not have a length field and body is being read, another exclusion
// is due to H262 streams possibly having, in HLS mode, a pes across more than one segment // is due to H262 streams possibly having, in HLS mode, a pes across more than one segment
// which would trigger committing an unfinished sample in the middle of the access unit // which would trigger committing an unfinished sample in the middle of the access unit
return state == STATE_READING_BODY return state == STATE_READING_BODY
&& payloadSize == C.LENGTH_UNSET && payloadSize == C.LENGTH_UNSET
&& !(reader instanceof H262Reader); && !(isModeHls && reader instanceof H262Reader);
} }
/** /**

View file

@ -452,7 +452,8 @@ public final class TsExtractor implements Extractor {
TsPayloadReader payloadReader = tsPayloadReaders.valueAt(i); TsPayloadReader payloadReader = tsPayloadReaders.valueAt(i);
if (payloadReader instanceof PesReader) { if (payloadReader instanceof PesReader) {
PesReader pesReader = (PesReader) payloadReader; PesReader pesReader = (PesReader) payloadReader;
if (pesReader.canConsumeDummyEndOfInput()) { boolean isModeHls = (mode == MODE_HLS);
if (pesReader.canConsumeDummyEndOfInput(isModeHls)) {
pesReader.consume(new ParsableByteArray(), FLAG_PAYLOAD_UNIT_START_INDICATOR); pesReader.consume(new ParsableByteArray(), FLAG_PAYLOAD_UNIT_START_INDICATOR);
} }
} }