diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2019-09-19 14:46:12 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2019-09-19 16:12:53 +0300 |
commit | fba35aa8c5cdedb3132b286874c5185c59af35a2 (patch) | |
tree | fa86a8fff40462b25b4f029a440bba7ed51fdd04 /intern | |
parent | 1e09dd094b0187ef7b7b202154bc810dc1479034 (diff) |
Use FFmpeg's own `av_guess_frame_rate()` function instead of guessing ourselves
This was introduced in FFmpeg lavf 55.1.100 in 2013. For systems that are
still on LibAV or older FFmpeg there is a fallback implementation that
performs the same guess as we did before in `av_get_r_frame_rate_compat()`.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ffmpeg/ffmpeg_compat.h | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index d254fa76ba9..123e18430a9 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -528,35 +528,21 @@ bool av_check_encoded_with_ffmpeg(AVFormatContext *ctx) return false; } -FFMPEG_INLINE -AVRational av_get_r_frame_rate_compat(AVFormatContext *ctx, const AVStream *stream) +/* Libav doesn't have av_guess_frame_rate(). + * It was introduced in FFmpeg's lavf 55.1.100. */ +#ifdef AV_USING_LIBAV +AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame) { - /* If the video is encoded with FFmpeg and we are decoding with FFmpeg - * as well it seems to be more reliable to use r_frame_rate (tbr). - * - * For other cases we fall back to avg_frame_rate (fps) when possible. - */ -#ifdef AV_USING_FFMPEG - if (av_check_encoded_with_ffmpeg(ctx)) { - return stream->r_frame_rate; - } -#endif - -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 23, 1) - /* For until r_frame_rate was deprecated use it. */ + (void)ctx; + (void)frame; +# if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 23, 1) + /* For until r_frame_rate was deprecated (in Libav) use it. */ return stream->r_frame_rate; -#else -# ifdef AV_USING_FFMPEG - /* Some of the videos might have average frame rate set to, while the - * r_frame_rate will show a correct value. This happens, for example, for - * OGG video files saved with Blender. */ - if (stream->avg_frame_rate.den == 0) { - return stream->r_frame_rate; - } -# endif +# else return stream->avg_frame_rate; -#endif +# endif } +#endif #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 32, 0) # define AV_OPT_SEARCH_FAKE_OBJ 0 |