forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use frame pts for ao and fix pts update
- Loading branch information
Showing
4 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -24,7 24,7 @@ | |
#include "utils/Logger.h" | ||
|
||
//ffmpeg2.1 libav10 | ||
#define AVPACKET_REF AV_MODULE_CHECK(LIBAVCODEC, 55, 34, 1 ,39, 101) | ||
#define AVPACKET_REF AV_MODULE_CHECK(LIBAVCODEC, 55, 34, 1, 39, 101) | ||
|
||
namespace QtAV { | ||
namespace { | ||
|
@@ -114,7 114,6 @@ bool Packet::fromAVPacket(Packet* pkt, const AVPacket *avpkt, double time_base) | |
pkt->pts = qMax<qreal>(0, pkt->pts); | ||
pkt->dts = qMax<qreal>(0, pkt->dts); | ||
|
||
|
||
// subtitle always has a key frame? convergence_duration may be 0 | ||
if (avpkt->convergence_duration > 0 // mpv demux_lavf only check this | ||
&& pkt->hasKeyFrame | ||
|
@@ -239,4 238,31 @@ const AVPacket *Packet::asAVPacket() const | |
} | ||
return p; | ||
} | ||
|
||
void Packet::skip(int bytes) | ||
{ | ||
if (!d.constData()) { //not constructed from AVPacket | ||
d = QSharedDataPointer<PacketPrivate>(new PacketPrivate()); | ||
} | ||
d->initialized = false; | ||
data = QByteArray::fromRawData(data.constData() bytes, data.size() - bytes); | ||
if (position >= 0) | ||
position = bytes; | ||
// TODO: if duration is valid, compute pts/dts and no manually update outside? | ||
} | ||
|
||
#ifndef QT_NO_DEBUG_STREAM | ||
QDebug operator<<(QDebug dbg, const Packet &pkt) | ||
{ | ||
dbg.nospace() << "QtAV::Packet.data " << hex << (qptrdiff)pkt.data.constData() << " " << dec << pkt.data.size(); | ||
dbg.nospace() << ", dts: " << pkt.dts; | ||
dbg.nospace() << ", pts: " << pkt.pts; | ||
dbg.nospace() << ", duration: " << pkt.duration; | ||
dbg.nospace() << ", position: " << pkt.position; | ||
dbg.nospace() << ", hasKeyFrame: " << pkt.hasKeyFrame; | ||
dbg.nospace() << ", isCorrupt: " << pkt.isCorrupt; | ||
dbg.nospace() << ", eof: " << pkt.isEOF(); | ||
return dbg.space(); | ||
} | ||
#endif //QT_NO_DEBUG_STREAM | ||
} //namespace QtAV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -55,6 55,12 @@ class Q_AV_EXPORT Packet | |
* Packet takes the owner ship. time unit is always ms even constructed from AVPacket. | ||
*/ | ||
const AVPacket* asAVPacket() const; | ||
/*! | ||
* \brief skip | ||
* Skip bytes of packet data. User has to update pts, dts etc to new values. | ||
* Useful for asAVPakcet(). When asAVPakcet() is called, AVPacket->pts/dts will be updated to new values. | ||
*/ | ||
void skip(int bytes); | ||
|
||
bool hasKeyFrame; | ||
bool isCorrupt; | ||
|
@@ -75,6 81,9 @@ bool Packet::isValid() const | |
return !isCorrupt && !data.isEmpty() && pts >= 0 && duration >= 0; //!data.isEmpty()? | ||
} | ||
|
||
#ifndef QT_NO_DEBUG_STREAM | ||
Q_AV_EXPORT QDebug operator<<(QDebug debug, const Packet &pkt); | ||
#endif | ||
} //namespace QtAV | ||
Q_DECLARE_METATYPE(QtAV::Packet) | ||
#endif // QAV_PACKET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters