Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tralph committed Mar 6, 2012
1 parent dbb5ffb commit 40c69e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/avformatdecoder.h
Expand Up @@ -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;

Expand Down

0 comments on commit 40c69e1

Please sign in to comment.