From d35bc4eb2d026441a7e7da88e32d1d1503591631 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 2 Sep 2022 10:08:30 +0200 Subject: [PATCH] ffpmeg 5.1 compat, remove access to private member -- #11 --- libharvid/ffcompat.h | 11 +++++++++++ libharvid/ffdecoder.c | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libharvid/ffcompat.h b/libharvid/ffcompat.h index b60baad..a5e0b01 100644 --- a/libharvid/ffcompat.h +++ b/libharvid/ffcompat.h @@ -151,5 +151,16 @@ register_codecs_compat () #endif } +static inline void +maybe_avcodec_flush_buffers(AVCodecContext *avctx) +{ +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 26, 100) + if (avctx->codec->flush) { + avcodec_flush_buffers(avctx); + } +#else + avcodec_flush_buffers(avctx); +#endif +} #endif /* FFCOMPAT_H */ diff --git a/libharvid/ffdecoder.c b/libharvid/ffdecoder.c index 7b5c751..1b55afb 100644 --- a/libharvid/ffdecoder.c +++ b/libharvid/ffdecoder.c @@ -604,9 +604,7 @@ static int my_seek_frame (ffst *ff, AVPacket *packet, int64_t framenumber) { if (ff->avprev < 0 || ff->avprev >= timestamp || ((ff->avprev + 32 * ff->tpf) < timestamp)) { rv = av_seek_frame(ff->pFormatCtx, ff->videoStream, timestamp, AVSEEK_FLAG_BACKWARD) ; - if (ff->pCodecCtx->codec->flush) { - avcodec_flush_buffers(ff->pCodecCtx); - } + maybe_avcodec_flush_buffers (ff->pCodecCtx); } ff->avprev = -1; @@ -683,9 +681,7 @@ static int my_seek_frame (ffst *ff, AVPacket *packet, int64_t framenumber) { fprintf(stdout, " PTS mismatch want: %"PRId64" got: %"PRId64" -> re-seek\n", timestamp, pts); // re-seek - make a guess, since we don't know the keyframe interval rv = av_seek_frame(ff->pFormatCtx, ff->videoStream, MAX(0, timestamp - ff->tpf * 25), AVSEEK_FLAG_BACKWARD) ; - if (ff->pCodecCtx->codec->flush) { - avcodec_flush_buffers(ff->pCodecCtx); - } + maybe_avcodec_flush_buffers (ff->pCodecCtx); if (rv < 0) { return -3; }