diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2023-05-11 13:38:56 +0200 |
---|---|---|
committer | Artem Dyomin <artem.dyomin@qt.io> | 2023-05-16 10:36:19 +0200 |
commit | df46a50615136adeac39223953ab7aed393ebd08 (patch) | |
tree | 32814977ba5ae5eb67091793303e02a013cd1e2f /src/plugins/multimedia/ffmpeg/qffmpeg_p.h | |
parent | f23ac51572704e84e12b2765ad0c372c68b96a0b (diff) | |
download | qtmultimedia-df46a50615136adeac39223953ab7aed393ebd08.tar.gz |
Improve getting ffmpeg frame duration
FFmpeg doc says that AVFrame.duration represents the duration
except cases if it's 0 (unknown). It's appeared in only 6.0
so we use a helper to get it.
So let's apply the rule to our AVFrame wrapper.
Pick-to: 6.5
Change-Id: I9596364561f88929796c0097381bfc26bf1d4565
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'src/plugins/multimedia/ffmpeg/qffmpeg_p.h')
-rw-r--r-- | src/plugins/multimedia/ffmpeg/qffmpeg_p.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h index 44fd66cf2..ec927f8b5 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h +++ b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h @@ -20,6 +20,8 @@ extern "C" { (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 91, 100)) // since ffmpeg n4.3 #define QT_FFMPEG_HAS_FRAME_TIME_BASE \ (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 18, 100)) // since ffmpeg n5.0 +#define QT_FFMPEG_HAS_FRAME_DURATION \ + (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 3, 100)) // since ffmpeg n6.0 QT_BEGIN_NAMESPACE @@ -68,7 +70,7 @@ inline void setAVFrameTime(AVFrame &frame, int64_t pts, const AVRational &timeBa #endif } -inline void getAVFrameTime(AVFrame &frame, int64_t &pts, AVRational &timeBase) +inline void getAVFrameTime(const AVFrame &frame, int64_t &pts, AVRational &timeBase) { pts = frame.pts; #if QT_FFMPEG_HAS_FRAME_TIME_BASE @@ -78,6 +80,15 @@ inline void getAVFrameTime(AVFrame &frame, int64_t &pts, AVRational &timeBase) #endif } +inline int64_t getAVFrameDuration(const AVFrame &frame) +{ +#if QT_FFMPEG_HAS_FRAME_DURATION + return frame.duration; +#else + return 0; +#endif +} + struct AVDictionaryHolder { AVDictionary *opts = nullptr; |