#define DEMUXER_SEQ_HEAD 0xB3010000
#endif
-
+#define SEEK_THRESHOLD 150000 // About 1.5 seconds
const int Demuxer::FrameRates[9] = { 0, 23, 24, 25, 29, 30, 50, 59, 60 };
if ( !videostream.init(video, demuxMemoryV) ||
!audiostream.init(audio, demuxMemoryA))
{
- Log::getInstance()->log("Demuxer", Log::CRIT, "Failed to initialize demuxer");
+ Log::getInstance()->log("Demuxer", Log::CRIT,
+ "Failed to initialize demuxer");
shutdown();
return 0;
}
{
if (aspect_ratio != ar)
{
- Log::getInstance()->log("Demux", Log::DEBUG, "Aspect ratio difference signalled");
+ Log::getInstance()->log("Demux", Log::DEBUG,
+ "Aspect ratio difference signalled");
if (++arcnt > 3) // avoid changing aspect ratio if glitch in signal
{
arcnt = 0;
#ifndef NEW_DEMUXER
sent = dx->videostream.put(data+submitted, size-submitted);
#else
- sent = dx->videostream.put(data+submitted, size-submitted,cur_pos);
+ sent = dx->videostream.put(data+submitted, size-submitted,cur_pos);
#endif
else
sent = size-submitted;
// Extract audio PTS if it exists
if ( data[7] & 0x80 ) // PTS_DTS_flags indicate that PTS is present
{
- dx->audio_pts = ( (ULLONG)(data[9] & 0x0E) << 29 ) |
+ dx->audio_pts = ( (ULLONG)(data[9] & 0x0E) << 29 ) |
( (ULLONG)(data[10]) << 22 ) |
( (ULLONG)(data[11] & 0xFE) << 14 ) |
( (ULLONG)(data[12]) << 7 ) |
( (ULLONG)(data[13] & 0xFE) >> 1 );
+
+ // We continue to seek on the audio if the video PTS that we
+ // are trying to match is ahead of the audio PTS by at most
+ // SEEK_THRESHOLD. We consider the possibility of PTS wrap.
if (dx->aud_seeking && !dx->vid_seeking &&
- dx->audio_pts >= dx->video_pts_seek)
+ !( (dx->video_pts_seek > dx->audio_pts &&
+ dx->video_pts_seek - dx->audio_pts < SEEK_THRESHOLD)
+ ||
+ (dx->video_pts_seek < dx->audio_pts &&
+ dx->video_pts_seek + (1LL<<33) -
+ dx->audio_pts < SEEK_THRESHOLD) ))
{
dx->aud_seeking = 0;
Log::getInstance()->log("Demuxer", Log::DEBUG,
// Extract video PTS if it exists
if ( data[7] & 0x80 ) // PTS_DTS_flags indicate that PTS is present
{
- dx->video_pts = ( (ULLONG)(data[9] & 0x0E) << 29 ) |
+ dx->video_pts = ( (ULLONG)(data[9] & 0x0E) << 29 ) |
( (ULLONG)(data[10]) << 22 ) |
( (ULLONG)(data[11] & 0xFE) << 14 ) |
( (ULLONG)(data[12]) << 7 ) |
class Demuxer
{
-public: //MS Visual C++ need this, private does not work for DemuxerVDR, Marten
+protected:
class PESPacket
{
public:
#ifndef NEW_DEMUXER
int submit();
#else
- int submit(ULLONG cur_pos);
+ int submit(ULLONG cur_pos);
#endif
private:
UCHAR data[0x10000];
#ifndef NEW_DEMUXER
virtual int put(UCHAR* buf, int len) = 0;
#else
- virtual int put(UCHAR* buf, int len,ULLONG cur_pos) = 0;
+ virtual int put(UCHAR* buf, int len,ULLONG cur_pos) = 0;
#endif
int getHorizontalSize() { return horizontal_size; }