Workarounds TS contents with dts moving backwards
Negative duration is not allowed, so set the duration of that sample to an arbitrary small value in case it is needed to decode future samples. Issue #451. Change-Id: I9250d71d163f769ea2657d56e108b6dbd583de67
This commit is contained in:
parent
e071710fa9
commit
33792ca2da
|
@ -304,10 +304,20 @@ bool EsParserH26x::EmitFrame(int64_t access_unit_pos,
|
|||
media_sample->set_dts(current_timing_desc.dts);
|
||||
media_sample->set_pts(current_timing_desc.pts);
|
||||
if (pending_sample_) {
|
||||
DCHECK_GT(media_sample->dts(), pending_sample_->dts());
|
||||
pending_sample_duration_ = media_sample->dts() - pending_sample_->dts();
|
||||
pending_sample_->set_duration(pending_sample_duration_);
|
||||
emit_sample_cb_.Run(pid(), pending_sample_);
|
||||
if (media_sample->dts() <= pending_sample_->dts()) {
|
||||
LOG(WARNING) << "[MPEG-2 TS] PID " << pid() << " dts "
|
||||
<< media_sample->dts()
|
||||
<< " less than or equal to previous dts "
|
||||
<< pending_sample_->dts();
|
||||
// Keep the sample but adjust the sample duration to a very small value,
|
||||
// in case that the sample is still needed for the decoding afterwards.
|
||||
const int64_t kArbitrarySmallDuration = 0.001 * kMpeg2Timescale; // 1ms.
|
||||
pending_sample_->set_duration(kArbitrarySmallDuration);
|
||||
} else {
|
||||
pending_sample_duration_ = media_sample->dts() - pending_sample_->dts();
|
||||
pending_sample_->set_duration(pending_sample_duration_);
|
||||
}
|
||||
emit_sample_cb_.Run(pid(), std::move(pending_sample_));
|
||||
}
|
||||
pending_sample_ = media_sample;
|
||||
|
||||
|
|
Loading…
Reference in New Issue