summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Ralph <tralph@mythtv.org>2012-03-06 01:00:40 (GMT)
committer Taylor Ralph <tralph@mythtv.org>2012-03-06 01:00:40 (GMT)
commit40c69e1c48a51d9061a01e5041b4ad88ce73d862 (patch)
treee67e318a07876bb475013e578bd92ea64aeba1c1
parentdbb5ffb20709fd5554e7eacdbfb4d36af764aa80 (diff)
AvFormatDecoder: add FORCE_DTS_TIMESTAMPS environment variable
This allows a user to force the player to use video dts timestamps for av-sync purposes in the event they have material with busted pts timestamps.
-rw-r--r--mythtv/libs/libmythtv/avformatdecoder.cpp18
-rw-r--r--mythtv/libs/libmythtv/avformatdecoder.h2
2 files changed, 16 insertions, 4 deletions
diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
index 9535c1c..4a01e14 100644
--- a/mythtv/libs/libmythtv/avformatdecoder.cpp
+++ b/mythtv/libs/libmythtv/avformatdecoder.cpp
@@ -283,6 +283,7 @@ AvFormatDecoder::AvFormatDecoder(MythPlayer *parent,
pts_detected(false),
reordered_pts_detected(false),
pts_selected(true),
+ force_dts_timestamps(false),
playerFlags(flags),
video_codec_id(kCodec_NONE),
maxkeyframedist(-1),
@@ -1104,6 +1105,9 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
.arg(framenum));
}
+ if (getenv("FORCE_DTS_TIMESTAMPS"))
+ force_dts_timestamps = true;
+
// Return true if recording has position map
return recordingHasPositionMap;
}
@@ -3088,7 +3092,13 @@ bool AvFormatDecoder::ProcessVideoPacket(AVStream *curstream, AVPacket *pkt)
// the DTS timestamp is missing. Also use fixups for missing PTS instead of
// DTS to avoid oscillating between PTS and DTS. Only select DTS if PTS is
// more faulty or never detected.
- if (ringBuffer->IsDVD())
+ if (force_dts_timestamps)
+ {
+ if (pkt->dts != (int64_t)AV_NOPTS_VALUE)
+ pts = pkt->dts;
+ pts_selected = false;
+ }
+ else if (ringBuffer->IsDVD())
{
if (pkt->dts != (int64_t)AV_NOPTS_VALUE)
pts = pkt->dts;
@@ -3113,10 +3123,10 @@ bool AvFormatDecoder::ProcessVideoPacket(AVStream *curstream, AVPacket *pkt)
}
LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_DEBUG, LOC +
- QString("video packet timestamps reordered %1 pts %2 dts %3 (%4 "
- "active)")
+ QString("video packet timestamps reordered %1 pts %2 dts %3 (%4)")
.arg(mpa_pic.reordered_opaque).arg(pkt->pts).arg(pkt->dts)
- .arg((pts_selected) ? "reordered" : "dts"));
+ .arg((force_dts_timestamps) ? "dts forced" :
+ (pts_selected) ? "reordered" : "dts"));
mpa_pic.reordered_opaque = pts;
diff --git a/mythtv/libs/libmythtv/avformatdecoder.h b/mythtv/libs/libmythtv/avformatdecoder.h
index b4f0fcf..f236ec9 100644
--- a/mythtv/libs/libmythtv/avformatdecoder.h
+++ b/mythtv/libs/libmythtv/avformatdecoder.h
@@ -308,6 +308,8 @@ class AvFormatDecoder : public DecoderBase
bool reordered_pts_detected;
bool pts_selected;
+ bool force_dts_timestamps;
+
PlayerFlags playerFlags;
MythCodecID video_codec_id;