subLength = 0;
tID = p_tID;
havechannelinfo=false;
+ doubledframerate=false;
+ framereserve=0;
}
void DemuxerTS::flush()
subActive = false;
subLength = 0;
tActive = false;
+ doubledframerate=false;
+ framereserve=0;
}
int DemuxerTS::scan(UCHAR *buf, int len)
{
frameCounting = true;
frameNumber = frame;
+ framereserve=0;
Log::getInstance()->log("DemuxerTS", Log::DEBUG, "setFrameNum %d", frame);
}
while (iter != pts_map.end())
{
++total;
+ //Log::getInstance()->log("DemuxerTS", Log::DEBUG, "getFrameNumfromPTS pts1 %lld pts2 %lld", pts, iter->pts);
if (PTSDifference(iter->pts, pts) < PTS_ALLOWANCE)
{
difference = 0;
pts_map.erase(iter, pts_map.end());
}
pts_map_mutex.Unlock();
+
+ //Log::getInstance()->log("DemuxerTS", Log::DEBUG, "getFrameNumfromPTS pts %lld deleted %d difference %lld", pts, total,difference);
if (difference == (1LL<<33))
return 0; // We cannot make sense of the pts
{
packetNumber++;
}
- UINT numpicts=packet.countPictureHeaders(h264);
+ UINT pictsinpacket=packet.countPictureHeaders(h264);
+
+ UINT numpicts=0;
+ if (!doubledframerate)
+ {
+ numpicts=pictsinpacket;
+ }
+ else
+ {
+ numpicts=(pictsinpacket+framereserve)>>1;
+ framereserve=(pictsinpacket+framereserve)%2;
+ }
+
if (frameCounting && numpicts &&
packet.getPacketType() >= PESTYPE_VID0 &&
pts_map_mutex.Unlock();
//UINT fps = Video::getInstance()->getFPS();
- ULLONG pts_expected = me.pts + 90000*((int)(((double)(frame_num - me.frame)) / fps));
+ double tfps=fps;
+ if (doubledframerate) tfps*=2.;
+ ULLONG pts_expected = me.pts + 90000*((int)(((double)(frame_num - me.frame)) / tfps));
while (pts_expected > (1LL<<33)) pts_expected -= (1LL<<33);
+ if (!doubledframerate
+ &&(abs(PTSDistance(pts_expected, packet.getPTS())-1800) <= 1
+ || abs(PTSDistance(pts_expected, packet.getPTS())-1501) <= 1)) {
+ doubledframerate=true; //Detected p50 or p60
+ }
+
if (PTSDistance(pts_expected, packet.getPTS()) > PTS_JUMP_MARGIN) // PTS jump!
{
me.pts = packet.getPTS();
int getAID() { return aID; }
int getSubID() { return subID; }
int put(UCHAR* buf, int len);
- int PMTPID; //TODO HANS which of these do I Need:
+
void setFrameNum(ULONG frame);
void setPacketNum(ULONG npacket);
ULONG getFrameNumFromPTS(ULLONG pts);
PESPacket subPacket; // Subtitles PES packet under construction
PESPacket tPacket; // Teletext PES packet under construction
int vID, aID, subID,tID; // TS IDs for video/audio/subtitles
+ int PMTPID; //TODO HANS which of these do I Need:
int atype;
bool subActive; // Same for subtitles
//TODO HANS which of next do I need
ULONG frameNumber, packetNumber;
bool frameCounting, packetCounting;
+ bool doubledframerate;
+ int framereserve;
typedef struct { ULLONG pts; ULONG frame; } PTSMapEntry;
typedef std::deque<PTSMapEntry> PTSMap;
PTSMap pts_map;