Remove timestamp clipping in MergingMediaPeriod.TimeOffsetSampleStream

This was done because it was deemed correct to only start at timestamp
zero when the code was originally written. However, in case of
prerolling from a keyframe, many samples will get the same timestamp,
which is not correct and interferes with downstream logic
that deals with timestamps.

PiperOrigin-RevId: 548986160
This commit is contained in:
tonihei 2023-07-18 14:38:05 +01:00 committed by Ian Baker
parent 1b2a2fcde0
commit b0ec2cc701
8 changed files with 145 additions and 146 deletions

View File

@ -16,7 +16,6 @@
package androidx.media3.exoplayer.source;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static java.lang.Math.max;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
@ -461,7 +460,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
FormatHolder formatHolder, DecoderInputBuffer buffer, @ReadFlags int readFlags) {
int readResult = sampleStream.readData(formatHolder, buffer, readFlags);
if (readResult == C.RESULT_BUFFER_READ) {
buffer.timeUs = max(0, buffer.timeUs + timeOffsetUs);
buffer.timeUs = buffer.timeUs + timeOffsetUs;
}
return readResult;
}

View File

@ -494,34 +494,34 @@ MediaCodecAdapter (exotest.video.avc):
flags = 4
contents = length 0, hash 1
input buffer #31:
timeUs = 1000001024000
timeUs = 1000000724000
contents = length 36692, hash D216076E
input buffer #32:
timeUs = 1000001024000
timeUs = 1000000790733
contents = length 5312, hash D45D3CA0
input buffer #33:
timeUs = 1000001024000
timeUs = 1000000757366
contents = length 599, hash 1BE7812D
input buffer #34:
timeUs = 1000001024000
timeUs = 1000000924200
contents = length 7735, hash 4490F110
input buffer #35:
timeUs = 1000001024000
timeUs = 1000000857466
contents = length 987, hash 560B5036
input buffer #36:
timeUs = 1000001024000
timeUs = 1000000824100
contents = length 673, hash ED7CD8C7
input buffer #37:
timeUs = 1000001024000
timeUs = 1000000890833
contents = length 523, hash 3020DF50
input buffer #38:
timeUs = 1000001057666
contents = length 6061, hash 736C72B2
input buffer #39:
timeUs = 1000001024000
timeUs = 1000000990933
contents = length 992, hash FE132F23
input buffer #40:
timeUs = 1000001024000
timeUs = 1000000957566
contents = length 623, hash 5B2C1816
input buffer #41:
timeUs = 1000001024300
@ -674,31 +674,31 @@ MediaCodecAdapter (exotest.video.avc):
size = 568
rendered = true
output buffer #30:
timeUs = 1000001024000
timeUs = 1000000724000
size = 36692
rendered = false
output buffer #31:
timeUs = 1000001024000
timeUs = 1000000790733
size = 5312
rendered = false
output buffer #32:
timeUs = 1000001024000
timeUs = 1000000757366
size = 599
rendered = false
output buffer #33:
timeUs = 1000001024000
timeUs = 1000000924200
size = 7735
rendered = false
output buffer #34:
timeUs = 1000001024000
timeUs = 1000000857466
size = 987
rendered = false
output buffer #35:
timeUs = 1000001024000
timeUs = 1000000824100
size = 673
rendered = false
output buffer #36:
timeUs = 1000001024000
timeUs = 1000000890833
size = 523
rendered = false
output buffer #37:
@ -706,11 +706,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #38:
timeUs = 1000001024000
timeUs = 1000000990933
size = 992
rendered = false
output buffer #39:
timeUs = 1000001024000
timeUs = 1000000957566
size = 623
rendered = false
output buffer #40:

View File

@ -215,34 +215,34 @@ MediaCodecAdapter (exotest.video.avc):
flags = 4
contents = length 0, hash 1
input buffer #8:
timeUs = 1000000800000
timeUs = 1000000500000
contents = length 36692, hash D216076E
input buffer #9:
timeUs = 1000000800000
timeUs = 1000000566733
contents = length 5312, hash D45D3CA0
input buffer #10:
timeUs = 1000000800000
timeUs = 1000000533366
contents = length 599, hash 1BE7812D
input buffer #11:
timeUs = 1000000800000
timeUs = 1000000700200
contents = length 7735, hash 4490F110
input buffer #12:
timeUs = 1000000800000
timeUs = 1000000633466
contents = length 987, hash 560B5036
input buffer #13:
timeUs = 1000000800000
timeUs = 1000000600100
contents = length 673, hash ED7CD8C7
input buffer #14:
timeUs = 1000000800000
timeUs = 1000000666833
contents = length 523, hash 3020DF50
input buffer #15:
timeUs = 1000000833666
contents = length 6061, hash 736C72B2
input buffer #16:
timeUs = 1000000800000
timeUs = 1000000766933
contents = length 992, hash FE132F23
input buffer #17:
timeUs = 1000000800000
timeUs = 1000000733566
contents = length 623, hash 5B2C1816
input buffer #18:
timeUs = 1000000800300
@ -303,31 +303,31 @@ MediaCodecAdapter (exotest.video.avc):
size = 523
rendered = true
output buffer #7:
timeUs = 1000000800000
timeUs = 1000000500000
size = 36692
rendered = false
output buffer #8:
timeUs = 1000000800000
timeUs = 1000000566733
size = 5312
rendered = false
output buffer #9:
timeUs = 1000000800000
timeUs = 1000000533366
size = 599
rendered = false
output buffer #10:
timeUs = 1000000800000
timeUs = 1000000700200
size = 7735
rendered = false
output buffer #11:
timeUs = 1000000800000
timeUs = 1000000633466
size = 987
rendered = false
output buffer #12:
timeUs = 1000000800000
timeUs = 1000000600100
size = 673
rendered = false
output buffer #13:
timeUs = 1000000800000
timeUs = 1000000666833
size = 523
rendered = false
output buffer #14:
@ -335,11 +335,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #15:
timeUs = 1000000800000
timeUs = 1000000766933
size = 992
rendered = false
output buffer #16:
timeUs = 1000000800000
timeUs = 1000000733566
size = 623
rendered = false
output buffer #17:

View File

@ -400,34 +400,34 @@ MediaCodecAdapter (exotest.video.avc):
inputBuffers:
count = 49
input buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
contents = length 36692, hash D216076E
input buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
contents = length 5312, hash D45D3CA0
input buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
contents = length 599, hash 1BE7812D
input buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
contents = length 7735, hash 4490F110
input buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
contents = length 987, hash 560B5036
input buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
contents = length 673, hash ED7CD8C7
input buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
contents = length 523, hash 3020DF50
input buffer #7:
timeUs = 1000000033666
contents = length 6061, hash 736C72B2
input buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
contents = length 992, hash FE132F23
input buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
contents = length 623, hash 5B2C1816
input buffer #10:
timeUs = 1000000000300
@ -550,31 +550,31 @@ MediaCodecAdapter (exotest.video.avc):
outputBuffers:
count = 48
output buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
size = 36692
rendered = false
output buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
size = 5312
rendered = false
output buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
size = 599
rendered = false
output buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
size = 7735
rendered = false
output buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
size = 987
rendered = false
output buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
size = 673
rendered = false
output buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
size = 523
rendered = false
output buffer #7:
@ -582,11 +582,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
size = 992
rendered = false
output buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
size = 623
rendered = false
output buffer #10:

View File

@ -190,34 +190,34 @@ MediaCodecAdapter (exotest.video.avc):
inputBuffers:
count = 26
input buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
contents = length 36692, hash D216076E
input buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
contents = length 5312, hash D45D3CA0
input buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
contents = length 599, hash 1BE7812D
input buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
contents = length 7735, hash 4490F110
input buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
contents = length 987, hash 560B5036
input buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
contents = length 673, hash ED7CD8C7
input buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
contents = length 523, hash 3020DF50
input buffer #7:
timeUs = 1000000033666
contents = length 6061, hash 736C72B2
input buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
contents = length 992, hash FE132F23
input buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
contents = length 623, hash 5B2C1816
input buffer #10:
timeUs = 1000000000300
@ -271,31 +271,31 @@ MediaCodecAdapter (exotest.video.avc):
outputBuffers:
count = 25
output buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
size = 36692
rendered = false
output buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
size = 5312
rendered = false
output buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
size = 599
rendered = false
output buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
size = 7735
rendered = false
output buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
size = 987
rendered = false
output buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
size = 673
rendered = false
output buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
size = 523
rendered = false
output buffer #7:
@ -303,11 +303,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
size = 992
rendered = false
output buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
size = 623
rendered = false
output buffer #10:

View File

@ -183,34 +183,34 @@ MediaCodecAdapter (exotest.video.avc):
inputBuffers:
count = 38
input buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
contents = length 36692, hash D216076E
input buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
contents = length 5312, hash D45D3CA0
input buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
contents = length 599, hash 1BE7812D
input buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
contents = length 7735, hash 4490F110
input buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
contents = length 987, hash 560B5036
input buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
contents = length 673, hash ED7CD8C7
input buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
contents = length 523, hash 3020DF50
input buffer #7:
timeUs = 1000000033666
contents = length 6061, hash 736C72B2
input buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
contents = length 992, hash FE132F23
input buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
contents = length 623, hash 5B2C1816
input buffer #10:
timeUs = 1000000000300
@ -241,34 +241,34 @@ MediaCodecAdapter (exotest.video.avc):
flags = 4
contents = length 0, hash 1
input buffer #19:
timeUs = 1000000300000
timeUs = 1000000000000
contents = length 36692, hash D216076E
input buffer #20:
timeUs = 1000000300000
timeUs = 1000000066733
contents = length 5312, hash D45D3CA0
input buffer #21:
timeUs = 1000000300000
timeUs = 1000000033366
contents = length 599, hash 1BE7812D
input buffer #22:
timeUs = 1000000300000
timeUs = 1000000200200
contents = length 7735, hash 4490F110
input buffer #23:
timeUs = 1000000300000
timeUs = 1000000133466
contents = length 987, hash 560B5036
input buffer #24:
timeUs = 1000000300000
timeUs = 1000000100100
contents = length 673, hash ED7CD8C7
input buffer #25:
timeUs = 1000000300000
timeUs = 1000000166833
contents = length 523, hash 3020DF50
input buffer #26:
timeUs = 1000000333666
contents = length 6061, hash 736C72B2
input buffer #27:
timeUs = 1000000300000
timeUs = 1000000266933
contents = length 992, hash FE132F23
input buffer #28:
timeUs = 1000000300000
timeUs = 1000000233566
contents = length 623, hash 5B2C1816
input buffer #29:
timeUs = 1000000300300
@ -301,31 +301,31 @@ MediaCodecAdapter (exotest.video.avc):
outputBuffers:
count = 36
output buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
size = 36692
rendered = false
output buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
size = 5312
rendered = false
output buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
size = 599
rendered = false
output buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
size = 7735
rendered = false
output buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
size = 987
rendered = false
output buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
size = 673
rendered = false
output buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
size = 523
rendered = false
output buffer #7:
@ -333,11 +333,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
size = 992
rendered = false
output buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
size = 623
rendered = false
output buffer #10:
@ -373,31 +373,31 @@ MediaCodecAdapter (exotest.video.avc):
size = 781
rendered = true
output buffer #18:
timeUs = 1000000300000
timeUs = 1000000000000
size = 36692
rendered = false
output buffer #19:
timeUs = 1000000300000
timeUs = 1000000066733
size = 5312
rendered = false
output buffer #20:
timeUs = 1000000300000
timeUs = 1000000033366
size = 599
rendered = false
output buffer #21:
timeUs = 1000000300000
timeUs = 1000000200200
size = 7735
rendered = false
output buffer #22:
timeUs = 1000000300000
timeUs = 1000000133466
size = 987
rendered = false
output buffer #23:
timeUs = 1000000300000
timeUs = 1000000100100
size = 673
rendered = false
output buffer #24:
timeUs = 1000000300000
timeUs = 1000000166833
size = 523
rendered = false
output buffer #25:
@ -405,11 +405,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #26:
timeUs = 1000000300000
timeUs = 1000000266933
size = 992
rendered = false
output buffer #27:
timeUs = 1000000300000
timeUs = 1000000233566
size = 623
rendered = false
output buffer #28:

View File

@ -190,34 +190,34 @@ MediaCodecAdapter (exotest.video.avc):
inputBuffers:
count = 38
input buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
contents = length 36692, hash D216076E
input buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
contents = length 5312, hash D45D3CA0
input buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
contents = length 599, hash 1BE7812D
input buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
contents = length 7735, hash 4490F110
input buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
contents = length 987, hash 560B5036
input buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
contents = length 673, hash ED7CD8C7
input buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
contents = length 523, hash 3020DF50
input buffer #7:
timeUs = 1000000033666
contents = length 6061, hash 736C72B2
input buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
contents = length 992, hash FE132F23
input buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
contents = length 623, hash 5B2C1816
input buffer #10:
timeUs = 1000000000300
@ -308,31 +308,31 @@ MediaCodecAdapter (exotest.video.avc):
outputBuffers:
count = 36
output buffer #0:
timeUs = 1000000000000
timeUs = 999999700000
size = 36692
rendered = false
output buffer #1:
timeUs = 1000000000000
timeUs = 999999766733
size = 5312
rendered = false
output buffer #2:
timeUs = 1000000000000
timeUs = 999999733366
size = 599
rendered = false
output buffer #3:
timeUs = 1000000000000
timeUs = 999999900200
size = 7735
rendered = false
output buffer #4:
timeUs = 1000000000000
timeUs = 999999833466
size = 987
rendered = false
output buffer #5:
timeUs = 1000000000000
timeUs = 999999800100
size = 673
rendered = false
output buffer #6:
timeUs = 1000000000000
timeUs = 999999866833
size = 523
rendered = false
output buffer #7:
@ -340,11 +340,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #8:
timeUs = 1000000000000
timeUs = 999999966933
size = 992
rendered = false
output buffer #9:
timeUs = 1000000000000
timeUs = 999999933566
size = 623
rendered = false
output buffer #10:

View File

@ -248,34 +248,34 @@ MediaCodecAdapter (exotest.video.avc):
flags = 4
contents = length 0, hash 1
input buffer #19:
timeUs = 1000000800000
timeUs = 1000000500000
contents = length 36692, hash D216076E
input buffer #20:
timeUs = 1000000800000
timeUs = 1000000566733
contents = length 5312, hash D45D3CA0
input buffer #21:
timeUs = 1000000800000
timeUs = 1000000533366
contents = length 599, hash 1BE7812D
input buffer #22:
timeUs = 1000000800000
timeUs = 1000000700200
contents = length 7735, hash 4490F110
input buffer #23:
timeUs = 1000000800000
timeUs = 1000000633466
contents = length 987, hash 560B5036
input buffer #24:
timeUs = 1000000800000
timeUs = 1000000600100
contents = length 673, hash ED7CD8C7
input buffer #25:
timeUs = 1000000800000
timeUs = 1000000666833
contents = length 523, hash 3020DF50
input buffer #26:
timeUs = 1000000833666
contents = length 6061, hash 736C72B2
input buffer #27:
timeUs = 1000000800000
timeUs = 1000000766933
contents = length 992, hash FE132F23
input buffer #28:
timeUs = 1000000800000
timeUs = 1000000733566
contents = length 623, hash 5B2C1816
input buffer #29:
timeUs = 1000000800300
@ -380,31 +380,31 @@ MediaCodecAdapter (exotest.video.avc):
size = 781
rendered = true
output buffer #18:
timeUs = 1000000800000
timeUs = 1000000500000
size = 36692
rendered = false
output buffer #19:
timeUs = 1000000800000
timeUs = 1000000566733
size = 5312
rendered = false
output buffer #20:
timeUs = 1000000800000
timeUs = 1000000533366
size = 599
rendered = false
output buffer #21:
timeUs = 1000000800000
timeUs = 1000000700200
size = 7735
rendered = false
output buffer #22:
timeUs = 1000000800000
timeUs = 1000000633466
size = 987
rendered = false
output buffer #23:
timeUs = 1000000800000
timeUs = 1000000600100
size = 673
rendered = false
output buffer #24:
timeUs = 1000000800000
timeUs = 1000000666833
size = 523
rendered = false
output buffer #25:
@ -412,11 +412,11 @@ MediaCodecAdapter (exotest.video.avc):
size = 6061
rendered = true
output buffer #26:
timeUs = 1000000800000
timeUs = 1000000766933
size = 992
rendered = false
output buffer #27:
timeUs = 1000000800000
timeUs = 1000000733566
size = 623
rendered = false
output buffer #28: